-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Closed
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerregressionIndicates than the issue relates to something that worked in a previous versionIndicates than the issue relates to something that worked in a previous version
Milestone
Description
Command
build
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
20.1.6
Description
This same code used to work but after updating to 20.2 latest I'm seeing the following errors in a handful of places:
X [ERROR] Cannot use "||" with "??" without parentheses
Expressions of the form "x ?? y || z" are not allowed in JavaScript. You must disambiguate between "(x ?? y) || z" and "x ?? (y || z)" by adding parentheses.
Couple of concerns:
- Should this be a breaking change like this?
- The error itself seems to come from the
.html
file but the error mentioned in the CLI appears to be a generated file/line numbers instead of my raw code. - I do have parenthesis in my HTML file, so not sure what recourse I could have to fix this in user-land
Minimal Reproduction
Stackblitz:
https://stackblitz.com/edit/stackblitz-starters-jsu7gzpr?file=src%2Fexample%2Fexample.component.ts
import { Component, signal } from '@angular/core';
@Component({
standalone: true,
selector: 'app-example',
template: `
<h1>Example!</h1>
{{ (someSignal() ?? false) || screenIsReadOnly() }}
`,
})
export class ExampleComponent {
someSignal = signal<boolean | undefined>(true);
screenIsReadOnly = signal<boolean | undefined>(false);
}
Exception or Error
> X [ERROR] Cannot use "||" with "??" without parentheses
> Expressions of the form "x ?? y || z" are not allowed in JavaScript. You must disambiguate between "(x ?? y) || z" and "x ?? (y || z)" by adding parentheses.
Your Environment
Angular CLI: 20.2.0
Node: 20.19.1
Package Manager: npm 10.8.2
OS: linux x64
Angular: 20.2.0
... animations, build, cli, common, compiler, compiler-cli, core
... forms, platform-browser, router
Package Version
------------------------------------
@angular-devkit/architect 0.2002.0
@angular-devkit/core 20.2.0
@angular-devkit/schematics 20.2.0
@schematics/angular 20.2.0
rxjs 7.8.2
typescript 5.9.2
zone.js 0.15.1
Anything else relevant?
No response
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerregressionIndicates than the issue relates to something that worked in a previous versionIndicates than the issue relates to something that worked in a previous version