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
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
No
Description
Hi !
I'm getting a warning telling me i can safely replace ?. with . on an array item, but if this array item isn't there (or the array is empty), then i need the safe call
Here, fleets is of type Fleet[] so fleets[0] can be either Fleet or undefined but i get the warning (shown below) anyway.
For now i've worked around the warning by doing that :
@if (fleets.length > 0) {
{{ fleets[0].label }}
}
But i feel like this should be adressed anyway.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
▲ [WARNING] NG8107: The left side of this optional chain operation does not include 'null' or 'undefined' in its type, therefore the '?.' operator can be replaced with the '.' operator. [plugin angular-compiler]
src/pages/dashboard/dashboard.component.html:35:26:
35 │ {{ fleets[0]?.label || '' }}
╵ ~~~~~
Please provide the environment you discovered this bug in (run ng version)
Duplicate of #46918. This indeed depends on the noUncheckedIndexedAccess TypeScript option, which is typically false, but introduces inaccurate types where the potential for undefined is missing from the type. Angular's diagnostic is entirely based on the type system, so if that is inaccurate then the diagnostic will be inaccurate.
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
No
Description
Hi !
I'm getting a warning telling me i can safely replace ?. with . on an array item, but if this array item isn't there (or the array is empty), then i need the safe call
Here's a code sample :
Here,
fleets
is of typeFleet[]
sofleets[0]
can be eitherFleet
orundefined
but i get the warning (shown below) anyway.For now i've worked around the warning by doing that :
But i feel like this should be adressed anyway.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: