10000 Array indexing with strictNullChecks should return ItemType | undefined · Issue #15661 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Array indexing with strictNullChecks should return ItemType | undefined #15661
Closed
@mmkal

Description

@mmkal

TypeScript Version: 2.2.2

Code

const words = new Array<string>();
words.push("foo");
const bar = words[2];

Expected behavior:
When strictNullChecks is turned on, the type of bar should be string | undefined. In the case above, it will definitely be undefined.

Actual behavior:
The type is string.

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

      0