Skip to content

Using null coalescing operator with style host binding leads to an error #53295

@ssougnez

Description

@ssougnez

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

When using the host property of the "Component" decorator along with the null coalescing operator, the error "tmp_b_0 is not defined" is thrown.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/angular-rh3swb?file=src%2Fmain.ts

Please provide the exception or error you saw

ERROR
Error: tmp_b_0 is not defined

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.0.3
Node: 20.9.0
Package Manager: yarn 1.22.19
OS: win32 x64

Angular: 17.0.4
... animations, common, compiler, compiler-cli, core, elements
... forms, language-service, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.3
@angular-devkit/build-angular   17.0.3
@angular-devkit/core            17.0.3
@angular-devkit/schematics      17.0.3
@angular/cli                    17.0.3
@schematics/angular             17.0.3
ng-packagr                      17.0.0
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Anything else?

It seems that replacing "??" by "||" works.

Metadata

Metadata

Assignees

Labels

P2The issue is important to a large percentage of users, with a workaroundarea: compilerIssues related to `ngc`, Angular's template compilerstate: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions