1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
tests/cases/compiler/arrayDestructuringInSwitch2.ts(11,13): error TS2488: Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator.
==== tests/cases/compiler/arrayDestructuringInSwitch2.ts (1 errors) ====
type X = { kind: "a", a: [1] } | { kind: "b", a: [] }
function foo(x: X): 1 {
const { kind, a } = x;
switch (kind) {
case "a":
return a[0];
case "b":
return 1;
default:
const [n] = a;
~~~
!!! error TS2488: Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator.
return a;
}
}
|