Skip to content

refactor(compiler-cli): relax nullish coalescing non nullable diagnostics on indexed access - #70656

Merged
atscott merged 1 commit into
angular:mainfrom
JeanMeche:fix-nullish-coalescing-check
Sep 10, 2026
Merged

atscott merged 1 commit into
angular:mainfrom
JeanMeche:fix-nullish-coalescing-check

Conversation

@JeanMeche

@JeanMeche JeanMeche commented Sep 9, 2026

Copy link
Copy Markdown
Member

When noUncheckedIndexedAccess is not enabled, indexed accesses do not include undefined in the type. This relaxes the check for nullish coalescing similarly to optional chaining.

Fixes #70655

@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Sep 9, 2026
@ngbot ngbot Bot added this to the Backlog milestone Sep 9, 2026
@JeanMeche
JeanMeche marked this pull request as ready for review September 9, 2026 23:36
@JeanMeche
JeanMeche requested a review from atscott September 9, 2026 23:36
@pullapprove
pullapprove Bot requested a review from josephperrott September 9, 2026 23:36
@JeanMeche
JeanMeche requested review from mattrbeck and removed request for atscott and josephperrott September 9, 2026 23:36
@pullapprove
pullapprove Bot requested a review from josephperrott September 9, 2026 23:36
@JeanMeche
JeanMeche force-pushed the fix-nullish-coalescing-check branch from 234d015 to 3f98f84 Compare September 9, 2026 23:37
@JeanMeche
JeanMeche removed the request for review from josephperrott September 9, 2026 23:37
@pullapprove
pullapprove Bot requested a review from josephperrott September 10, 2026 00:08
@JeanMeche
JeanMeche force-pushed the fix-nullish-coalescing-check branch from c66c6f8 to e8c0e63 Compare September 10, 2026 00:10
@JeanMeche

Copy link
Copy Markdown
Member Author

Addressed the review comments by adding isAccessFromUncheckedIndex to traverse safe navigation chains and parenthesized expressions.

@JeanMeche
JeanMeche force-pushed the fix-nullish-coalescing-check branch from b92ba8d to ea6c4e0 Compare September 10, 2026 00:17
@JeanMeche
JeanMeche force-pushed the fix-nullish-coalescing-check branch from ea6c4e0 to 998667b Compare September 10, 2026 09:10
@JeanMeche

Copy link
Copy Markdown
Member Author

note: The extended diagnostic is globally disabled in g3 (since we landed the optional chaining change) , no need for a TGP here.

@JeanMeche
JeanMeche force-pushed the fix-nullish-coalescing-check branch 2 times, most recently from 6eb28a5 to 4187898 Compare September 10, 2026 09:18
@JeanMeche
JeanMeche removed the request for review from josephperrott September 10, 2026 13:46
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Sep 10, 2026
@JeanMeche
JeanMeche force-pushed the fix-nullish-coalescing-check branch from 4187898 to f0dd648 Compare September 10, 2026 20:45
…tics on indexed access

When noUncheckedIndexedAccess is not enabled, indexed accesses do not include undefined in the type. This relaxes the check for nullish coalescing similarly to optional chaining. Fixes angular#70655

fixes angular#70655
@JeanMeche
JeanMeche force-pushed the fix-nullish-coalescing-check branch from f0dd648 to d31cabb Compare September 10, 2026 20:48
@atscott
atscott merged commit 9090a75 into angular:main Sep 10, 2026
20 of 23 checks passed
@atscott

atscott commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NG8102 reported for potentially out-of-bounds array access

4 participants