-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercore: control flowIssues related to the built-in control flow (@if, @for, @switch)Issues related to the built-in control flow (@if, @for, @switch)state: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
compiler-cli
Is this a regression?
Yes
Description
In the code I am working with, we have a section which looked like this:
<ng-container [ngSwitch]="type">
<!-- commented out code -->
</ng-container>
This used to compile.
If I replace this with the new syntax like this:
@switch (type) {
<!-- commented out code -->
}
it fails to compile with the error shown below.
The switch block contains commented out code for legacy reasons.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
√ Browser application bundle generation complete.
<e> [webpack-dev-middleware] TypeError: Cannot read properties of undefined (reading 'index')
<e> at TemplateDefinitionBuilder.visitSwitchBlock (file:///C:/<myproject>/node_modules/@angular/compiler/fesm2022/compiler.mjs:28574:44)
<e> at SwitchBlock.visit (file:///C:/<myproject>/node_modules/@angular/compiler/fesm2022/compiler.mjs:3970:24)
<e> at visitAll$1 (file:///C:/<myproject>/node_modules/@angular/compiler/fesm2022/compiler.mjs:4184:34)
<e> at TemplateDefinitionBuilder.visitElement (file:///C:/<myproject>/node_modules/@angular/compiler/fesm2022/compiler.mjs:28324:9)
<e> at Element$1.visit (file:///C:/<myproject>/node_modules/@angular/compiler/fesm2022/compiler.mjs:3836:24)
<e> at visitAll$1 (file:///C:/<myproject>/node_modules/@angular/compiler/fesm2022/compiler.mjs:4184:34)
<e> at TemplateDefinitionBuilder.buildTemplateFunction (file:///C:/<myproject>/node_modules/@angular/compiler/fesm2022/compiler.mjs:27798:9)
<e> at compileComponentFromMetadata (file:///C:/<myproject>/node_modules/@angular/compiler/fesm2022/compiler.mjs:30021:60)
<e> at ComponentDecoratorHandler.compileFull (file:///C:/<myproject>/node_modules/@angular/compiler-cli/bundles/chunk-B5URQIVL.js:7010:17)
<e> at TraitCompiler.compile (file:///C:/<myproject>/node_modules/@angular/compiler-cli/bundles/chunk-B5URQIVL.js:1688:38)
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 17.0.8
Node: 18.18.2
Package Manager: npm 10.2.5
OS: win32 x64
Angular: 17.0.8
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1700.8
@angular-devkit/build-angular 17.0.8
@angular-devkit/core 17.0.8
@angular-devkit/schematics 17.0.8
@angular/cdk 17.0.4
@angular/material 17.0.4
@schematics/angular 17.0.8
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.2
Anything else?
No response
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilercore: control flowIssues related to the built-in control flow (@if, @for, @switch)Issues related to the built-in control flow (@if, @for, @switch)state: has PR