File: arrayDestructuringInSwitch2.errors.txt

package info (click to toggle)
node-typescript 4.8.4%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 523,068 kB
  • sloc: javascript: 1,735,777; makefile: 7; sh: 1
file content (20 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (3)
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;
      }
    }