|
| 1 | +=== tests/cases/compiler/classExtendedDiscriminatedUnionInference.ts === |
| 2 | +declare class LocalController<T, U> { |
| 3 | +>LocalController : Symbol(LocalController, Decl(classExtendedDiscriminatedUnionInference.ts, 0, 0)) |
| 4 | +>T : Symbol(T, Decl(classExtendedDiscriminatedUnionInference.ts, 0, 30)) |
| 5 | +>U : Symbol(U, Decl(classExtendedDiscriminatedUnionInference.ts, 0, 32)) |
| 6 | + |
| 7 | + isLocal: true; |
| 8 | +>isLocal : Symbol(LocalController.isLocal, Decl(classExtendedDiscriminatedUnionInference.ts, 0, 37)) |
| 9 | + |
| 10 | + getProps(a: T, b: U): void; |
| 11 | +>getProps : Symbol(LocalController.getProps, Decl(classExtendedDiscriminatedUnionInference.ts, 1, 18)) |
| 12 | +>a : Symbol(a, Decl(classExtendedDiscriminatedUnionInference.ts, 2, 13)) |
| 13 | +>T : Symbol(T, Decl(classExtendedDiscriminatedUnionInference.ts, 0, 30)) |
| 14 | +>b : Symbol(b, Decl(classExtendedDiscriminatedUnionInference.ts, 2, 18)) |
| 15 | +>U : Symbol(U, Decl(classExtendedDiscriminatedUnionInference.ts, 0, 32)) |
| 16 | +} |
| 17 | +declare class GlobalController<T, U> { |
| 18 | +>GlobalController : Symbol(GlobalController, Decl(classExtendedDiscriminatedUnionInference.ts, 3, 1)) |
| 19 | +>T : Symbol(T, Decl(classExtendedDiscriminatedUnionInference.ts, 4, 31)) |
| 20 | +>U : Symbol(U, Decl(classExtendedDiscriminatedUnionInference.ts, 4, 33)) |
| 21 | + |
| 22 | + isLocal: false; |
| 23 | +>isLocal : Symbol(GlobalController.isLocal, Decl(classExtendedDiscriminatedUnionInference.ts, 4, 38)) |
| 24 | + |
| 25 | + // N.B.: Parameter type order is reversed |
| 26 | + getProps(a: U, b: T): void; |
| 27 | +>getProps : Symbol(GlobalController.getProps, Decl(classExtendedDiscriminatedUnionInference.ts, 5, 19)) |
| 28 | +>a : Symbol(a, Decl(classExtendedDiscriminatedUnionInference.ts, 7, 13)) |
| 29 | +>U : Symbol(U, Decl(classExtendedDiscriminatedUnionInference.ts, 4, 33)) |
| 30 | +>b : Symbol(b, Decl(classExtendedDiscriminatedUnionInference.ts, 7, 18)) |
| 31 | +>T : Symbol(T, Decl(classExtendedDiscriminatedUnionInference.ts, 4, 31)) |
| 32 | +} |
| 33 | + |
| 34 | +class FailWithTS42 extends LocalController<{ foo: any }, { bar: any }> { } |
| 35 | +>FailWithTS42 : Symbol(FailWithTS42, Decl(classExtendedDiscriminatedUnionInference.ts, 8, 1)) |
| 36 | +>LocalController : Symbol(LocalController, Decl(classExtendedDiscriminatedUnionInference.ts, 0, 0)) |
| 37 | +>foo : Symbol(foo, Decl(classExtendedDiscriminatedUnionInference.ts, 10, 44)) |
| 38 | +>bar : Symbol(bar, Decl(classExtendedDiscriminatedUnionInference.ts, 10, 58)) |
| 39 | + |
| 40 | +const p = new FailWithTS42(); |
| 41 | +>p : Symbol(p, Decl(classExtendedDiscriminatedUnionInference.ts, 11, 5)) |
| 42 | +>FailWithTS42 : Symbol(FailWithTS42, Decl(classExtendedDiscriminatedUnionInference.ts, 8, 1)) |
| 43 | + |
| 44 | +declare function createEnhancer1<T, U>(Wrapper: GlobalController<T, U> | LocalController<T, U>): [T, U]; |
| 45 | +>createEnhancer1 : Symbol(createEnhancer1, Decl(classExtendedDiscriminatedUnionInference.ts, 11, 29)) |
| 46 | +>T : Symbol(T, Decl(classExtendedDiscriminatedUnionInference.ts, 13, 33)) |
| 47 | +>U : Symbol(U, Decl(classExtendedDiscriminatedUnionInference.ts, 13, 35)) |
| 48 | +>Wrapper : Symbol(Wrapper, Decl(classExtendedDiscriminatedUnionInference.ts, 13, 39)) |
| 49 | +>GlobalController : Symbol(GlobalController, Decl(classExtendedDiscriminatedUnionInference.ts, 3, 1)) |
| 50 | +>T : Symbol(T, Decl(classExtendedDiscriminatedUnionInference.ts, 13, 33)) |
| 51 | +>U : Symbol(U, Decl(classExtendedDiscriminatedUnionInference.ts, 13, 35)) |
| 52 | +>LocalController : Symbol(LocalController, Decl(classExtendedDiscriminatedUnionInference.ts, 0, 0)) |
| 53 | +>T : Symbol(T, Decl(classExtendedDiscriminatedUnionInference.ts, 13, 33)) |
| 54 | +>U : Symbol(U, Decl(classExtendedDiscriminatedUnionInference.ts, 13, 35)) |
| 55 | +>T : Symbol(T, Decl(classExtendedDiscriminatedUnionInference.ts, 13, 33)) |
| 56 | +>U : Symbol(U, Decl(classExtendedDiscriminatedUnionInference.ts, 13, 35)) |
| 57 | + |
| 58 | +const q1 = createEnhancer1(p); |
| 59 | +>q1 : Symbol(q1, Decl(classExtendedDiscriminatedUnionInference.ts, 14, 5)) |
| 60 | +>createEnhancer1 : Symbol(createEnhancer1, Decl(classExtendedDiscriminatedUnionInference.ts, 11, 29)) |
| 61 | +>p : Symbol(p, Decl(classExtendedDiscriminatedUnionInference.ts, 11, 5)) |
| 62 | + |
| 63 | +const q2 = createEnhancer1(p as LocalController<{ foo: any }, { bar: any }>); // structurally identical type to the above |
| 64 | +>q2 : Symbol(q2, Decl(classExtendedDiscriminatedUnionInference.ts, 15, 5)) |
| 65 | +>createEnhancer1 : Symbol(createEnhancer1, Decl(classExtendedDiscriminatedUnionInference.ts, 11, 29)) |
| 66 | +>p : Symbol(p, Decl(classExtendedDiscriminatedUnionInference.ts, 11, 5)) |
| 67 | +>LocalController : Symbol(LocalController, Decl(classExtendedDiscriminatedUnionInference.ts, 0, 0)) |
| 68 | +>foo : Symbol(foo, Decl(classExtendedDiscriminatedUnionInference.ts, 15, 49)) |
| 69 | +>bar : Symbol(bar, Decl(classExtendedDiscriminatedUnionInference.ts, 15, 63)) |
| 70 | + |
0 commit comments