1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
=== tests/cases/compiler/arrayDestructuringInSwitch2.ts ===
type X = { kind: "a", a: [1] } | { kind: "b", a: [] }
>X : { kind: "a"; a: [1]; } | { kind: "b"; a: []; }
>kind : "a"
>a : [1]
>kind : "b"
>a : []
function foo(x: X): 1 {
>foo : (x: X) => 1
>x : X
const { kind, a } = x;
>kind : "a" | "b"
>a : [1] | []
>x : X
switch (kind) {
>kind : "a" | "b"
case "a":
>"a" : "a"
return a[0];
>a[0] : 1
>a : [1]
>0 : 0
case "b":
>"b" : "b"
return 1;
>1 : 1
default:
const [n] = a;
>n : never
>a : never
return a;
>a : never
}
}
|