We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TypeScript Version: 2.4.0
Code
const values = [1, 2]; values.filter((value) => value === 3)[0];
Expected behavior: Object is possibly 'undefined'.
Actual behavior: No errors.
The text was updated successfully, but these errors were encountered:
The type of values is number[] not [number, number] or [1, 2]. Even if tuple types were used however, this still would not be an error.
values
number[]
[number, number]
[1, 2]
See #6229
Sorry, something went wrong.
values.filter((value) => value === 3) is undefined in this case. It doesn't link with provided issue.
values.filter((value) => value === 3)
Duplicate of #13778
It is a conscious decision to favour usability over correctness, though the linked issue indicates it is open for further discussion.
We assume that you are bounds-checking yourself correctly since the alternative is quite a bit worse. See linked issues above.
No branches or pull requests
TypeScript Version: 2.4.0
Code
Expected behavior:
Object is possibly 'undefined'.
Actual behavior:
No errors.
The text was updated successfully, but these errors were encountered: