TypeScript/tests/cases/conformance/expressions/typeGuards/typeGuardNesting.ts
2015-10-29 17:51:36 -07:00

15 lines
836 B
TypeScript

let strOrBool: string|boolean;
if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'string') {
let label: string = (typeof strOrBool === 'string') ? strOrBool : "string";
let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false;
let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string";
let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false;
}
if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boolean') {
let label: string = (typeof strOrBool === 'string') ? strOrBool : "string";
let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false;
let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string";
let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false;
}