|
1 | 1 | === tests/cases/compiler/unionTypeParameterInference.ts === |
| 2 | +// Regression test for #5861 |
| 3 | + |
2 | 4 | interface Foo<T> { prop: T; } |
3 | 5 | >Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0)) |
4 | | ->T : Symbol(T, Decl(unionTypeParameterInference.ts, 0, 14)) |
5 | | ->prop : Symbol(prop, Decl(unionTypeParameterInference.ts, 0, 18)) |
6 | | ->T : Symbol(T, Decl(unionTypeParameterInference.ts, 0, 14)) |
| 6 | +>T : Symbol(T, Decl(unionTypeParameterInference.ts, 2, 14)) |
| 7 | +>prop : Symbol(prop, Decl(unionTypeParameterInference.ts, 2, 18)) |
| 8 | +>T : Symbol(T, Decl(unionTypeParameterInference.ts, 2, 14)) |
7 | 9 |
|
8 | 10 | declare function lift<U>(value: U | Foo<U>): Foo<U>; |
9 | | ->lift : Symbol(lift, Decl(unionTypeParameterInference.ts, 0, 29)) |
10 | | ->U : Symbol(U, Decl(unionTypeParameterInference.ts, 2, 22)) |
11 | | ->value : Symbol(value, Decl(unionTypeParameterInference.ts, 2, 25)) |
12 | | ->U : Symbol(U, Decl(unionTypeParameterInference.ts, 2, 22)) |
| 11 | +>lift : Symbol(lift, Decl(unionTypeParameterInference.ts, 2, 29)) |
| 12 | +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 22)) |
| 13 | +>value : Symbol(value, Decl(unionTypeParameterInference.ts, 4, 25)) |
| 14 | +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 22)) |
13 | 15 | >Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0)) |
14 | | ->U : Symbol(U, Decl(unionTypeParameterInference.ts, 2, 22)) |
| 16 | +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 22)) |
15 | 17 | >Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0)) |
16 | | ->U : Symbol(U, Decl(unionTypeParameterInference.ts, 2, 22)) |
| 18 | +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 22)) |
17 | 19 |
|
18 | 20 | function unlift<U>(value: U | Foo<U>): U { |
19 | | ->unlift : Symbol(unlift, Decl(unionTypeParameterInference.ts, 2, 52)) |
20 | | ->U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 16)) |
21 | | ->value : Symbol(value, Decl(unionTypeParameterInference.ts, 4, 19)) |
22 | | ->U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 16)) |
| 21 | +>unlift : Symbol(unlift, Decl(unionTypeParameterInference.ts, 4, 52)) |
| 22 | +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 6, 16)) |
| 23 | +>value : Symbol(value, Decl(unionTypeParameterInference.ts, 6, 19)) |
| 24 | +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 6, 16)) |
23 | 25 | >Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0)) |
24 | | ->U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 16)) |
25 | | ->U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 16)) |
| 26 | +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 6, 16)) |
| 27 | +>U : Symbol(U, Decl(unionTypeParameterInference.ts, 6, 16)) |
26 | 28 |
|
27 | | - return lift(value).prop; // error TS2322: Type '{}' is not assignable to type 'U'. |
28 | | ->lift(value).prop : Symbol(Foo.prop, Decl(unionTypeParameterInference.ts, 0, 18)) |
29 | | ->lift : Symbol(lift, Decl(unionTypeParameterInference.ts, 0, 29)) |
30 | | ->value : Symbol(value, Decl(unionTypeParameterInference.ts, 4, 19)) |
31 | | ->prop : Symbol(Foo.prop, Decl(unionTypeParameterInference.ts, 0, 18)) |
| 29 | + return lift(value).prop; |
| 30 | +>lift(value).prop : Symbol(Foo.prop, Decl(unionTypeParameterInference.ts, 2, 18)) |
| 31 | +>lift : Symbol(lift, Decl(unionTypeParameterInference.ts, 2, 29)) |
| 32 | +>value : Symbol(value, Decl(unionTypeParameterInference.ts, 6, 19)) |
| 33 | +>prop : Symbol(Foo.prop, Decl(unionTypeParameterInference.ts, 2, 18)) |
32 | 34 | } |
33 | 35 |
|
0 commit comments