Files
Matthieu Riegler 8bc31a515f feat(core): Allow other expression for exhaustive typechecking
When the switched expression is nested within a union, exhaustive typechecking needs to know which expression to check.
This change adds the possibility of specifying the expression to check:

```
@Component({
  selector: 'app-root',
  imports: [],
  template: `
    @switch (state.mode) {
      @case ('show') { {{ state.menu }}; }
      @case ('hide') {}
      @default never(state);
    }
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class App {
  state!: { mode: 'hide' } | { mode: 'show'; menu: number };;
}
```

fixes #67406
2026-03-24 14:42:28 -07:00

73 lines
915 B
HTML

@defer (doSomething({111})) {
<a></a>
}
@defer {
<a></a>
}
@switch (a) {
@case(0) @case (1) {
{{getCase1()}}
}
@case (2) @case(3) {
{{a.b.c}}
}
@default {
default case
}
}
@switch(aOrb) {
@case(a) {}
@default never;
}
@switch(aOrb) {
@case(a) {}
@default never(aOrb.c);
}
@if (a==b) { hello } @else { goodbye }
@if (a==b) {
hello
} @else if (b==a) {
goodbye
}
@for (let item of items; track $index) {
bla
}
@if (
items;
track $index;
let o = $odd
) {
{{o}}
}
@if
(items) {}
@for
(item of items; track $index) { }
@for (item of items; track $index) {
}
@empty
{
}
<!-- `track` is only a keyword at the start of the clause -->
@for (item of items; let track = $index; track item.track) { }
@for (track of tracks; track track) { }
<!-- Should not highlight -->
some.email@google.com ({}) {}