Skip to content

Array lookup should return T | undefined #11122

Closed
@OliverJAsh

Description

@OliverJAsh

TS 2.0.3

    const xs = [1,2,3];
    const x5 = xs[5]; // type is number, expected number | undefined

The type system doesn't know of care about the length of xs, so I would expect any lookup in the array to return T | undefined.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions