From a38d86391002b7a9bb0ba4c666be3bae015f1cce Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 29 Mar 2016 20:00:40 -0700 Subject: [PATCH] Accepting new baselines --- .../reference/typeGuardOfFormTypeOfBoolean.js | 16 ++++----- .../typeGuardOfFormTypeOfBoolean.symbols | 18 +++++----- .../typeGuardOfFormTypeOfBoolean.types | 24 ++++++------- .../reference/typeGuardOfFormTypeOfNumber.js | 16 ++++----- .../typeGuardOfFormTypeOfNumber.symbols | 22 ++++++------ .../typeGuardOfFormTypeOfNumber.types | 22 ++++++------ .../reference/typeGuardOfFormTypeOfOther.js | 16 ++++----- .../typeGuardOfFormTypeOfOther.symbols | 30 ++++++++-------- .../typeGuardOfFormTypeOfOther.types | 24 ++++++------- .../reference/typeGuardOfFormTypeOfString.js | 16 ++++----- .../typeGuardOfFormTypeOfString.symbols | 18 +++++----- .../typeGuardOfFormTypeOfString.types | 18 +++++----- .../typeGuardTautologicalConsistiency.types | 6 ++-- .../reference/typeGuardTypeOfUndefined.types | 34 +++++++++---------- 14 files changed, 124 insertions(+), 156 deletions(-) diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.js b/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.js index e9e11275d0d..7d68b893373 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.js +++ b/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.js @@ -42,12 +42,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 } @@ -79,12 +78,11 @@ 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; // {} } @@ -134,9 +132,8 @@ if (typeof boolOrC === "boolean") { else { c = boolOrC; // C } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNum === "boolean") { - var z1 = strOrNum; // string | number + var z1 = strOrNum; // {} } else { var z2 = strOrNum; // string | number @@ -168,10 +165,9 @@ if (typeof boolOrC !== "boolean") { else { bool = boolOrC; // boolean } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNum !== "boolean") { var z1 = strOrNum; // string | number } else { - var z2 = strOrNum; // string | number + var z2 = strOrNum; // {} } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.symbols b/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.symbols index d3879519228..dbef84c28c7 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.symbols +++ b/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.symbols @@ -93,17 +93,16 @@ else { >boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfBoolean.ts, 11, 3)) } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNum === "boolean") { >strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfBoolean.ts, 5, 3)) - var z1: string | number = strOrNum; // string | number ->z1 : Symbol(z1, Decl(typeGuardOfFormTypeOfBoolean.ts, 45, 7), Decl(typeGuardOfFormTypeOfBoolean.ts, 82, 7)) + let z1: {} = strOrNum; // {} +>z1 : Symbol(z1, Decl(typeGuardOfFormTypeOfBoolean.ts, 44, 7)) >strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfBoolean.ts, 5, 3)) } else { - var z2: string | number = strOrNum; // string | number ->z2 : Symbol(z2, Decl(typeGuardOfFormTypeOfBoolean.ts, 48, 7), Decl(typeGuardOfFormTypeOfBoolean.ts, 85, 7)) + let z2: string | number = strOrNum; // string | number +>z2 : Symbol(z2, Decl(typeGuardOfFormTypeOfBoolean.ts, 47, 7)) >strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfBoolean.ts, 5, 3)) } @@ -160,17 +159,16 @@ else { >boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfBoolean.ts, 11, 3)) } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNum !== "boolean") { >strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfBoolean.ts, 5, 3)) - var z1: string | number = strOrNum; // string | number ->z1 : Symbol(z1, Decl(typeGuardOfFormTypeOfBoolean.ts, 45, 7), Decl(typeGuardOfFormTypeOfBoolean.ts, 82, 7)) + let z1: string | number = strOrNum; // string | number +>z1 : Symbol(z1, Decl(typeGuardOfFormTypeOfBoolean.ts, 80, 7)) >strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfBoolean.ts, 5, 3)) } else { - var z2: string | number = strOrNum; // string | number ->z2 : Symbol(z2, Decl(typeGuardOfFormTypeOfBoolean.ts, 48, 7), Decl(typeGuardOfFormTypeOfBoolean.ts, 85, 7)) + let z2: {} = strOrNum; // {} +>z2 : Symbol(z2, Decl(typeGuardOfFormTypeOfBoolean.ts, 83, 7)) >strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfBoolean.ts, 5, 3)) } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types b/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types index 9d9f28548be..a5dcc9207cd 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types @@ -113,19 +113,18 @@ else { >boolOrC : C } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNum === "boolean") { >typeof strOrNum === "boolean" : boolean >typeof strOrNum : string >strOrNum : string | number >"boolean" : string - var z1: string | number = strOrNum; // string | number ->z1 : string | number ->strOrNum : string | number + let z1: {} = strOrNum; // {} +>z1 : {} +>strOrNum : {} } else { - var z2: string | number = strOrNum; // string | number + let z2: string | number = strOrNum; // string | number >z2 : string | number >strOrNum : string | number } @@ -137,7 +136,7 @@ else { if (typeof strOrBool !== "boolean") { >typeof strOrBool !== "boolean" : boolean >typeof strOrBool : string ->strOrBool : string | boolean +>strOrBool : boolean | string >"boolean" : string str = strOrBool; // string @@ -154,7 +153,7 @@ else { if (typeof numOrBool !== "boolean") { >typeof numOrBool !== "boolean" : boolean >typeof numOrBool : string ->numOrBool : number | boolean +>numOrBool : boolean | number >"boolean" : string num = numOrBool; // number @@ -171,7 +170,7 @@ else { if (typeof strOrNumOrBool !== "boolean") { >typeof strOrNumOrBool !== "boolean" : boolean >typeof strOrNumOrBool : string ->strOrNumOrBool : string | number | boolean +>strOrNumOrBool : boolean | string | number >"boolean" : string strOrNum = strOrNumOrBool; // string | number @@ -203,20 +202,19 @@ else { >boolOrC : boolean } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNum !== "boolean") { >typeof strOrNum !== "boolean" : boolean >typeof strOrNum : string >strOrNum : string | number >"boolean" : string - var z1: string | number = strOrNum; // string | number + let z1: string | number = strOrNum; // string | number >z1 : string | number >strOrNum : string | number } else { - var z2: string | number = strOrNum; // string | number ->z2 : string | number ->strOrNum : string | number + let z2: {} = strOrNum; // {} +>z2 : {} +>strOrNum : {} } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfNumber.js b/tests/baselines/reference/typeGuardOfFormTypeOfNumber.js index 66fcff0c387..3bea6e87d2b 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfNumber.js +++ b/tests/baselines/reference/typeGuardOfFormTypeOfNumber.js @@ -42,12 +42,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, @@ -78,12 +77,11 @@ 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; // {} } @@ -133,9 +131,8 @@ if (typeof numOrC === "number") { else { c = numOrC; // C } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrBool === "number") { - var y1 = strOrBool; // string | boolean + var y1 = strOrBool; // {} } else { var y2 = strOrBool; // string | boolean @@ -167,10 +164,9 @@ if (typeof numOrC !== "number") { else { num = numOrC; // number } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrBool !== "number") { var y1 = strOrBool; // string | boolean } else { - var y2 = strOrBool; // string | boolean + var y2 = strOrBool; // {} } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfNumber.symbols b/tests/baselines/reference/typeGuardOfFormTypeOfNumber.symbols index 2fd48389ae8..f38c348131e 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfNumber.symbols +++ b/tests/baselines/reference/typeGuardOfFormTypeOfNumber.symbols @@ -65,7 +65,7 @@ if (typeof numOrBool === "number") { } else { var x: number | boolean = numOrBool; // number | boolean ->x : Symbol(x, Decl(typeGuardOfFormTypeOfNumber.ts, 28, 7), Decl(typeGuardOfFormTypeOfNumber.ts, 61, 7)) +>x : Symbol(x, Decl(typeGuardOfFormTypeOfNumber.ts, 28, 7), Decl(typeGuardOfFormTypeOfNumber.ts, 60, 7)) >numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNumber.ts, 7, 3)) } if (typeof strOrNumOrBool === "number") { @@ -93,17 +93,16 @@ else { >numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfNumber.ts, 10, 3)) } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrBool === "number") { >strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNumber.ts, 6, 3)) - var y1: string | boolean = strOrBool; // string | boolean ->y1 : Symbol(y1, Decl(typeGuardOfFormTypeOfNumber.ts, 45, 7), Decl(typeGuardOfFormTypeOfNumber.ts, 81, 7)) + let y1: {} = strOrBool; // {} +>y1 : Symbol(y1, Decl(typeGuardOfFormTypeOfNumber.ts, 44, 7)) >strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNumber.ts, 6, 3)) } else { - var y2: string | boolean = strOrBool; // string | boolean ->y2 : Symbol(y2, Decl(typeGuardOfFormTypeOfNumber.ts, 48, 7), Decl(typeGuardOfFormTypeOfNumber.ts, 84, 7)) + let y2: string | boolean = strOrBool; // string | boolean +>y2 : Symbol(y2, Decl(typeGuardOfFormTypeOfNumber.ts, 47, 7)) >strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNumber.ts, 6, 3)) } @@ -126,7 +125,7 @@ if (typeof numOrBool !== "number") { >numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNumber.ts, 7, 3)) var x: number | boolean = numOrBool; // number | boolean ->x : Symbol(x, Decl(typeGuardOfFormTypeOfNumber.ts, 28, 7), Decl(typeGuardOfFormTypeOfNumber.ts, 61, 7)) +>x : Symbol(x, Decl(typeGuardOfFormTypeOfNumber.ts, 28, 7), Decl(typeGuardOfFormTypeOfNumber.ts, 60, 7)) >numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfNumber.ts, 7, 3)) } else { @@ -159,17 +158,16 @@ else { >numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfNumber.ts, 10, 3)) } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrBool !== "number") { >strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNumber.ts, 6, 3)) - var y1: string | boolean = strOrBool; // string | boolean ->y1 : Symbol(y1, Decl(typeGuardOfFormTypeOfNumber.ts, 45, 7), Decl(typeGuardOfFormTypeOfNumber.ts, 81, 7)) + let y1: string | boolean = strOrBool; // string | boolean +>y1 : Symbol(y1, Decl(typeGuardOfFormTypeOfNumber.ts, 79, 7)) >strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNumber.ts, 6, 3)) } else { - var y2: string | boolean = strOrBool; // string | boolean ->y2 : Symbol(y2, Decl(typeGuardOfFormTypeOfNumber.ts, 48, 7), Decl(typeGuardOfFormTypeOfNumber.ts, 84, 7)) + let y2: {} = strOrBool; // {} +>y2 : Symbol(y2, Decl(typeGuardOfFormTypeOfNumber.ts, 82, 7)) >strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfNumber.ts, 6, 3)) } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types b/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types index d3caef24efd..99f927b7137 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types @@ -112,19 +112,18 @@ else { >numOrC : C } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrBool === "number") { >typeof strOrBool === "number" : boolean >typeof strOrBool : string >strOrBool : string | boolean >"number" : string - var y1: string | boolean = strOrBool; // string | boolean ->y1 : string | boolean ->strOrBool : string | boolean + let y1: {} = strOrBool; // {} +>y1 : {} +>strOrBool : {} } else { - var y2: string | boolean = strOrBool; // string | boolean + let y2: string | boolean = strOrBool; // string | boolean >y2 : string | boolean >strOrBool : string | boolean } @@ -135,7 +134,7 @@ else { if (typeof strOrNum !== "number") { >typeof strOrNum !== "number" : boolean >typeof strOrNum : string ->strOrNum : string | number +>strOrNum : number | string >"number" : string str === strOrNum; // string @@ -168,7 +167,7 @@ else { if (typeof strOrNumOrBool !== "number") { >typeof strOrNumOrBool !== "number" : boolean >typeof strOrNumOrBool : string ->strOrNumOrBool : string | number | boolean +>strOrNumOrBool : number | string | boolean >"number" : string strOrBool = strOrNumOrBool; // string | boolean @@ -200,20 +199,19 @@ else { >numOrC : number } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrBool !== "number") { >typeof strOrBool !== "number" : boolean >typeof strOrBool : string >strOrBool : string | boolean >"number" : string - var y1: string | boolean = strOrBool; // string | boolean + let y1: string | boolean = strOrBool; // string | boolean >y1 : string | boolean >strOrBool : string | boolean } else { - var y2: string | boolean = strOrBool; // string | boolean ->y2 : string | boolean ->strOrBool : string | boolean + let y2: {} = strOrBool; // {} +>y2 : {} +>strOrBool : {} } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.js b/tests/baselines/reference/typeGuardOfFormTypeOfOther.js index b1e6ca26566..ee0b6f66332 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.js +++ b/tests/baselines/reference/typeGuardOfFormTypeOfOther.js @@ -38,12 +38,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, @@ -68,12 +67,11 @@ 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; // {} } @@ -118,9 +116,8 @@ if (typeof boolOrC === "Object") { else { var r4 = boolOrC; // boolean } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNumOrBool === "Object") { - var q1 = strOrNumOrBool; // string | number | boolean + var q1 = strOrNumOrBool; // {} } else { var q2 = strOrNumOrBool; // string | number | boolean @@ -146,10 +143,9 @@ if (typeof boolOrC !== "Object") { else { c = boolOrC; // C } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNumOrBool !== "Object") { var q1 = strOrNumOrBool; // string | number | boolean } else { - var q2 = strOrNumOrBool; // string | number | boolean + var q2 = strOrNumOrBool; // {} } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols b/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols index ba759871a9b..a8760feda45 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols +++ b/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols @@ -57,7 +57,7 @@ if (typeof strOrC === "Object") { } else { var r2: string = strOrC; // string ->r2 : Symbol(r2, Decl(typeGuardOfFormTypeOfOther.ts, 24, 7), Decl(typeGuardOfFormTypeOfOther.ts, 51, 7)) +>r2 : Symbol(r2, Decl(typeGuardOfFormTypeOfOther.ts, 24, 7), Decl(typeGuardOfFormTypeOfOther.ts, 50, 7)) >strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) } if (typeof numOrC === "Object") { @@ -69,7 +69,7 @@ if (typeof numOrC === "Object") { } else { var r3: number = numOrC; // number ->r3 : Symbol(r3, Decl(typeGuardOfFormTypeOfOther.ts, 30, 7), Decl(typeGuardOfFormTypeOfOther.ts, 57, 7)) +>r3 : Symbol(r3, Decl(typeGuardOfFormTypeOfOther.ts, 30, 7), Decl(typeGuardOfFormTypeOfOther.ts, 56, 7)) >numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) } if (typeof boolOrC === "Object") { @@ -81,21 +81,20 @@ if (typeof boolOrC === "Object") { } else { var r4: boolean = boolOrC; // boolean ->r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfOther.ts, 36, 7), Decl(typeGuardOfFormTypeOfOther.ts, 63, 7)) +>r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfOther.ts, 36, 7), Decl(typeGuardOfFormTypeOfOther.ts, 62, 7)) >boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNumOrBool === "Object") { >strOrNumOrBool : Symbol(strOrNumOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 8, 3)) - var q1: string | number | boolean = strOrNumOrBool; // string | number | boolean ->q1 : Symbol(q1, Decl(typeGuardOfFormTypeOfOther.ts, 41, 7), Decl(typeGuardOfFormTypeOfOther.ts, 71, 7)) + let q1: {} = strOrNumOrBool; // {} +>q1 : Symbol(q1, Decl(typeGuardOfFormTypeOfOther.ts, 40, 7)) >strOrNumOrBool : Symbol(strOrNumOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 8, 3)) } else { - var q2: string | number | boolean = strOrNumOrBool; // string | number | boolean ->q2 : Symbol(q2, Decl(typeGuardOfFormTypeOfOther.ts, 44, 7), Decl(typeGuardOfFormTypeOfOther.ts, 74, 7)) + let q2: string | number | boolean = strOrNumOrBool; // string | number | boolean +>q2 : Symbol(q2, Decl(typeGuardOfFormTypeOfOther.ts, 43, 7)) >strOrNumOrBool : Symbol(strOrNumOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 8, 3)) } @@ -106,7 +105,7 @@ if (typeof strOrC !== "Object") { >strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) var r2: string = strOrC; // string ->r2 : Symbol(r2, Decl(typeGuardOfFormTypeOfOther.ts, 24, 7), Decl(typeGuardOfFormTypeOfOther.ts, 51, 7)) +>r2 : Symbol(r2, Decl(typeGuardOfFormTypeOfOther.ts, 24, 7), Decl(typeGuardOfFormTypeOfOther.ts, 50, 7)) >strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) } else { @@ -118,7 +117,7 @@ if (typeof numOrC !== "Object") { >numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) var r3: number = numOrC; // number ->r3 : Symbol(r3, Decl(typeGuardOfFormTypeOfOther.ts, 30, 7), Decl(typeGuardOfFormTypeOfOther.ts, 57, 7)) +>r3 : Symbol(r3, Decl(typeGuardOfFormTypeOfOther.ts, 30, 7), Decl(typeGuardOfFormTypeOfOther.ts, 56, 7)) >numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) } else { @@ -130,7 +129,7 @@ if (typeof boolOrC !== "Object") { >boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) var r4: boolean = boolOrC; // boolean ->r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfOther.ts, 36, 7), Decl(typeGuardOfFormTypeOfOther.ts, 63, 7)) +>r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfOther.ts, 36, 7), Decl(typeGuardOfFormTypeOfOther.ts, 62, 7)) >boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) } else { @@ -139,17 +138,16 @@ else { >boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNumOrBool !== "Object") { >strOrNumOrBool : Symbol(strOrNumOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 8, 3)) - var q1: string | number | boolean = strOrNumOrBool; // string | number | boolean ->q1 : Symbol(q1, Decl(typeGuardOfFormTypeOfOther.ts, 41, 7), Decl(typeGuardOfFormTypeOfOther.ts, 71, 7)) + let q1: string | number | boolean = strOrNumOrBool; // string | number | boolean +>q1 : Symbol(q1, Decl(typeGuardOfFormTypeOfOther.ts, 69, 7)) >strOrNumOrBool : Symbol(strOrNumOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 8, 3)) } else { - var q2: string | number | boolean = strOrNumOrBool; // string | number | boolean ->q2 : Symbol(q2, Decl(typeGuardOfFormTypeOfOther.ts, 44, 7), Decl(typeGuardOfFormTypeOfOther.ts, 74, 7)) + let q2: {} = strOrNumOrBool; // {} +>q2 : Symbol(q2, Decl(typeGuardOfFormTypeOfOther.ts, 72, 7)) >strOrNumOrBool : Symbol(strOrNumOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 8, 3)) } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.types b/tests/baselines/reference/typeGuardOfFormTypeOfOther.types index 5cec3567194..aba8e429b8c 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfOther.types @@ -97,19 +97,18 @@ else { >boolOrC : boolean } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNumOrBool === "Object") { >typeof strOrNumOrBool === "Object" : boolean >typeof strOrNumOrBool : string >strOrNumOrBool : string | number | boolean >"Object" : string - var q1: string | number | boolean = strOrNumOrBool; // string | number | boolean ->q1 : string | number | boolean ->strOrNumOrBool : string | number | boolean + let q1: {} = strOrNumOrBool; // {} +>q1 : {} +>strOrNumOrBool : {} } else { - var q2: string | number | boolean = strOrNumOrBool; // string | number | boolean + let q2: string | number | boolean = strOrNumOrBool; // string | number | boolean >q2 : string | number | boolean >strOrNumOrBool : string | number | boolean } @@ -120,7 +119,7 @@ else { if (typeof strOrC !== "Object") { >typeof strOrC !== "Object" : boolean >typeof strOrC : string ->strOrC : string | C +>strOrC : C | string >"Object" : string var r2: string = strOrC; // string @@ -136,7 +135,7 @@ else { if (typeof numOrC !== "Object") { >typeof numOrC !== "Object" : boolean >typeof numOrC : string ->numOrC : number | C +>numOrC : C | number >"Object" : string var r3: number = numOrC; // number @@ -152,7 +151,7 @@ else { if (typeof boolOrC !== "Object") { >typeof boolOrC !== "Object" : boolean >typeof boolOrC : string ->boolOrC : boolean | C +>boolOrC : C | boolean >"Object" : string var r4: boolean = boolOrC; // boolean @@ -166,20 +165,19 @@ else { >boolOrC : C } -// Narrowing occurs only if target type is a subtype of variable type if (typeof strOrNumOrBool !== "Object") { >typeof strOrNumOrBool !== "Object" : boolean >typeof strOrNumOrBool : string >strOrNumOrBool : string | number | boolean >"Object" : string - var q1: string | number | boolean = strOrNumOrBool; // string | number | boolean + let q1: string | number | boolean = strOrNumOrBool; // string | number | boolean >q1 : string | number | boolean >strOrNumOrBool : string | number | boolean } else { - var q2: string | number | boolean = strOrNumOrBool; // string | number | boolean ->q2 : string | number | boolean ->strOrNumOrBool : string | number | boolean + let q2: {} = strOrNumOrBool; // {} +>q2 : {} +>strOrNumOrBool : {} } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfString.js b/tests/baselines/reference/typeGuardOfFormTypeOfString.js index 5626396f73d..d79f73a87c5 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfString.js +++ b/tests/baselines/reference/typeGuardOfFormTypeOfString.js @@ -42,12 +42,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, @@ -78,12 +77,11 @@ 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; // {} } @@ -133,9 +131,8 @@ if (typeof strOrC === "string") { else { c = strOrC; // C } -// Narrowing occurs only if target type is a subtype of variable type if (typeof numOrBool === "string") { - var x1 = numOrBool; // number | boolean + var x1 = numOrBool; // {} } else { var x2 = numOrBool; // number | boolean @@ -167,10 +164,9 @@ if (typeof strOrC !== "string") { else { str = strOrC; // string } -// Narrowing occurs only if target type is a subtype of variable type if (typeof numOrBool !== "string") { var x1 = numOrBool; // number | boolean } else { - var x2 = numOrBool; // number | boolean + var x2 = numOrBool; // {} } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfString.symbols b/tests/baselines/reference/typeGuardOfFormTypeOfString.symbols index d3209189f83..4a77ecb1ffb 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfString.symbols +++ b/tests/baselines/reference/typeGuardOfFormTypeOfString.symbols @@ -93,17 +93,16 @@ else { >strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfString.ts, 9, 3)) } -// Narrowing occurs only if target type is a subtype of variable type if (typeof numOrBool === "string") { >numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfString.ts, 7, 3)) - var x1: number | boolean = numOrBool; // number | boolean ->x1 : Symbol(x1, Decl(typeGuardOfFormTypeOfString.ts, 45, 7), Decl(typeGuardOfFormTypeOfString.ts, 81, 7)) + let x1: {} = numOrBool; // {} +>x1 : Symbol(x1, Decl(typeGuardOfFormTypeOfString.ts, 44, 7)) >numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfString.ts, 7, 3)) } else { - var x2: number | boolean = numOrBool; // number | boolean ->x2 : Symbol(x2, Decl(typeGuardOfFormTypeOfString.ts, 48, 7), Decl(typeGuardOfFormTypeOfString.ts, 84, 7)) + let x2: number | boolean = numOrBool; // number | boolean +>x2 : Symbol(x2, Decl(typeGuardOfFormTypeOfString.ts, 47, 7)) >numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfString.ts, 7, 3)) } @@ -159,17 +158,16 @@ else { >strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfString.ts, 9, 3)) } -// Narrowing occurs only if target type is a subtype of variable type if (typeof numOrBool !== "string") { >numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfString.ts, 7, 3)) - var x1: number | boolean = numOrBool; // number | boolean ->x1 : Symbol(x1, Decl(typeGuardOfFormTypeOfString.ts, 45, 7), Decl(typeGuardOfFormTypeOfString.ts, 81, 7)) + let x1: number | boolean = numOrBool; // number | boolean +>x1 : Symbol(x1, Decl(typeGuardOfFormTypeOfString.ts, 79, 7)) >numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfString.ts, 7, 3)) } else { - var x2: number | boolean = numOrBool; // number | boolean ->x2 : Symbol(x2, Decl(typeGuardOfFormTypeOfString.ts, 48, 7), Decl(typeGuardOfFormTypeOfString.ts, 84, 7)) + let x2: {} = numOrBool; // {} +>x2 : Symbol(x2, Decl(typeGuardOfFormTypeOfString.ts, 82, 7)) >numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfString.ts, 7, 3)) } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfString.types b/tests/baselines/reference/typeGuardOfFormTypeOfString.types index d6a382261ac..c77f9f3207a 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfString.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfString.types @@ -113,19 +113,18 @@ else { >strOrC : C } -// Narrowing occurs only if target type is a subtype of variable type if (typeof numOrBool === "string") { >typeof numOrBool === "string" : boolean >typeof numOrBool : string >numOrBool : number | boolean >"string" : string - var x1: number | boolean = numOrBool; // number | boolean ->x1 : number | boolean ->numOrBool : number | boolean + let x1: {} = numOrBool; // {} +>x1 : {} +>numOrBool : {} } else { - var x2: number | boolean = numOrBool; // number | boolean + let x2: number | boolean = numOrBool; // number | boolean >x2 : number | boolean >numOrBool : number | boolean } @@ -202,20 +201,19 @@ else { >strOrC : string } -// Narrowing occurs only if target type is a subtype of variable type if (typeof numOrBool !== "string") { >typeof numOrBool !== "string" : boolean >typeof numOrBool : string >numOrBool : number | boolean >"string" : string - var x1: number | boolean = numOrBool; // number | boolean + let x1: number | boolean = numOrBool; // number | boolean >x1 : number | boolean >numOrBool : number | boolean } else { - var x2: number | boolean = numOrBool; // number | boolean ->x2 : number | boolean ->numOrBool : number | boolean + let x2: {} = numOrBool; // {} +>x2 : {} +>numOrBool : {} } diff --git a/tests/baselines/reference/typeGuardTautologicalConsistiency.types b/tests/baselines/reference/typeGuardTautologicalConsistiency.types index d758dcde22b..100e528f616 100644 --- a/tests/baselines/reference/typeGuardTautologicalConsistiency.types +++ b/tests/baselines/reference/typeGuardTautologicalConsistiency.types @@ -15,7 +15,7 @@ if (typeof stringOrNumber === "number") { >"number" : string stringOrNumber; ->stringOrNumber : string | number +>stringOrNumber : {} } } @@ -23,7 +23,7 @@ if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { >typeof stringOrNumber === "number" && typeof stringOrNumber !== "number" : boolean >typeof stringOrNumber === "number" : boolean >typeof stringOrNumber : string ->stringOrNumber : string | number +>stringOrNumber : number | string >"number" : string >typeof stringOrNumber !== "number" : boolean >typeof stringOrNumber : string @@ -31,6 +31,6 @@ if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { >"number" : string stringOrNumber; ->stringOrNumber : string | number +>stringOrNumber : {} } diff --git a/tests/baselines/reference/typeGuardTypeOfUndefined.types b/tests/baselines/reference/typeGuardTypeOfUndefined.types index 6cf57e1a1dd..7073d9aeacb 100644 --- a/tests/baselines/reference/typeGuardTypeOfUndefined.types +++ b/tests/baselines/reference/typeGuardTypeOfUndefined.types @@ -26,7 +26,7 @@ function test1(a: any) { } else { a; ->a : any +>a : undefined } } @@ -43,15 +43,15 @@ function test2(a: any) { if (typeof a === "boolean") { >typeof a === "boolean" : boolean >typeof a : string ->a : any +>a : undefined >"boolean" : string a; ->a : boolean +>a : {} } else { a; ->a : any +>a : undefined } } else { @@ -76,7 +76,7 @@ function test3(a: any) { >"boolean" : string a; ->a : any +>a : boolean } else { a; @@ -121,7 +121,7 @@ function test5(a: boolean | void) { if (typeof a === "boolean") { >typeof a === "boolean" : boolean >typeof a : string ->a : boolean | void +>a : boolean >"boolean" : string a; @@ -129,7 +129,7 @@ function test5(a: boolean | void) { } else { a; ->a : void +>a : {} } } else { @@ -164,7 +164,7 @@ function test6(a: boolean | void) { } else { a; ->a : boolean | void +>a : boolean } } @@ -180,7 +180,7 @@ function test7(a: boolean | void) { >"undefined" : string >typeof a === "boolean" : boolean >typeof a : string ->a : boolean | void +>a : boolean >"boolean" : string a; @@ -188,7 +188,7 @@ function test7(a: boolean | void) { } else { a; ->a : void +>a : {} } } @@ -204,7 +204,7 @@ function test8(a: boolean | void) { >"undefined" : string >typeof a === "boolean" : boolean >typeof a : string ->a : boolean | void +>a : boolean >"boolean" : string a; @@ -337,7 +337,7 @@ function test13(a: boolean | number | void) { if (typeof a === "boolean") { >typeof a === "boolean" : boolean >typeof a : string ->a : boolean | number | void +>a : boolean | number >"boolean" : string a; @@ -345,7 +345,7 @@ function test13(a: boolean | number | void) { } else { a; ->a : number | void +>a : number } } else { @@ -380,7 +380,7 @@ function test14(a: boolean | number | void) { } else { a; ->a : boolean | number | void +>a : boolean | number } } @@ -396,7 +396,7 @@ function test15(a: boolean | number | void) { >"undefined" : string >typeof a === "boolean" : boolean >typeof a : string ->a : boolean | number | void +>a : boolean | number >"boolean" : string a; @@ -404,7 +404,7 @@ function test15(a: boolean | number | void) { } else { a; ->a : number | void +>a : number } } @@ -420,7 +420,7 @@ function test16(a: boolean | number | void) { >"undefined" : string >typeof a === "boolean" : boolean >typeof a : string ->a : boolean | number | void +>a : boolean | number >"boolean" : string a;