|
| 1 | +=== tests/cases/conformance/types/typeRelationships/instanceOf/narrowingGenericTypeFromInstanceof01.ts === |
| 2 | +class A<T> { |
| 3 | +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) |
| 4 | +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 8)) |
| 5 | + |
| 6 | + constructor(private a: string) { } |
| 7 | +>a : Symbol(A.a, Decl(narrowingGenericTypeFromInstanceof01.ts, 1, 16)) |
| 8 | +} |
| 9 | + |
| 10 | +class B<T> { |
| 11 | +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) |
| 12 | +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 4, 8)) |
| 13 | +} |
| 14 | + |
| 15 | +function acceptA<T>(a: A<T>) { } |
| 16 | +>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1)) |
| 17 | +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 17)) |
| 18 | +>a : Symbol(a, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 20)) |
| 19 | +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) |
| 20 | +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 17)) |
| 21 | + |
| 22 | +function acceptB<T>(b: B<T>) { } |
| 23 | +>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32)) |
| 24 | +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 17)) |
| 25 | +>b : Symbol(b, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 20)) |
| 26 | +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) |
| 27 | +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 17)) |
| 28 | + |
| 29 | +function test<T>(x: A<T> | B<T>) { |
| 30 | +>test : Symbol(test, Decl(narrowingGenericTypeFromInstanceof01.ts, 8, 32)) |
| 31 | +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14)) |
| 32 | +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) |
| 33 | +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) |
| 34 | +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14)) |
| 35 | +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) |
| 36 | +>T : Symbol(T, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 14)) |
| 37 | + |
| 38 | + if (x instanceof B) { |
| 39 | +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) |
| 40 | +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) |
| 41 | + |
| 42 | + acceptA(x); |
| 43 | +>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1)) |
| 44 | +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) |
| 45 | + } |
| 46 | + |
| 47 | + if (x instanceof A) { |
| 48 | +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) |
| 49 | +>A : Symbol(A, Decl(narrowingGenericTypeFromInstanceof01.ts, 0, 0)) |
| 50 | + |
| 51 | + acceptA(x); |
| 52 | +>acceptA : Symbol(acceptA, Decl(narrowingGenericTypeFromInstanceof01.ts, 5, 1)) |
| 53 | +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) |
| 54 | + } |
| 55 | + |
| 56 | + if (x instanceof B) { |
| 57 | +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) |
| 58 | +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) |
| 59 | + |
| 60 | + acceptB(x); |
| 61 | +>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32)) |
| 62 | +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) |
| 63 | + } |
| 64 | + |
| 65 | + if (x instanceof B) { |
| 66 | +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) |
| 67 | +>B : Symbol(B, Decl(narrowingGenericTypeFromInstanceof01.ts, 2, 1)) |
| 68 | + |
| 69 | + acceptB(x); |
| 70 | +>acceptB : Symbol(acceptB, Decl(narrowingGenericTypeFromInstanceof01.ts, 7, 32)) |
| 71 | +>x : Symbol(x, Decl(narrowingGenericTypeFromInstanceof01.ts, 10, 17)) |
| 72 | + } |
| 73 | +} |
0 commit comments