mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
We type check `@switch` blocks by generating identical TS `switch` statements in the TCB, however TS currently has a bug where parenthesized `switch` block expressions don't narrow their types. Since we use parenthesized expressions to wrap AST nodes for diagnostics, this will bug will affect all Angular-generated `switch` statements. These changes work around the issue by generating `if`/`else if`/`else` statements that represent the `switch`. Some alternatives that were considered: 1. Moving the `switch` expression to a constant - this is fairly simple to implement, but it won't fully resolve the narrowing issue since the same constant will have to be used in expressions inside the different cases. 2. Removing the outer-most parenthesis from the switch expression - this works and allows us to continue using switch statements, but because we use parenthesized expressions to map diagnostics to their template locations, I wasn't sure if it won't lead to worse template dignostics. Fixes #52077. PR Close #52110 |
||
|---|---|---|
| .. | ||
| integrationtest | ||
| linker | ||
| ngcc | ||
| private | ||
| src | ||
| test | ||
| BUILD.bazel | ||
| esbuild.config.js | ||
| index.ts | ||
| package.json | ||
| tsconfig-build.json | ||
| tsconfig.json | ||