|
| 1 | +//// [tests/cases/compiler/controlFlowUnionContainingTypeParameter1.ts] //// |
| 2 | + |
| 3 | +=== controlFlowUnionContainingTypeParameter1.ts === |
| 4 | +// https://github.com/microsoft/TypeScript/issues/44814 |
| 5 | + |
| 6 | +class TestClass<T> { |
| 7 | +>TestClass : Symbol(TestClass, Decl(controlFlowUnionContainingTypeParameter1.ts, 0, 0)) |
| 8 | +>T : Symbol(T, Decl(controlFlowUnionContainingTypeParameter1.ts, 2, 16)) |
| 9 | + |
| 10 | + typeguard(val: unknown): val is T { |
| 11 | +>typeguard : Symbol(TestClass.typeguard, Decl(controlFlowUnionContainingTypeParameter1.ts, 2, 20)) |
| 12 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 3, 12)) |
| 13 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 3, 12)) |
| 14 | +>T : Symbol(T, Decl(controlFlowUnionContainingTypeParameter1.ts, 2, 16)) |
| 15 | + |
| 16 | + return true; |
| 17 | + } |
| 18 | + f(v: number): void {} |
| 19 | +>f : Symbol(TestClass.f, Decl(controlFlowUnionContainingTypeParameter1.ts, 5, 3)) |
| 20 | +>v : Symbol(v, Decl(controlFlowUnionContainingTypeParameter1.ts, 6, 4)) |
| 21 | + |
| 22 | + h(v: T): void {} |
| 23 | +>h : Symbol(TestClass.h, Decl(controlFlowUnionContainingTypeParameter1.ts, 6, 23)) |
| 24 | +>v : Symbol(v, Decl(controlFlowUnionContainingTypeParameter1.ts, 7, 4)) |
| 25 | +>T : Symbol(T, Decl(controlFlowUnionContainingTypeParameter1.ts, 2, 16)) |
| 26 | + |
| 27 | + func(val: T | number): void { |
| 28 | +>func : Symbol(TestClass.func, Decl(controlFlowUnionContainingTypeParameter1.ts, 7, 18)) |
| 29 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 8, 7)) |
| 30 | +>T : Symbol(T, Decl(controlFlowUnionContainingTypeParameter1.ts, 2, 16)) |
| 31 | + |
| 32 | + if (this.typeguard(val)) { |
| 33 | +>this.typeguard : Symbol(TestClass.typeguard, Decl(controlFlowUnionContainingTypeParameter1.ts, 2, 20)) |
| 34 | +>this : Symbol(TestClass, Decl(controlFlowUnionContainingTypeParameter1.ts, 0, 0)) |
| 35 | +>typeguard : Symbol(TestClass.typeguard, Decl(controlFlowUnionContainingTypeParameter1.ts, 2, 20)) |
| 36 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 8, 7)) |
| 37 | + |
| 38 | + this.h(val); |
| 39 | +>this.h : Symbol(TestClass.h, Decl(controlFlowUnionContainingTypeParameter1.ts, 6, 23)) |
| 40 | +>this : Symbol(TestClass, Decl(controlFlowUnionContainingTypeParameter1.ts, 0, 0)) |
| 41 | +>h : Symbol(TestClass.h, Decl(controlFlowUnionContainingTypeParameter1.ts, 6, 23)) |
| 42 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 8, 7)) |
| 43 | + |
| 44 | + return; |
| 45 | + } |
| 46 | + this.f(val); |
| 47 | +>this.f : Symbol(TestClass.f, Decl(controlFlowUnionContainingTypeParameter1.ts, 5, 3)) |
| 48 | +>this : Symbol(TestClass, Decl(controlFlowUnionContainingTypeParameter1.ts, 0, 0)) |
| 49 | +>f : Symbol(TestClass.f, Decl(controlFlowUnionContainingTypeParameter1.ts, 5, 3)) |
| 50 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 8, 7)) |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +class TestClass2<T extends Date> { |
| 55 | +>TestClass2 : Symbol(TestClass2, Decl(controlFlowUnionContainingTypeParameter1.ts, 15, 1)) |
| 56 | +>T : Symbol(T, Decl(controlFlowUnionContainingTypeParameter1.ts, 17, 17)) |
| 57 | +>Date : Symbol(Date, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.scripthost.d.ts, --, --)) |
| 58 | + |
| 59 | + typeguard(val: unknown): val is T { |
| 60 | +>typeguard : Symbol(TestClass2.typeguard, Decl(controlFlowUnionContainingTypeParameter1.ts, 17, 34)) |
| 61 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 18, 12)) |
| 62 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 18, 12)) |
| 63 | +>T : Symbol(T, Decl(controlFlowUnionContainingTypeParameter1.ts, 17, 17)) |
| 64 | + |
| 65 | + return true; |
| 66 | + } |
| 67 | + f(v: number): void {} |
| 68 | +>f : Symbol(TestClass2.f, Decl(controlFlowUnionContainingTypeParameter1.ts, 20, 3)) |
| 69 | +>v : Symbol(v, Decl(controlFlowUnionContainingTypeParameter1.ts, 21, 4)) |
| 70 | + |
| 71 | + h(v: T): void {} |
| 72 | +>h : Symbol(TestClass2.h, Decl(controlFlowUnionContainingTypeParameter1.ts, 21, 23)) |
| 73 | +>v : Symbol(v, Decl(controlFlowUnionContainingTypeParameter1.ts, 22, 4)) |
| 74 | +>T : Symbol(T, Decl(controlFlowUnionContainingTypeParameter1.ts, 17, 17)) |
| 75 | + |
| 76 | + func(val: T | number): void { |
| 77 | +>func : Symbol(TestClass2.func, Decl(controlFlowUnionContainingTypeParameter1.ts, 22, 18)) |
| 78 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 23, 7)) |
| 79 | +>T : Symbol(T, Decl(controlFlowUnionContainingTypeParameter1.ts, 17, 17)) |
| 80 | + |
| 81 | + if (this.typeguard(val)) { |
| 82 | +>this.typeguard : Symbol(TestClass2.typeguard, Decl(controlFlowUnionContainingTypeParameter1.ts, 17, 34)) |
| 83 | +>this : Symbol(TestClass2, Decl(controlFlowUnionContainingTypeParameter1.ts, 15, 1)) |
| 84 | +>typeguard : Symbol(TestClass2.typeguard, Decl(controlFlowUnionContainingTypeParameter1.ts, 17, 34)) |
| 85 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 23, 7)) |
| 86 | + |
| 87 | + this.h(val); |
| 88 | +>this.h : Symbol(TestClass2.h, Decl(controlFlowUnionContainingTypeParameter1.ts, 21, 23)) |
| 89 | +>this : Symbol(TestClass2, Decl(controlFlowUnionContainingTypeParameter1.ts, 15, 1)) |
| 90 | +>h : Symbol(TestClass2.h, Decl(controlFlowUnionContainingTypeParameter1.ts, 21, 23)) |
| 91 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 23, 7)) |
| 92 | + |
| 93 | + return; |
| 94 | + } |
| 95 | + val; |
| 96 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 23, 7)) |
| 97 | + |
| 98 | + this.f(val); |
| 99 | +>this.f : Symbol(TestClass2.f, Decl(controlFlowUnionContainingTypeParameter1.ts, 20, 3)) |
| 100 | +>this : Symbol(TestClass2, Decl(controlFlowUnionContainingTypeParameter1.ts, 15, 1)) |
| 101 | +>f : Symbol(TestClass2.f, Decl(controlFlowUnionContainingTypeParameter1.ts, 20, 3)) |
| 102 | +>val : Symbol(val, Decl(controlFlowUnionContainingTypeParameter1.ts, 23, 7)) |
| 103 | + } |
| 104 | +} |
| 105 | + |
0 commit comments