Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
No
Description
This seems identical to some of the bits of #44859, but that was marked as closed and potentially fixed. Either the problem crept back in, or it wasn't completely fixed earlier.
Out-of-bounds array accesses are meant to return undefined in normal js execution. So one might have templates with e.g.
{{bars[0] ?? "Hello"}}
{{foos[0]?.Name ?? "Angular"}}
and NG8102 is reported for these, IMO incorrectly.
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-afe3stia?file=src%2Fmain.ts
Please provide the exception or error you saw
▲ [WARNING] NG8102: NG8102: The left side of this nullish coalescing operation does not include 'null' or 'undefined' in its type, therefore the '??' operator can be safely removed. Find more at https://v22.angular.dev/extended-diagnostics/NG8102 [plugin angular-compiler]
src/main.ts:17:4:
17 │ {{bars[0] ?? "Hello"}}
╵ ~~~~~~~~~~~~~~~~~~
▲ [WARNING] NG8102: NG8102: The left side of this nullish coalescing operation does not include 'null' or 'undefined' in its type, therefore the '??' operator can be safely removed. Find more at https://v22.angular.dev/extended-diagnostics/NG8102 [plugin angular-compiler]
src/main.ts:18:4:
18 │ {{foos[0]?.Name ?? "Angular"}}
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~
Please provide the environment you discovered this bug in (run ng version)
I've seen this with Angular 22.1.5, but the one in stackblitz is:
Angular CLI : 22.1.3
Angular : 22.1.1
Node.js : 22.22.3
Package Manager : npm 10.8.2
Operating System : linux x64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 22.1.3 │ ^22.0.0 │
│ @angular/cli │ 22.1.3 │ ^22.0.0 │
│ @angular/common │ 22.1.1 │ ^22.0.0 │
│ @angular/compiler │ 22.1.1 │ ^22.0.0 │
│ @angular/compiler-cli │ 22.1.1 │ ^22.0.0 │
│ @angular/core │ 22.1.1 │ ^22.0.0 │
│ @angular/forms │ 22.1.1 │ ^22.0.0 │
│ @angular/platform-browser │ 22.1.1 │ ^22.0.0 │
│ @angular/router │ 22.1.1 │ ^22.0.0 │
│ rxjs │ 7.8.2 │ ^7.8.1 │
│ typescript │ 6.0.3 │ ~6.0.3 │
└───────────────────────────┴───────────────────┴───────────────────┘
Anything else?
No response
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
No
Description
This seems identical to some of the bits of #44859, but that was marked as closed and potentially fixed. Either the problem crept back in, or it wasn't completely fixed earlier.
Out-of-bounds array accesses are meant to return undefined in normal js execution. So one might have templates with e.g.
and NG8102 is reported for these, IMO incorrectly.
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-afe3stia?file=src%2Fmain.ts
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version)Anything else?
No response