Skip to content

fix(compiler-cli): Produce correct tcb expression for optional chaining - #70232

Open
JeanMeche wants to merge 2 commits into
angular:mainfrom
JeanMeche:tcb-optional-chaining-fix2
Open

fix(compiler-cli): Produce correct tcb expression for optional chaining#70232
JeanMeche wants to merge 2 commits into
angular:mainfrom
JeanMeche:tcb-optional-chaining-fix2

Conversation

@JeanMeche

Copy link
Copy Markdown
Member

The semantics of optional chaining changes when there are extra parenthesis. We need to make sure that we do not introduce some unnecessary ones.

fixes #70143

The semantics of optional chaining changes when there are extra parenthesis. We need to make sure that we do not introduce some unnecessary ones.

fixes angular#70143
@JeanMeche
JeanMeche requested review from JoostK and atscott August 17, 2026 07:39
@angular-robot angular-robot Bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Aug 17, 2026
@ngbot ngbot Bot added this to the Backlog milestone Aug 17, 2026

@JoostK JoostK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this can also be tested from ngtsc's template type checking tests that capture real diagnostics for test components, instead of only asserting against the generated TCB; parenthesis wrapping is subtle enough that any TCB changes are likely to just be accepted without seeing the effect it has on type-checking behaviour.

@JeanMeche

Copy link
Copy Markdown
Member Author

I've added a test, although this issue can already really be caught by the extended diagnostic. Regular TS doesn't mind about unecessary optional chaining.

Comment thread packages/compiler-cli/test/ngtsc/template_typecheck_spec.ts
@JeanMeche
JeanMeche force-pushed the tcb-optional-chaining-fix2 branch from d185f2c to 746355a Compare August 18, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compiler Issues related to `ngc`, Angular's template compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optional chaining in template should short-circuit

3 participants