mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
8bc31a515f
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
73 lines
915 B
HTML
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 ({}) {}
|
|
|