mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
40 lines
1.4 KiB
Plaintext
40 lines
1.4 KiB
Plaintext
//// [tests/cases/compiler/arrayDestructuringInSwitch2.ts] ////
|
|
|
|
=== arrayDestructuringInSwitch2.ts ===
|
|
type X = { kind: "a", a: [1] } | { kind: "b", a: [] }
|
|
>X : Symbol(X, Decl(arrayDestructuringInSwitch2.ts, 0, 0))
|
|
>kind : Symbol(kind, Decl(arrayDestructuringInSwitch2.ts, 0, 10))
|
|
>a : Symbol(a, Decl(arrayDestructuringInSwitch2.ts, 0, 21))
|
|
>kind : Symbol(kind, Decl(arrayDestructuringInSwitch2.ts, 0, 34))
|
|
>a : Symbol(a, Decl(arrayDestructuringInSwitch2.ts, 0, 45))
|
|
|
|
function foo(x: X): 1 {
|
|
>foo : Symbol(foo, Decl(arrayDestructuringInSwitch2.ts, 0, 53))
|
|
>x : Symbol(x, Decl(arrayDestructuringInSwitch2.ts, 2, 13))
|
|
>X : Symbol(X, Decl(arrayDestructuringInSwitch2.ts, 0, 0))
|
|
|
|
const { kind, a } = x;
|
|
>kind : Symbol(kind, Decl(arrayDestructuringInSwitch2.ts, 3, 9))
|
|
>a : Symbol(a, Decl(arrayDestructuringInSwitch2.ts, 3, 15))
|
|
>x : Symbol(x, Decl(arrayDestructuringInSwitch2.ts, 2, 13))
|
|
|
|
switch (kind) {
|
|
>kind : Symbol(kind, Decl(arrayDestructuringInSwitch2.ts, 3, 9))
|
|
|
|
case "a":
|
|
return a[0];
|
|
>a : Symbol(a, Decl(arrayDestructuringInSwitch2.ts, 3, 15))
|
|
>0 : Symbol(0)
|
|
|
|
case "b":
|
|
return 1;
|
|
default:
|
|
const [n] = a;
|
|
>n : Symbol(n, Decl(arrayDestructuringInSwitch2.ts, 10, 13))
|
|
>a : Symbol(a, Decl(arrayDestructuringInSwitch2.ts, 3, 15))
|
|
|
|
return a;
|
|
>a : Symbol(a, Decl(arrayDestructuringInSwitch2.ts, 3, 15))
|
|
}
|
|
}
|