96 lines
4.3 KiB
Text
96 lines
4.3 KiB
Text
=== tests/cases/conformance/expressions/typeGuards/typeGuardsInProperties.ts ===
|
|
|
|
// Note that type guards affect types of variables and parameters only and
|
|
// have no effect on members of objects such as properties.
|
|
|
|
var num: number;
|
|
>num : Symbol(num, Decl(typeGuardsInProperties.ts, 4, 3))
|
|
|
|
var strOrNum: string | number;
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInProperties.ts, 5, 3))
|
|
|
|
class C1 {
|
|
>C1 : Symbol(C1, Decl(typeGuardsInProperties.ts, 5, 30))
|
|
|
|
private pp1: string | number;
|
|
>pp1 : Symbol(pp1, Decl(typeGuardsInProperties.ts, 6, 10))
|
|
|
|
pp2: string | number;
|
|
>pp2 : Symbol(pp2, Decl(typeGuardsInProperties.ts, 7, 33))
|
|
|
|
// Inside public accessor getter
|
|
get pp3() {
|
|
>pp3 : Symbol(pp3, Decl(typeGuardsInProperties.ts, 8, 25))
|
|
|
|
return strOrNum;
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInProperties.ts, 5, 3))
|
|
}
|
|
method() {
|
|
>method : Symbol(method, Decl(typeGuardsInProperties.ts, 12, 5))
|
|
|
|
strOrNum = typeof this.pp1 === "string" && this.pp1; // string | number
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInProperties.ts, 5, 3))
|
|
>this.pp1 : Symbol(pp1, Decl(typeGuardsInProperties.ts, 6, 10))
|
|
>this : Symbol(C1, Decl(typeGuardsInProperties.ts, 5, 30))
|
|
>pp1 : Symbol(pp1, Decl(typeGuardsInProperties.ts, 6, 10))
|
|
>this.pp1 : Symbol(pp1, Decl(typeGuardsInProperties.ts, 6, 10))
|
|
>this : Symbol(C1, Decl(typeGuardsInProperties.ts, 5, 30))
|
|
>pp1 : Symbol(pp1, Decl(typeGuardsInProperties.ts, 6, 10))
|
|
|
|
strOrNum = typeof this.pp2 === "string" && this.pp2; // string | number
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInProperties.ts, 5, 3))
|
|
>this.pp2 : Symbol(pp2, Decl(typeGuardsInProperties.ts, 7, 33))
|
|
>this : Symbol(C1, Decl(typeGuardsInProperties.ts, 5, 30))
|
|
>pp2 : Symbol(pp2, Decl(typeGuardsInProperties.ts, 7, 33))
|
|
>this.pp2 : Symbol(pp2, Decl(typeGuardsInProperties.ts, 7, 33))
|
|
>this : Symbol(C1, Decl(typeGuardsInProperties.ts, 5, 30))
|
|
>pp2 : Symbol(pp2, Decl(typeGuardsInProperties.ts, 7, 33))
|
|
|
|
strOrNum = typeof this.pp3 === "string" && this.pp3; // string | number
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInProperties.ts, 5, 3))
|
|
>this.pp3 : Symbol(pp3, Decl(typeGuardsInProperties.ts, 8, 25))
|
|
>this : Symbol(C1, Decl(typeGuardsInProperties.ts, 5, 30))
|
|
>pp3 : Symbol(pp3, Decl(typeGuardsInProperties.ts, 8, 25))
|
|
>this.pp3 : Symbol(pp3, Decl(typeGuardsInProperties.ts, 8, 25))
|
|
>this : Symbol(C1, Decl(typeGuardsInProperties.ts, 5, 30))
|
|
>pp3 : Symbol(pp3, Decl(typeGuardsInProperties.ts, 8, 25))
|
|
}
|
|
}
|
|
var c1: C1;
|
|
>c1 : Symbol(c1, Decl(typeGuardsInProperties.ts, 19, 3))
|
|
>C1 : Symbol(C1, Decl(typeGuardsInProperties.ts, 5, 30))
|
|
|
|
strOrNum = typeof c1.pp2 === "string" && c1.pp2; // string | number
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInProperties.ts, 5, 3))
|
|
>c1.pp2 : Symbol(C1.pp2, Decl(typeGuardsInProperties.ts, 7, 33))
|
|
>c1 : Symbol(c1, Decl(typeGuardsInProperties.ts, 19, 3))
|
|
>pp2 : Symbol(C1.pp2, Decl(typeGuardsInProperties.ts, 7, 33))
|
|
>c1.pp2 : Symbol(C1.pp2, Decl(typeGuardsInProperties.ts, 7, 33))
|
|
>c1 : Symbol(c1, Decl(typeGuardsInProperties.ts, 19, 3))
|
|
>pp2 : Symbol(C1.pp2, Decl(typeGuardsInProperties.ts, 7, 33))
|
|
|
|
strOrNum = typeof c1.pp3 === "string" && c1.pp3; // string | number
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInProperties.ts, 5, 3))
|
|
>c1.pp3 : Symbol(C1.pp3, Decl(typeGuardsInProperties.ts, 8, 25))
|
|
>c1 : Symbol(c1, Decl(typeGuardsInProperties.ts, 19, 3))
|
|
>pp3 : Symbol(C1.pp3, Decl(typeGuardsInProperties.ts, 8, 25))
|
|
>c1.pp3 : Symbol(C1.pp3, Decl(typeGuardsInProperties.ts, 8, 25))
|
|
>c1 : Symbol(c1, Decl(typeGuardsInProperties.ts, 19, 3))
|
|
>pp3 : Symbol(C1.pp3, Decl(typeGuardsInProperties.ts, 8, 25))
|
|
|
|
var obj1: {
|
|
>obj1 : Symbol(obj1, Decl(typeGuardsInProperties.ts, 22, 3))
|
|
|
|
x: string | number;
|
|
>x : Symbol(x, Decl(typeGuardsInProperties.ts, 22, 11))
|
|
|
|
};
|
|
strOrNum = typeof obj1.x === "string" && obj1.x; // string | number
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInProperties.ts, 5, 3))
|
|
>obj1.x : Symbol(x, Decl(typeGuardsInProperties.ts, 22, 11))
|
|
>obj1 : Symbol(obj1, Decl(typeGuardsInProperties.ts, 22, 3))
|
|
>x : Symbol(x, Decl(typeGuardsInProperties.ts, 22, 11))
|
|
>obj1.x : Symbol(x, Decl(typeGuardsInProperties.ts, 22, 11))
|
|
>obj1 : Symbol(obj1, Decl(typeGuardsInProperties.ts, 22, 3))
|
|
>x : Symbol(x, Decl(typeGuardsInProperties.ts, 22, 11))
|
|
|