Fix some tests

This commit is contained in:
Anders Hejlsberg 2016-03-29 19:59:05 -07:00
parent c6f4de3607
commit e53f390b3e
4 changed files with 16 additions and 24 deletions

View File

@ -41,12 +41,11 @@ else {
c = boolOrC; // C
}
// Narrowing occurs only if target type is a subtype of variable type
if (typeof strOrNum === "boolean") {
var z1: string | number = strOrNum; // string | number
let z1: {} = strOrNum; // {}
}
else {
var z2: string | number = strOrNum; // string | number
let z2: string | number = strOrNum; // string | number
}
@ -78,10 +77,9 @@ else {
bool = boolOrC; // boolean
}
// Narrowing occurs only if target type is a subtype of variable type
if (typeof strOrNum !== "boolean") {
var z1: string | number = strOrNum; // string | number
let z1: string | number = strOrNum; // string | number
}
else {
var z2: string | number = strOrNum; // string | number
let z2: {} = strOrNum; // {}
}

View File

@ -41,12 +41,11 @@ else {
c = numOrC; // C
}
// Narrowing occurs only if target type is a subtype of variable type
if (typeof strOrBool === "number") {
var y1: string | boolean = strOrBool; // string | boolean
let y1: {} = strOrBool; // {}
}
else {
var y2: string | boolean = strOrBool; // string | boolean
let y2: string | boolean = strOrBool; // string | boolean
}
// A type guard of the form typeof x !== s, where s is a string literal,
@ -77,10 +76,9 @@ else {
num = numOrC; // number
}
// Narrowing occurs only if target type is a subtype of variable type
if (typeof strOrBool !== "number") {
var y1: string | boolean = strOrBool; // string | boolean
let y1: string | boolean = strOrBool; // string | boolean
}
else {
var y2: string | boolean = strOrBool; // string | boolean
let y2: {} = strOrBool; // {}
}

View File

@ -37,12 +37,11 @@ else {
var r4: boolean = boolOrC; // boolean
}
// Narrowing occurs only if target type is a subtype of variable type
if (typeof strOrNumOrBool === "Object") {
var q1: string | number | boolean = strOrNumOrBool; // string | number | boolean
let q1: {} = strOrNumOrBool; // {}
}
else {
var q2: string | number | boolean = strOrNumOrBool; // string | number | boolean
let q2: string | number | boolean = strOrNumOrBool; // string | number | boolean
}
// A type guard of the form typeof x !== s, where s is a string literal,
@ -67,10 +66,9 @@ else {
c = boolOrC; // C
}
// Narrowing occurs only if target type is a subtype of variable type
if (typeof strOrNumOrBool !== "Object") {
var q1: string | number | boolean = strOrNumOrBool; // string | number | boolean
let q1: string | number | boolean = strOrNumOrBool; // string | number | boolean
}
else {
var q2: string | number | boolean = strOrNumOrBool; // string | number | boolean
let q2: {} = strOrNumOrBool; // {}
}

View File

@ -41,12 +41,11 @@ else {
c = strOrC; // C
}
// Narrowing occurs only if target type is a subtype of variable type
if (typeof numOrBool === "string") {
var x1: number | boolean = numOrBool; // number | boolean
let x1: {} = numOrBool; // {}
}
else {
var x2: number | boolean = numOrBool; // number | boolean
let x2: number | boolean = numOrBool; // number | boolean
}
// A type guard of the form typeof x !== s, where s is a string literal,
@ -77,10 +76,9 @@ else {
str = strOrC; // string
}
// Narrowing occurs only if target type is a subtype of variable type
if (typeof numOrBool !== "string") {
var x1: number | boolean = numOrBool; // number | boolean
let x1: number | boolean = numOrBool; // number | boolean
}
else {
var x2: number | boolean = numOrBool; // number | boolean
let x2: {} = numOrBool; // {}
}