252 lines
12 KiB
Text
252 lines
12 KiB
Text
=== tests/cases/conformance/expressions/typeGuards/typeGuardsInClassAccessors.ts ===
|
|
|
|
// Note that type guards affect types of variables and parameters only and
|
|
// have no effect on members of objects such as properties.
|
|
|
|
// variables in global
|
|
var num: number;
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
|
|
var strOrNum: string | number;
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInClassAccessors.ts, 6, 3))
|
|
|
|
var var1: string | number;
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
|
|
class ClassWithAccessors {
|
|
>ClassWithAccessors : Symbol(ClassWithAccessors, Decl(typeGuardsInClassAccessors.ts, 7, 26))
|
|
|
|
// Inside public accessor getter
|
|
get p1() {
|
|
>p1 : Symbol(p1, Decl(typeGuardsInClassAccessors.ts, 8, 26), Decl(typeGuardsInClassAccessors.ts, 19, 5))
|
|
|
|
// global vars in function declaration
|
|
num = typeof var1 === "string" && var1.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>var1.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// variables in function declaration
|
|
var var2: string | number;
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 15, 11))
|
|
|
|
num = typeof var2 === "string" && var2.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 15, 11))
|
|
>var2.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 15, 11))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
return strOrNum;
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInClassAccessors.ts, 6, 3))
|
|
}
|
|
// Inside public accessor setter
|
|
set p1(param: string | number) {
|
|
>p1 : Symbol(p1, Decl(typeGuardsInClassAccessors.ts, 8, 26), Decl(typeGuardsInClassAccessors.ts, 19, 5))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 21, 11))
|
|
|
|
// global vars in function declaration
|
|
num = typeof var1 === "string" && var1.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>var1.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// parameter of function declaration
|
|
num = typeof param === "string" && param.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 21, 11))
|
|
>param.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 21, 11))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// variables in function declaration
|
|
var var2: string | number;
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 29, 11))
|
|
|
|
num = typeof var2 === "string" && var2.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 29, 11))
|
|
>var2.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 29, 11))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
}
|
|
// Inside private accessor getter
|
|
private get pp1() {
|
|
>pp1 : Symbol(pp1, Decl(typeGuardsInClassAccessors.ts, 31, 5), Decl(typeGuardsInClassAccessors.ts, 42, 5))
|
|
|
|
// global vars in function declaration
|
|
num = typeof var1 === "string" && var1.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>var1.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// variables in function declaration
|
|
var var2: string | number;
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 38, 11))
|
|
|
|
num = typeof var2 === "string" && var2.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 38, 11))
|
|
>var2.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 38, 11))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
return strOrNum;
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInClassAccessors.ts, 6, 3))
|
|
}
|
|
// Inside private accessor setter
|
|
private set pp1(param: string | number) {
|
|
>pp1 : Symbol(pp1, Decl(typeGuardsInClassAccessors.ts, 31, 5), Decl(typeGuardsInClassAccessors.ts, 42, 5))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 44, 20))
|
|
|
|
// global vars in function declaration
|
|
num = typeof var1 === "string" && var1.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>var1.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// parameter of function declaration
|
|
num = typeof param === "string" && param.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 44, 20))
|
|
>param.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 44, 20))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// variables in function declaration
|
|
var var2: string | number;
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 52, 11))
|
|
|
|
num = typeof var2 === "string" && var2.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 52, 11))
|
|
>var2.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 52, 11))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
}
|
|
// Inside static accessor getter
|
|
static get s1() {
|
|
>s1 : Symbol(ClassWithAccessors.s1, Decl(typeGuardsInClassAccessors.ts, 54, 5), Decl(typeGuardsInClassAccessors.ts, 65, 5))
|
|
|
|
// global vars in function declaration
|
|
num = typeof var1 === "string" && var1.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>var1.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// variables in function declaration
|
|
var var2: string | number;
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 61, 11))
|
|
|
|
num = typeof var2 === "string" && var2.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 61, 11))
|
|
>var2.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 61, 11))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
return strOrNum;
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInClassAccessors.ts, 6, 3))
|
|
}
|
|
// Inside static accessor setter
|
|
static set s1(param: string | number) {
|
|
>s1 : Symbol(ClassWithAccessors.s1, Decl(typeGuardsInClassAccessors.ts, 54, 5), Decl(typeGuardsInClassAccessors.ts, 65, 5))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 67, 18))
|
|
|
|
// global vars in function declaration
|
|
num = typeof var1 === "string" && var1.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>var1.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// parameter of function declaration
|
|
num = typeof param === "string" && param.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 67, 18))
|
|
>param.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 67, 18))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// variables in function declaration
|
|
var var2: string | number;
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 75, 11))
|
|
|
|
num = typeof var2 === "string" && var2.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 75, 11))
|
|
>var2.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 75, 11))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
}
|
|
// Inside private static accessor getter
|
|
private static get ss1() {
|
|
>ss1 : Symbol(ClassWithAccessors.ss1, Decl(typeGuardsInClassAccessors.ts, 77, 5), Decl(typeGuardsInClassAccessors.ts, 88, 5))
|
|
|
|
// global vars in function declaration
|
|
num = typeof var1 === "string" && var1.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>var1.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// variables in function declaration
|
|
var var2: string | number;
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 84, 11))
|
|
|
|
num = typeof var2 === "string" && var2.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 84, 11))
|
|
>var2.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 84, 11))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
return strOrNum;
|
|
>strOrNum : Symbol(strOrNum, Decl(typeGuardsInClassAccessors.ts, 6, 3))
|
|
}
|
|
// Inside private static accessor setter
|
|
private static set ss1(param: string | number) {
|
|
>ss1 : Symbol(ClassWithAccessors.ss1, Decl(typeGuardsInClassAccessors.ts, 77, 5), Decl(typeGuardsInClassAccessors.ts, 88, 5))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 90, 27))
|
|
|
|
// global vars in function declaration
|
|
num = typeof var1 === "string" && var1.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>var1.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var1 : Symbol(var1, Decl(typeGuardsInClassAccessors.ts, 7, 3))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// parameter of function declaration
|
|
num = typeof param === "string" && param.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 90, 27))
|
|
>param.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>param : Symbol(param, Decl(typeGuardsInClassAccessors.ts, 90, 27))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
|
|
// variables in function declaration
|
|
var var2: string | number;
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 98, 11))
|
|
|
|
num = typeof var2 === "string" && var2.length; // string
|
|
>num : Symbol(num, Decl(typeGuardsInClassAccessors.ts, 5, 3))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 98, 11))
|
|
>var2.length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
>var2 : Symbol(var2, Decl(typeGuardsInClassAccessors.ts, 98, 11))
|
|
>length : Symbol(String.length, Decl(lib.d.ts, 414, 19))
|
|
}
|
|
}
|
|
|