1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
=== tests/cases/compiler/narrowingOfDottedNames.ts ===
// Repro from #8383
class A {
>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0))
prop: { a: string; };
>prop : Symbol(A.prop, Decl(narrowingOfDottedNames.ts, 2, 9))
>a : Symbol(a, Decl(narrowingOfDottedNames.ts, 3, 11))
}
class B {
>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1))
prop: { b: string; }
>prop : Symbol(B.prop, Decl(narrowingOfDottedNames.ts, 6, 9))
>b : Symbol(b, Decl(narrowingOfDottedNames.ts, 7, 11))
}
function isA(x: any): x is A {
>isA : Symbol(isA, Decl(narrowingOfDottedNames.ts, 8, 1))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 10, 13))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 10, 13))
>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0))
return x instanceof A;
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 10, 13))
>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0))
}
function isB(x: any): x is B {
>isB : Symbol(isB, Decl(narrowingOfDottedNames.ts, 12, 1))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 14, 13))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 14, 13))
>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1))
return x instanceof B;
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 14, 13))
>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1))
}
function f1(x: A | B) {
>f1 : Symbol(f1, Decl(narrowingOfDottedNames.ts, 16, 1))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 18, 12))
>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0))
>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1))
while (true) {
if (x instanceof A) {
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 18, 12))
>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0))
x.prop.a;
>x.prop.a : Symbol(a, Decl(narrowingOfDottedNames.ts, 3, 11))
>x.prop : Symbol(A.prop, Decl(narrowingOfDottedNames.ts, 2, 9))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 18, 12))
>prop : Symbol(A.prop, Decl(narrowingOfDottedNames.ts, 2, 9))
>a : Symbol(a, Decl(narrowingOfDottedNames.ts, 3, 11))
}
else if (x instanceof B) {
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 18, 12))
>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1))
x.prop.b;
>x.prop.b : Symbol(b, Decl(narrowingOfDottedNames.ts, 7, 11))
>x.prop : Symbol(B.prop, Decl(narrowingOfDottedNames.ts, 6, 9))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 18, 12))
>prop : Symbol(B.prop, Decl(narrowingOfDottedNames.ts, 6, 9))
>b : Symbol(b, Decl(narrowingOfDottedNames.ts, 7, 11))
}
}
}
function f2(x: A | B) {
>f2 : Symbol(f2, Decl(narrowingOfDottedNames.ts, 27, 1))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 29, 12))
>A : Symbol(A, Decl(narrowingOfDottedNames.ts, 0, 0))
>B : Symbol(B, Decl(narrowingOfDottedNames.ts, 4, 1))
while (true) {
if (isA(x)) {
>isA : Symbol(isA, Decl(narrowingOfDottedNames.ts, 8, 1))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 29, 12))
x.prop.a;
>x.prop.a : Symbol(a, Decl(narrowingOfDottedNames.ts, 3, 11))
>x.prop : Symbol(A.prop, Decl(narrowingOfDottedNames.ts, 2, 9))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 29, 12))
>prop : Symbol(A.prop, Decl(narrowingOfDottedNames.ts, 2, 9))
>a : Symbol(a, Decl(narrowingOfDottedNames.ts, 3, 11))
}
else if (isB(x)) {
>isB : Symbol(isB, Decl(narrowingOfDottedNames.ts, 12, 1))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 29, 12))
x.prop.b;
>x.prop.b : Symbol(b, Decl(narrowingOfDottedNames.ts, 7, 11))
>x.prop : Symbol(B.prop, Decl(narrowingOfDottedNames.ts, 6, 9))
>x : Symbol(x, Decl(narrowingOfDottedNames.ts, 29, 12))
>prop : Symbol(B.prop, Decl(narrowingOfDottedNames.ts, 6, 9))
>b : Symbol(b, Decl(narrowingOfDottedNames.ts, 7, 11))
}
}
}
|