Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array indexing with strictNullChecks should return ItemType | undefined #15661

Closed
mmkal opened this issue May 8, 2017 · 1 comment
Closed
Labels
Duplicate An existing issue was already created

Comments

@mmkal
Copy link

mmkal commented May 8, 2017

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.

@ahejlsberg
Copy link
Member

Duplicate of #13778.

@ahejlsberg ahejlsberg added the Duplicate An existing issue was already created label May 8, 2017
@mhegazy mhegazy closed this as completed May 8, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants