You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The indexing of a T[] by a number is typed as a T, instead of a T|undefined.
I encountered that when applying a .filter to one of my arrays then doing [0].fieldaccess, and then noticing no error despite that field access failing if the filter returns an empty array (since the 0-indexing returns undefined).
Bug Type
What does this bug affect
Angular Language Service VSCode extension
Angular Language Service server
(not sure which, if any)
Reproduction
functionf(a: number[]){constb=a[0];b.toFixed(0);// no typing error report}
Hovering b shows it as type number, when it should be number|undefined.
Logs
No log since this has no effect on performance and nothing is reported when it should.
The doc example may not be super obvious here, but this option will cause undefined to be included in the return type for index read access operations, as with the array in question.
🐞 bug report
Is this a regression?
No idea.
Description
The indexing of a
T[]
by a number is typed as aT
, instead of aT|undefined
.I encountered that when applying a
.filter
to one of my arrays then doing[0].fieldaccess
, and then noticing no error despite that field access failing if the filter returns an empty array (since the 0-indexing returns undefined).Bug Type
What does this bug affect
(not sure which, if any)
Reproduction
Hovering b shows it as type
number
, when it should benumber|undefined
.Logs
No log since this has no effect on performance and nothing is reported when it should.
Screenshots
🌍 Your Environment
Angular Version:
Extension Version:
VSCode Version:
Operating System:
Extension options:
I didn't find any settings.json file.
The text was updated successfully, but these errors were encountered: