83 lines
4.2 KiB
Plaintext
83 lines
4.2 KiB
Plaintext
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts ===
|
|
class C { private p: string };
|
|
>C : C, Symbol(C, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 0, 0))
|
|
>p : string, Symbol(p, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 0, 9))
|
|
|
|
var strOrNum: string | number;
|
|
>strOrNum : string | number, Symbol(strOrNum, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 2, 3))
|
|
|
|
var strOrBool: string | boolean;
|
|
>strOrBool : string | boolean, Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 3, 3))
|
|
|
|
var numOrBool: number | boolean
|
|
>numOrBool : number | boolean, Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 4, 3))
|
|
|
|
var strOrC: string | C;
|
|
>strOrC : string | C, Symbol(strOrC, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 5, 3))
|
|
>C : C, Symbol(C, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 0, 0))
|
|
|
|
// typeof x != s has not effect on typeguard
|
|
if (typeof strOrNum != "string") {
|
|
>typeof strOrNum != "string" : boolean
|
|
>typeof strOrNum : string
|
|
>strOrNum : string | number, Symbol(strOrNum, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 2, 3))
|
|
>"string" : string
|
|
|
|
var r1 = strOrNum; // string | number
|
|
>r1 : string | number, Symbol(r1, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 9, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 12, 7))
|
|
>strOrNum : string | number, Symbol(strOrNum, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 2, 3))
|
|
}
|
|
else {
|
|
var r1 = strOrNum; // string | number
|
|
>r1 : string | number, Symbol(r1, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 9, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 12, 7))
|
|
>strOrNum : string | number, Symbol(strOrNum, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 2, 3))
|
|
}
|
|
|
|
if (typeof strOrBool != "boolean") {
|
|
>typeof strOrBool != "boolean" : boolean
|
|
>typeof strOrBool : string
|
|
>strOrBool : string | boolean, Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 3, 3))
|
|
>"boolean" : string
|
|
|
|
var r2 = strOrBool; // string | boolean
|
|
>r2 : string | boolean, Symbol(r2, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 16, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 19, 7))
|
|
>strOrBool : string | boolean, Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 3, 3))
|
|
}
|
|
else {
|
|
var r2 = strOrBool; // string | boolean
|
|
>r2 : string | boolean, Symbol(r2, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 16, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 19, 7))
|
|
>strOrBool : string | boolean, Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 3, 3))
|
|
}
|
|
|
|
if (typeof numOrBool != "number") {
|
|
>typeof numOrBool != "number" : boolean
|
|
>typeof numOrBool : string
|
|
>numOrBool : number | boolean, Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 4, 3))
|
|
>"number" : string
|
|
|
|
var r3 = numOrBool; // number | boolean
|
|
>r3 : number | boolean, Symbol(r3, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 23, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 26, 7))
|
|
>numOrBool : number | boolean, Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 4, 3))
|
|
}
|
|
else {
|
|
var r3 = numOrBool; // number | boolean
|
|
>r3 : number | boolean, Symbol(r3, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 23, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 26, 7))
|
|
>numOrBool : number | boolean, Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 4, 3))
|
|
}
|
|
|
|
if (typeof strOrC != "Object") {
|
|
>typeof strOrC != "Object" : boolean
|
|
>typeof strOrC : string
|
|
>strOrC : string | C, Symbol(strOrC, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 5, 3))
|
|
>"Object" : string
|
|
|
|
var r4 = strOrC; // string | C
|
|
>r4 : string | C, Symbol(r4, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 30, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 33, 7))
|
|
>strOrC : string | C, Symbol(strOrC, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 5, 3))
|
|
}
|
|
else {
|
|
var r4 = strOrC; // string | C
|
|
>r4 : string | C, Symbol(r4, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 30, 7), Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 33, 7))
|
|
>strOrC : string | C, Symbol(strOrC, Decl(typeGuardOfFormTypeOfNotEqualHasNoEffect.ts, 5, 3))
|
|
}
|