139 lines
7 KiB
Text
139 lines
7 KiB
Text
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormInstanceOfOnInterface.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.
|
|
|
|
interface C1 {
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 0, 0))
|
|
|
|
(): C1;
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 0, 0))
|
|
|
|
prototype: C1;
|
|
>prototype : Symbol(prototype, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 7, 11))
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 0, 0))
|
|
|
|
p1: string;
|
|
>p1 : Symbol(p1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 8, 18))
|
|
}
|
|
interface C2 {
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 10, 1))
|
|
|
|
(): C2;
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 10, 1))
|
|
|
|
prototype: C2;
|
|
>prototype : Symbol(prototype, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 12, 11))
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 10, 1))
|
|
|
|
p2: number;
|
|
>p2 : Symbol(p2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 13, 18))
|
|
}
|
|
interface D1 extends C1 {
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 15, 1))
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 0, 0))
|
|
|
|
prototype: D1;
|
|
>prototype : Symbol(prototype, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 16, 25))
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 15, 1))
|
|
|
|
p3: number;
|
|
>p3 : Symbol(p3, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 17, 18))
|
|
}
|
|
var str: string;
|
|
>str : Symbol(str, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 20, 3))
|
|
|
|
var num: number;
|
|
>num : Symbol(num, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 21, 3))
|
|
|
|
var strOrNum: string | number;
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 22, 3))
|
|
|
|
var c1: C1;
|
|
>c1 : Symbol(c1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 24, 3))
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 0, 0))
|
|
|
|
var c2: C2;
|
|
>c2 : Symbol(c2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 25, 3))
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 10, 1))
|
|
|
|
var d1: D1;
|
|
>d1 : Symbol(d1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 26, 3))
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 15, 1))
|
|
|
|
var c1Orc2: C1 | C2;
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 27, 3))
|
|
>C1 : Symbol(C1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 0, 0))
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 10, 1))
|
|
|
|
str = c1Orc2 instanceof c1 && c1Orc2.p1; // C1
|
|
>str : Symbol(str, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 20, 3))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 27, 3))
|
|
>c1 : Symbol(c1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 24, 3))
|
|
>c1Orc2.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 8, 18))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 27, 3))
|
|
>p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 8, 18))
|
|
|
|
num = c1Orc2 instanceof c2 && c1Orc2.p2; // C2
|
|
>num : Symbol(num, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 21, 3))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 27, 3))
|
|
>c2 : Symbol(c2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 25, 3))
|
|
>c1Orc2.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 13, 18))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 27, 3))
|
|
>p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 13, 18))
|
|
|
|
str = c1Orc2 instanceof d1 && c1Orc2.p1; // C1
|
|
>str : Symbol(str, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 20, 3))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 27, 3))
|
|
>d1 : Symbol(d1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 26, 3))
|
|
>c1Orc2.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 8, 18))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 27, 3))
|
|
>p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 8, 18))
|
|
|
|
num = c1Orc2 instanceof d1 && c1Orc2.p3; // D1
|
|
>num : Symbol(num, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 21, 3))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 27, 3))
|
|
>d1 : Symbol(d1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 26, 3))
|
|
>c1Orc2.p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 17, 18))
|
|
>c1Orc2 : Symbol(c1Orc2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 27, 3))
|
|
>p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 17, 18))
|
|
|
|
var c2Ord1: C2 | D1;
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 33, 3))
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 10, 1))
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 15, 1))
|
|
|
|
num = c2Ord1 instanceof c2 && c2Ord1.p2; // C2
|
|
>num : Symbol(num, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 21, 3))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 33, 3))
|
|
>c2 : Symbol(c2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 25, 3))
|
|
>c2Ord1.p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 13, 18))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 33, 3))
|
|
>p2 : Symbol(C2.p2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 13, 18))
|
|
|
|
num = c2Ord1 instanceof d1 && c2Ord1.p3; // D1
|
|
>num : Symbol(num, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 21, 3))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 33, 3))
|
|
>d1 : Symbol(d1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 26, 3))
|
|
>c2Ord1.p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 17, 18))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 33, 3))
|
|
>p3 : Symbol(D1.p3, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 17, 18))
|
|
|
|
str = c2Ord1 instanceof d1 && c2Ord1.p1; // D1
|
|
>str : Symbol(str, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 20, 3))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 33, 3))
|
|
>d1 : Symbol(d1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 26, 3))
|
|
>c2Ord1.p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 8, 18))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 33, 3))
|
|
>p1 : Symbol(C1.p1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 8, 18))
|
|
|
|
var r2: D1 | C2 = c2Ord1 instanceof c1 && c2Ord1; // C2 | D1
|
|
>r2 : Symbol(r2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 37, 3))
|
|
>D1 : Symbol(D1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 15, 1))
|
|
>C2 : Symbol(C2, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 10, 1))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 33, 3))
|
|
>c1 : Symbol(c1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 24, 3))
|
|
>c2Ord1 : Symbol(c2Ord1, Decl(typeGuardOfFormInstanceOfOnInterface.ts, 33, 3))
|
|
|