110 lines
5.1 KiB
Plaintext
110 lines
5.1 KiB
Plaintext
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormInstanceOf.ts ===
|
|
// A type guard of the form x instanceof C, where C is of a subtype of the global type 'Function'
|
|
// and C has a property named 'prototype'
|
|
// - when true, narrows the type of x to the type of the 'prototype' property in C provided
|
|
// it is a subtype of the type of x, or
|
|
// - when false, has no effect on the type of x.
|
|
|
|
class C1 {
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0))
|
|
|
|
p1: string;
|
|
>p1 : Symbol(p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10))
|
|
}
|
|
class C2 {
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1))
|
|
|
|
p2: number;
|
|
>p2 : Symbol(p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10))
|
|
}
|
|
class D1 extends C1 {
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1))
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0))
|
|
|
|
p3: number;
|
|
>p3 : Symbol(p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21))
|
|
}
|
|
var str: string;
|
|
>str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 15, 3))
|
|
|
|
var num: number;
|
|
>num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 16, 3))
|
|
|
|
var strOrNum: string | number;
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormInstanceOf.ts, 17, 3))
|
|
|
|
var c1Orc2: C1 | C2;
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3))
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0))
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1))
|
|
|
|
str = c1Orc2 instanceof C1 && c1Orc2.p1; // C1
|
|
>str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 15, 3))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3))
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0))
|
|
>c1Orc2.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3))
|
|
>p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10))
|
|
|
|
num = c1Orc2 instanceof C2 && c1Orc2.p2; // C2
|
|
>num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 16, 3))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3))
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1))
|
|
>c1Orc2.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3))
|
|
>p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10))
|
|
|
|
str = c1Orc2 instanceof D1 && c1Orc2.p1; // D1
|
|
>str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 15, 3))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3))
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1))
|
|
>c1Orc2.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3))
|
|
>p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10))
|
|
|
|
num = c1Orc2 instanceof D1 && c1Orc2.p3; // D1
|
|
>num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 16, 3))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3))
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1))
|
|
>c1Orc2.p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOf.ts, 19, 3))
|
|
>p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21))
|
|
|
|
var c2Ord1: C2 | D1;
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3))
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1))
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1))
|
|
|
|
num = c2Ord1 instanceof C2 && c2Ord1.p2; // C2
|
|
>num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 16, 3))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3))
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1))
|
|
>c2Ord1.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3))
|
|
>p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOf.ts, 9, 10))
|
|
|
|
num = c2Ord1 instanceof D1 && c2Ord1.p3; // D1
|
|
>num : Symbol(num, Decl(typeGuardOfFormInstanceOf.ts, 16, 3))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3))
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1))
|
|
>c2Ord1.p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3))
|
|
>p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOf.ts, 12, 21))
|
|
|
|
str = c2Ord1 instanceof D1 && c2Ord1.p1; // D1
|
|
>str : Symbol(str, Decl(typeGuardOfFormInstanceOf.ts, 15, 3))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3))
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1))
|
|
>c2Ord1.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3))
|
|
>p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOf.ts, 6, 10))
|
|
|
|
var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1
|
|
>r2 : Symbol(r2, Decl(typeGuardOfFormInstanceOf.ts, 29, 3))
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOf.ts, 11, 1))
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOf.ts, 8, 1))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3))
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOf.ts, 0, 0))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOf.ts, 25, 3))
|
|
|