|
| 1 | +=== tests/cases/compiler/genericObjectSpreadResultInSwitch.ts === |
| 2 | +type Params = { |
| 3 | +>Params : Symbol(Params, Decl(genericObjectSpreadResultInSwitch.ts, 0, 0)) |
| 4 | + |
| 5 | + foo: string; |
| 6 | +>foo : Symbol(foo, Decl(genericObjectSpreadResultInSwitch.ts, 0, 15)) |
| 7 | + |
| 8 | +} & ({ tag: 'a'; type: number } | { tag: 'b'; type: string }); |
| 9 | +>tag : Symbol(tag, Decl(genericObjectSpreadResultInSwitch.ts, 2, 6)) |
| 10 | +>type : Symbol(type, Decl(genericObjectSpreadResultInSwitch.ts, 2, 16)) |
| 11 | +>tag : Symbol(tag, Decl(genericObjectSpreadResultInSwitch.ts, 2, 35)) |
| 12 | +>type : Symbol(type, Decl(genericObjectSpreadResultInSwitch.ts, 2, 45)) |
| 13 | + |
| 14 | +const getType = <P extends Params>(params: P) => { |
| 15 | +>getType : Symbol(getType, Decl(genericObjectSpreadResultInSwitch.ts, 4, 5)) |
| 16 | +>P : Symbol(P, Decl(genericObjectSpreadResultInSwitch.ts, 4, 17)) |
| 17 | +>Params : Symbol(Params, Decl(genericObjectSpreadResultInSwitch.ts, 0, 0)) |
| 18 | +>params : Symbol(params, Decl(genericObjectSpreadResultInSwitch.ts, 4, 35)) |
| 19 | +>P : Symbol(P, Decl(genericObjectSpreadResultInSwitch.ts, 4, 17)) |
| 20 | + |
| 21 | + const { |
| 22 | + // Omit |
| 23 | + foo, |
| 24 | +>foo : Symbol(foo, Decl(genericObjectSpreadResultInSwitch.ts, 5, 11)) |
| 25 | + |
| 26 | + ...rest |
| 27 | +>rest : Symbol(rest, Decl(genericObjectSpreadResultInSwitch.ts, 7, 12)) |
| 28 | + |
| 29 | + } = params; |
| 30 | +>params : Symbol(params, Decl(genericObjectSpreadResultInSwitch.ts, 4, 35)) |
| 31 | + |
| 32 | + return rest; |
| 33 | +>rest : Symbol(rest, Decl(genericObjectSpreadResultInSwitch.ts, 7, 12)) |
| 34 | + |
| 35 | +}; |
| 36 | + |
| 37 | +declare const params: Params; |
| 38 | +>params : Symbol(params, Decl(genericObjectSpreadResultInSwitch.ts, 15, 13)) |
| 39 | +>Params : Symbol(Params, Decl(genericObjectSpreadResultInSwitch.ts, 0, 0)) |
| 40 | + |
| 41 | +switch (params.tag) { |
| 42 | +>params.tag : Symbol(tag, Decl(genericObjectSpreadResultInSwitch.ts, 2, 6), Decl(genericObjectSpreadResultInSwitch.ts, 2, 35)) |
| 43 | +>params : Symbol(params, Decl(genericObjectSpreadResultInSwitch.ts, 15, 13)) |
| 44 | +>tag : Symbol(tag, Decl(genericObjectSpreadResultInSwitch.ts, 2, 6), Decl(genericObjectSpreadResultInSwitch.ts, 2, 35)) |
| 45 | + |
| 46 | + case 'a': { |
| 47 | + // TS 4.2: number |
| 48 | + // TS 4.3: string | number |
| 49 | + const result = getType(params).type; |
| 50 | +>result : Symbol(result, Decl(genericObjectSpreadResultInSwitch.ts, 21, 13)) |
| 51 | +>getType(params).type : Symbol(type, Decl(genericObjectSpreadResultInSwitch.ts, 2, 16)) |
| 52 | +>getType : Symbol(getType, Decl(genericObjectSpreadResultInSwitch.ts, 4, 5)) |
| 53 | +>params : Symbol(params, Decl(genericObjectSpreadResultInSwitch.ts, 15, 13)) |
| 54 | +>type : Symbol(type, Decl(genericObjectSpreadResultInSwitch.ts, 2, 16)) |
| 55 | + |
| 56 | + break; |
| 57 | + } |
| 58 | + case 'b': { |
| 59 | + // TS 4.2: string |
| 60 | + // TS 4.3: string | number |
| 61 | + const result = getType(params).type; |
| 62 | +>result : Symbol(result, Decl(genericObjectSpreadResultInSwitch.ts, 28, 13)) |
| 63 | +>getType(params).type : Symbol(type, Decl(genericObjectSpreadResultInSwitch.ts, 2, 45)) |
| 64 | +>getType : Symbol(getType, Decl(genericObjectSpreadResultInSwitch.ts, 4, 5)) |
| 65 | +>params : Symbol(params, Decl(genericObjectSpreadResultInSwitch.ts, 15, 13)) |
| 66 | +>type : Symbol(type, Decl(genericObjectSpreadResultInSwitch.ts, 2, 45)) |
| 67 | + |
| 68 | + break; |
| 69 | + } |
| 70 | +} |
0 commit comments