mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
20 lines
620 B
Plaintext
20 lines
620 B
Plaintext
arrayDestructuringInSwitch2.ts(11,13): error TS2488: Type 'never' must have a '[Symbol.iterator]()' method that returns an iterator.
|
|
|
|
|
|
==== 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;
|
|
}
|
|
} |