Skip to content

fix(compiler): allow safe navigation to correctly narrow down nullables - #67959

Merged
kirjs merged 1 commit into
angular:mainfrom
JeanMeche:safe-navigation-narrow
Apr 9, 2026
Merged

fix(compiler): allow safe navigation to correctly narrow down nullables#67959
kirjs merged 1 commit into
angular:mainfrom
JeanMeche:safe-navigation-narrow

Conversation

@JeanMeche

@JeanMeche JeanMeche commented Mar 31, 2026

Copy link
Copy Markdown
Member

The commit updates the TCB for safe navigation expressions to allow for correct narrowing of nullables.

This will trigger the nullishCoalescingNotNullable and optionalChainNotNullable diagnostics on exisiting projects.
You might want to disable those 2 diagnotiscs in your tsconfig temporarily if you want to update your project without having to fix all the issues at once.

Narrowing can be disabled altogether with strictSafeNavigationTyes: false.

fixes #37619

BREAKING CHANGE: This change will trigger the nullishCoalescingNotNullable and optionalChainNotNullable diagnostics on exisiting projects.
You might want to disable those 2 diagnotiscs in your tsconfig temporarily.

The migration for disabling nullishCoalescingNotNullable & optionalChainNotNullable on ng update will be added on a follow-up PR.

@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Mar 31, 2026
@ngbot ngbot Bot added this to the Backlog milestone Mar 31, 2026
@JeanMeche
JeanMeche force-pushed the safe-navigation-narrow branch 2 times, most recently from ecf9bad to 441aa96 Compare April 3, 2026 01:22
@angular-robot angular-robot Bot added the detected: feature PR contains a feature commit label Apr 3, 2026
@JeanMeche
JeanMeche force-pushed the safe-navigation-narrow branch 5 times, most recently from 3a478f1 to 2715b40 Compare April 7, 2026 08:25
@angular-robot angular-robot Bot added the detected: breaking change PR contains a commit with a breaking change label Apr 7, 2026
@JeanMeche
JeanMeche requested a review from crisbeto April 7, 2026 09:22
@JeanMeche
JeanMeche marked this pull request as ready for review April 7, 2026 09:22
@JeanMeche JeanMeche added the state: blocked on G3 cleanup This change requires a G3 cleanup label Apr 7, 2026
@JeanMeche

This comment was marked as outdated.

@JeanMeche

Copy link
Copy Markdown
Member Author

Passing TGP

@JeanMeche JeanMeche removed the state: blocked on G3 cleanup This change requires a G3 cleanup label Apr 7, 2026
@JeanMeche

Copy link
Copy Markdown
Member Author

G3 update was submitted

@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release labels Apr 8, 2026
aparzi added a commit to aparzi/angular that referenced this pull request Apr 8, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
@JeanMeche JeanMeche added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Apr 8, 2026
@JeanMeche
JeanMeche force-pushed the safe-navigation-narrow branch from 2715b40 to 874a83e Compare April 8, 2026 17:08
@JeanMeche JeanMeche added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Apr 8, 2026
@JeanMeche
JeanMeche force-pushed the safe-navigation-narrow branch from 874a83e to 1d0d46b Compare April 8, 2026 18:26
@JeanMeche JeanMeche removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Apr 8, 2026
@JeanMeche
JeanMeche force-pushed the safe-navigation-narrow branch from 1d0d46b to b1bcdc2 Compare April 8, 2026 18:44
aparzi added a commit to aparzi/angular that referenced this pull request Apr 8, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
aparzi added a commit to aparzi/angular that referenced this pull request Apr 8, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
aparzi added a commit to aparzi/angular that referenced this pull request Apr 9, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
The commit updates the TCB for safe navigation expressions to allow for correct narrowing of nullables.

This will trigger the `nullishCoalescingNotNullable` and `optionalChainNotNullable` diagnostics on exisiting projects.
You might want to disable those 2 diagnotiscs in your `tsconfig` temporarily if you want to update your project without having to fix all the issues at once.

Narrowing can be disabled altogether with `strictSafeNavigationTyes: false`.

fixes angular#37619

BREAKING CHANGE: This change will trigger the `nullishCoalescingNotNullable` and `optionalChainNotNullable` diagnostics on exisiting projects.
You might want to disable those 2 diagnotiscs in your `tsconfig` temporarily.
@JeanMeche
JeanMeche force-pushed the safe-navigation-narrow branch from b1bcdc2 to ee5e6d7 Compare April 9, 2026 12:40
aparzi added a commit to aparzi/angular that referenced this pull request Apr 9, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
@kirjs

kirjs commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

I'm merging this because TGP passed, and presubmit also passed, but we had to change a commit message.

@kirjs
kirjs merged commit 47fcbc4 into angular:main Apr 9, 2026
17 of 19 checks passed
@kirjs

kirjs commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

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

aparzi added a commit to aparzi/angular that referenced this pull request Apr 9, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
aparzi added a commit to aparzi/angular that referenced this pull request Apr 9, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
aparzi added a commit to aparzi/angular that referenced this pull request Apr 9, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
aparzi added a commit to aparzi/angular that referenced this pull request Apr 9, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
aparzi added a commit to aparzi/angular that referenced this pull request Apr 9, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
aparzi added a commit to aparzi/angular that referenced this pull request Apr 9, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
aparzi added a commit to aparzi/angular that referenced this pull request Apr 11, 2026
…ainNotNullable on ng update

Related to angular#67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
kirjs pushed a commit that referenced this pull request Apr 13, 2026
…ainNotNullable on ng update

Related to #67959 disabling two diagnostics errors by `ng update`:

- nullishCoalescingNotNullable
- optionalChainNotNullable
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators May 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler detected: breaking change PR contains a commit with a breaking change detected: feature PR contains a feature commit target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

strictTemplates and strictNullChecks doesn't work well with optional chaining in templates

3 participants