1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfPrimitiveSubtype.ts ===
let a: {};
>a : {}
let b: {toString(): string};
>b : { toString(): string; }
>toString : () => string
if (typeof a === "number") {
>typeof a === "number" : boolean
>typeof a : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>a : {}
>"number" : "number"
let c: number = a;
>c : number
>a : number
}
if (typeof a === "string") {
>typeof a === "string" : boolean
>typeof a : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>a : {}
>"string" : "string"
let c: string = a;
>c : string
>a : string
}
if (typeof a === "boolean") {
>typeof a === "boolean" : boolean
>typeof a : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>a : {}
>"boolean" : "boolean"
let c: boolean = a;
>c : boolean
>a : boolean
}
if (typeof b === "number") {
>typeof b === "number" : boolean
>typeof b : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>b : { toString(): string; }
>"number" : "number"
let c: number = b;
>c : number
>b : number
}
if (typeof b === "string") {
>typeof b === "string" : boolean
>typeof b : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>b : { toString(): string; }
>"string" : "string"
let c: string = b;
>c : string
>b : string
}
if (typeof b === "boolean") {
>typeof b === "boolean" : boolean
>typeof b : "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"
>b : { toString(): string; }
>"boolean" : "boolean"
let c: boolean = b;
>c : boolean
>b : boolean
}
|