|
| 1 | +//// [tests/cases/compiler/exhaustiveSwitchStatementsGeneric1.ts] //// |
| 2 | + |
| 3 | +=== exhaustiveSwitchStatementsGeneric1.ts === |
| 4 | +// https://github.com/microsoft/typescript-go/issues/986 |
| 5 | + |
| 6 | +interface A { |
| 7 | +>A : Symbol(A, Decl(exhaustiveSwitchStatementsGeneric1.ts, 0, 0)) |
| 8 | + |
| 9 | + type: "a"; |
| 10 | +>type : Symbol(type, Decl(exhaustiveSwitchStatementsGeneric1.ts, 2, 13)) |
| 11 | +} |
| 12 | + |
| 13 | +interface B { |
| 14 | +>B : Symbol(B, Decl(exhaustiveSwitchStatementsGeneric1.ts, 4, 1)) |
| 15 | + |
| 16 | + type: "b"; |
| 17 | +>type : Symbol(type, Decl(exhaustiveSwitchStatementsGeneric1.ts, 6, 13)) |
| 18 | +} |
| 19 | + |
| 20 | +interface Types { |
| 21 | +>Types : Symbol(Types, Decl(exhaustiveSwitchStatementsGeneric1.ts, 8, 1)) |
| 22 | + |
| 23 | + a: A; |
| 24 | +>a : Symbol(a, Decl(exhaustiveSwitchStatementsGeneric1.ts, 10, 17)) |
| 25 | +>A : Symbol(A, Decl(exhaustiveSwitchStatementsGeneric1.ts, 0, 0)) |
| 26 | + |
| 27 | + b: B; |
| 28 | +>b : Symbol(b, Decl(exhaustiveSwitchStatementsGeneric1.ts, 11, 7)) |
| 29 | +>B : Symbol(B, Decl(exhaustiveSwitchStatementsGeneric1.ts, 4, 1)) |
| 30 | +} |
| 31 | + |
| 32 | +export function exhaustiveSwitch<T extends keyof Types>(type: T): boolean { |
| 33 | +>exhaustiveSwitch : Symbol(exhaustiveSwitch, Decl(exhaustiveSwitchStatementsGeneric1.ts, 13, 1)) |
| 34 | +>T : Symbol(T, Decl(exhaustiveSwitchStatementsGeneric1.ts, 15, 33)) |
| 35 | +>Types : Symbol(Types, Decl(exhaustiveSwitchStatementsGeneric1.ts, 8, 1)) |
| 36 | +>type : Symbol(type, Decl(exhaustiveSwitchStatementsGeneric1.ts, 15, 56)) |
| 37 | +>T : Symbol(T, Decl(exhaustiveSwitchStatementsGeneric1.ts, 15, 33)) |
| 38 | + |
| 39 | + switch (type) { |
| 40 | +>type : Symbol(type, Decl(exhaustiveSwitchStatementsGeneric1.ts, 15, 56)) |
| 41 | + |
| 42 | + case "a": |
| 43 | + return true; |
| 44 | + case "b": |
| 45 | + return true; |
| 46 | + } |
| 47 | +} |
| 48 | + |
0 commit comments