镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

out of range index in a tuple magically works #5203

Description

var x : [number, number] = [1, 2];
var y = x[2]; // expected a compile error, actual ok

By design, isn't it?

Activity

  1. RyanCavanaugh commented on Oct 12, 2015

    @RyanCavanaugh
    Member

    It is currently per spec, but I don't think this behavior is desirable. This should probably be an error by some new rule.

  2. DanielRosenwasser commented on Oct 12, 2015

    @DanielRosenwasser
    Member

    Well the problem is that you're going to get that numeric index signature from Array<T>. There is another discussion about having an alternative interface for tuples at #4988 (comment).

  3. zpdDG4gta8XKpMCd commented on Oct 12, 2015

    @zpdDG4gta8XKpMCd
    Author

    I know guys you are trying your best, but I don't see an array, I only see a tuple which is not an array in a broad sense.

  4. falsandtru commented on Oct 14, 2015

    @falsandtru
    Contributor

    👍 This is invalid behavior.

  5. OliverJAsh commented on Dec 23, 2015

    @OliverJAsh
    Contributor

    I ran into exactly the same issue.

  6. Igorbek commented on Sep 19, 2016

    @Igorbek
    Contributor

    See proposal #6229

  7. RyanCavanaugh commented on Aug 6, 2018

    @RyanCavanaugh
    Member

    Aleksey-Bykov the arc of language design is long but it bends toward justice. Accepting PRs

  8. zpdDG4gta8XKpMCd commented on Aug 6, 2018

    @zpdDG4gta8XKpMCd
    Author

    god works in mysterious ways

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CommittedThe team has roadmapped this issueGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do thisSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions