diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4423b574e31bc..931fec458b4b3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -326,7 +326,6 @@ namespace ts { "object": TypeFacts.TypeofEQObject, "function": TypeFacts.TypeofEQFunction }); - const typeofNEFacts = createMapFromTemplate({ "string": TypeFacts.TypeofNEString, "number": TypeFacts.TypeofNENumber, @@ -336,7 +335,6 @@ namespace ts { "object": TypeFacts.TypeofNEObject, "function": TypeFacts.TypeofNEFunction }); - const typeofTypesByName = createMapFromTemplate({ "string": stringType, "number": numberType, @@ -344,6 +342,7 @@ namespace ts { "symbol": esSymbolType, "undefined": undefinedType }); + const typeofType = createTypeofType(); let jsxElementType: Type; let _jsxNamespace: string; @@ -1727,6 +1726,10 @@ namespace ts { return type; } + function createTypeofType() { + return getUnionType(convertToArray(typeofEQFacts.keys(), s => getLiteralTypeForText(TypeFlags.StringLiteral, s))); + } + // A reserved member name starts with two underscores, but the third character cannot be an underscore // or the @ symbol. A third underscore indicates an escaped form of an identifer that started // with at least two underscores. The @ character indicates that the name is denoted by a well known ES @@ -14626,7 +14629,7 @@ namespace ts { function checkTypeOfExpression(node: TypeOfExpression): Type { checkExpression(node.expression); - return stringType; + return typeofType; } function checkVoidExpression(node: VoidExpression): Type { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 304fba69b2677..94e32dfdbb31e 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -895,6 +895,14 @@ namespace ts { return result; } + export function convertToArray(iterator: Iterator, f: (value: T) => U) { + const result: U[] = []; + for (let { value, done } = iterator.next(); !done; { value, done } = iterator.next()) { + result.push(f(value)); + } + return result; + } + /** * Calls `callback` for each entry in the map, returning the first truthy result. * Use `map.forEach` instead for normal iteration. diff --git a/tests/baselines/reference/TypeGuardWithEnumUnion.types b/tests/baselines/reference/TypeGuardWithEnumUnion.types index d33411c4c7c1a..8ee4aaca363c6 100644 --- a/tests/baselines/reference/TypeGuardWithEnumUnion.types +++ b/tests/baselines/reference/TypeGuardWithEnumUnion.types @@ -12,7 +12,7 @@ function f1(x: Color | string) { if (typeof x === "number") { >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Color >"number" : "number" @@ -41,7 +41,7 @@ function f2(x: Color | string | string[]) { if (typeof x === "object") { >typeof x === "object" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Color | string[] >"object" : "object" @@ -54,7 +54,7 @@ function f2(x: Color | string | string[]) { } if (typeof x === "number") { >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Color | string[] >"number" : "number" @@ -76,7 +76,7 @@ function f2(x: Color | string | string[]) { } if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Color | string[] >"string" : "string" diff --git a/tests/baselines/reference/anonymousClassExpression1.types b/tests/baselines/reference/anonymousClassExpression1.types index 0fbffffdf4b82..3bc019604925c 100644 --- a/tests/baselines/reference/anonymousClassExpression1.types +++ b/tests/baselines/reference/anonymousClassExpression1.types @@ -4,7 +4,7 @@ function f() { return typeof class {} === "function"; >typeof class {} === "function" : boolean ->typeof class {} : string +>typeof class {} : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >class {} : typeof (Anonymous class) >"function" : "function" } diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types index 0b515750aecc6..658eff38bbb8a 100644 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types @@ -103,17 +103,17 @@ var r6 = foo6(1); >1 : 1 function foo7(x) { ->foo7 : (x: any) => string +>foo7 : (x: any) => "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : any return typeof x; ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : any } var r7 = foo7(1); ->r7 : string ->foo7(1) : string ->foo7 : (x: any) => string +>r7 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>foo7(1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>foo7 : (x: any) => "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >1 : 1 // object types diff --git a/tests/baselines/reference/castExpressionParentheses.types b/tests/baselines/reference/castExpressionParentheses.types index dafe3377aea94..aa633825eec99 100644 --- a/tests/baselines/reference/castExpressionParentheses.types +++ b/tests/baselines/reference/castExpressionParentheses.types @@ -182,7 +182,7 @@ declare var A; >(typeof A).x : any >(typeof A) : any >typeof A : any ->typeof A : string +>typeof A : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >A : any >x : any diff --git a/tests/baselines/reference/castOfAwait.types b/tests/baselines/reference/castOfAwait.types index 30220ca2ab6fe..805affe49db4b 100644 --- a/tests/baselines/reference/castOfAwait.types +++ b/tests/baselines/reference/castOfAwait.types @@ -8,7 +8,7 @@ async function f() { >0 : 0 typeof await 0; ->typeof await 0 : string +>typeof await 0 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >await 0 : 0 >0 : 0 @@ -21,7 +21,7 @@ async function f() { >await void typeof void await 0 : any >void typeof void await 0 : undefined > typeof void await 0 : string ->typeof void await 0 : string +>typeof void await 0 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" > void await 0 : number >void await 0 : undefined >await 0 : 0 diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types index 5ac20c6e0fadb..54b67dfd6a7e7 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types @@ -5,7 +5,7 @@ var x: StringTree; if (typeof x !== "string") { >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : StringTree >"string" : "string" diff --git a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types index f19769b1c5864..610b80ef61283 100644 --- a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types +++ b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types @@ -120,7 +120,7 @@ true ? exprString1 : exprBoolean1; // union typeof "123" == "string" ? exprBoolean1 : exprBoolean2; >typeof "123" == "string" ? exprBoolean1 : exprBoolean2 : boolean >typeof "123" == "string" : boolean ->typeof "123" : string +>typeof "123" : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >"123" : "123" >"string" : "string" >exprBoolean1 : boolean @@ -262,7 +262,7 @@ var resultIsBoolean3 = typeof "123" == "string" ? exprBoolean1 : exprBoolean2; >resultIsBoolean3 : boolean >typeof "123" == "string" ? exprBoolean1 : exprBoolean2 : boolean >typeof "123" == "string" : boolean ->typeof "123" : string +>typeof "123" : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >"123" : "123" >"string" : "string" >exprBoolean1 : boolean @@ -299,7 +299,7 @@ var resultIsStringOrBoolean4 = typeof "123" === "string" ? exprString1 : exprBoo >resultIsStringOrBoolean4 : string | boolean >typeof "123" === "string" ? exprString1 : exprBoolean1 : string | boolean >typeof "123" === "string" : boolean ->typeof "123" : string +>typeof "123" : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >"123" : "123" >"string" : "string" >exprString1 : string diff --git a/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types b/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types index a6906d7024a80..33e34bea635c3 100644 --- a/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types +++ b/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types @@ -123,7 +123,7 @@ var array = ["1", "2", "3"]; typeof condString ? exprAny1 : exprAny2; >typeof condString ? exprAny1 : exprAny2 : any ->typeof condString : string +>typeof condString : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >condString : string >exprAny1 : any >exprAny2 : any @@ -254,7 +254,7 @@ var resultIsStringOrBoolean2 = "hello" ? exprString1 : exprBoolean1; // union var resultIsAny3 = typeof condString ? exprAny1 : exprAny2; >resultIsAny3 : any >typeof condString ? exprAny1 : exprAny2 : any ->typeof condString : string +>typeof condString : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >condString : string >exprAny1 : any >exprAny2 : any @@ -297,7 +297,7 @@ var resultIsObject3 = array[1] ? exprIsObject1 : exprIsObject2; var resultIsStringOrBoolean3 = typeof condString ? exprString1 : exprBoolean1; // union >resultIsStringOrBoolean3 : string | boolean >typeof condString ? exprString1 : exprBoolean1 : string | boolean ->typeof condString : string +>typeof condString : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >condString : string >exprString1 : string >exprBoolean1 : boolean diff --git a/tests/baselines/reference/constLocalsInFunctionExpressions.types b/tests/baselines/reference/constLocalsInFunctionExpressions.types index db1da04e0ca1e..07d3392045cad 100644 --- a/tests/baselines/reference/constLocalsInFunctionExpressions.types +++ b/tests/baselines/reference/constLocalsInFunctionExpressions.types @@ -12,7 +12,7 @@ function f1() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -35,7 +35,7 @@ function f2() { if (typeof x !== "string") { >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -59,7 +59,7 @@ function f3() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -82,7 +82,7 @@ function f4() { if (typeof x !== "string") { >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -106,7 +106,7 @@ function f5() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" diff --git a/tests/baselines/reference/controlFlowCommaOperator.types b/tests/baselines/reference/controlFlowCommaOperator.types index 52fd3d7b87d62..d4e073295d79f 100644 --- a/tests/baselines/reference/controlFlowCommaOperator.types +++ b/tests/baselines/reference/controlFlowCommaOperator.types @@ -17,7 +17,7 @@ function f(x: string | number | boolean) { >y : string | number | boolean >"" : "" >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -36,7 +36,7 @@ function f(x: string | number | boolean) { >z : string | number | boolean >1 : 1 >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" diff --git a/tests/baselines/reference/controlFlowDoWhileStatement.types b/tests/baselines/reference/controlFlowDoWhileStatement.types index 24f3e92b144d3..baa585bc14d5e 100644 --- a/tests/baselines/reference/controlFlowDoWhileStatement.types +++ b/tests/baselines/reference/controlFlowDoWhileStatement.types @@ -66,7 +66,7 @@ function c() { if (typeof x === "string") continue; >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" diff --git a/tests/baselines/reference/controlFlowForStatement.types b/tests/baselines/reference/controlFlowForStatement.types index d227e87ea1d53..f82a018573bcc 100644 --- a/tests/baselines/reference/controlFlowForStatement.types +++ b/tests/baselines/reference/controlFlowForStatement.types @@ -82,7 +82,7 @@ function d() { >x : string | number | boolean >"" : "" >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >x = 5 : 5 @@ -107,7 +107,7 @@ function e() { >"" : "" >0 : 0 >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | true >"string" : "string" >x = "" || true : true @@ -128,7 +128,7 @@ function f() { for (; typeof x !== "string";) { >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -137,7 +137,7 @@ function f() { if (typeof x === "number") break; >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" diff --git a/tests/baselines/reference/controlFlowIIFE.types b/tests/baselines/reference/controlFlowIIFE.types index 7cf4337b53bd0..1c2e82903941f 100644 --- a/tests/baselines/reference/controlFlowIIFE.types +++ b/tests/baselines/reference/controlFlowIIFE.types @@ -13,7 +13,7 @@ function f1() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -41,7 +41,7 @@ function f2() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -73,7 +73,7 @@ function f3() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" diff --git a/tests/baselines/reference/controlFlowIfStatement.types b/tests/baselines/reference/controlFlowIfStatement.types index fd8f25b9ee331..e0ce68db7b15e 100644 --- a/tests/baselines/reference/controlFlowIfStatement.types +++ b/tests/baselines/reference/controlFlowIfStatement.types @@ -100,7 +100,7 @@ function c(data: string | T): T { if (typeof data === 'string') { >typeof data === 'string' : boolean ->typeof data : string +>typeof data : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >data : string | T >'string' : "string" @@ -124,7 +124,7 @@ function d(data: string | T): never { if (typeof data === 'string') { >typeof data === 'string' : boolean ->typeof data : string +>typeof data : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >data : string | T >'string' : "string" diff --git a/tests/baselines/reference/controlFlowWhileStatement.types b/tests/baselines/reference/controlFlowWhileStatement.types index 19f7fc49d02fc..4576e1a4f62a3 100644 --- a/tests/baselines/reference/controlFlowWhileStatement.types +++ b/tests/baselines/reference/controlFlowWhileStatement.types @@ -69,7 +69,7 @@ function c() { if (typeof x === "string") continue; >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" diff --git a/tests/baselines/reference/controlFlowWithIncompleteTypes.types b/tests/baselines/reference/controlFlowWithIncompleteTypes.types index 784f22a3966f0..f5e8f2bcf2403 100644 --- a/tests/baselines/reference/controlFlowWithIncompleteTypes.types +++ b/tests/baselines/reference/controlFlowWithIncompleteTypes.types @@ -16,7 +16,7 @@ function foo1() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -49,7 +49,7 @@ function foo2() { if (typeof x === "number") { >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"number" : "number" diff --git a/tests/baselines/reference/declarationEmitIdentifierPredicates01.types b/tests/baselines/reference/declarationEmitIdentifierPredicates01.types index 1129012a80a9c..1aeb3ea824d67 100644 --- a/tests/baselines/reference/declarationEmitIdentifierPredicates01.types +++ b/tests/baselines/reference/declarationEmitIdentifierPredicates01.types @@ -7,7 +7,7 @@ export function f(x: any): x is number { return typeof x === "number"; >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : any >"number" : "number" } diff --git a/tests/baselines/reference/discriminantsAndPrimitives.types b/tests/baselines/reference/discriminantsAndPrimitives.types index d3e1b70e59911..0870d17948fce 100644 --- a/tests/baselines/reference/discriminantsAndPrimitives.types +++ b/tests/baselines/reference/discriminantsAndPrimitives.types @@ -30,7 +30,7 @@ function f1(x: Foo | Bar | string) { if (typeof x !== 'string') { >typeof x !== 'string' : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Foo | Bar >'string' : "string" @@ -58,7 +58,7 @@ function f2(x: Foo | Bar | string | undefined) { if (typeof x === "object") { >typeof x === "object" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Foo | Bar | undefined >"object" : "object" @@ -89,7 +89,7 @@ function f3(x: Foo | Bar | string | null) { >x && typeof x !== "string" : boolean | "" | null >x : string | Foo | Bar | null >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | Foo | Bar >"string" : "string" @@ -120,7 +120,7 @@ function f4(x: Foo | Bar | string | number | null) { >x && typeof x === "object" : boolean | "" | 0 | null >x : string | number | Foo | Bar | null >typeof x === "object" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | Foo | Bar >"object" : "object" diff --git a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types index 7991ef224f0f0..d11846227f2e1 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types @@ -64,7 +64,7 @@ var s; `${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -162,14 +162,14 @@ var s; `${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}`; >`${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,7 +223,7 @@ var s; `hello ${typeof (t1 ** t2 ** t1)}`; >`hello ${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types index 981829dd42b9d..610c3a64a6ed2 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types @@ -64,7 +64,7 @@ var s; `${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -162,14 +162,14 @@ var s; `${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}`; >`${typeof (t1 ** t2 ** t1)} hello world ${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,7 +223,7 @@ var s; `hello ${typeof (t1 ** t2 ** t1)}`; >`hello ${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types index bbfb5b88e04c4..4f78cd61fcc20 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types @@ -54,7 +54,7 @@ var s; `${typeof (t1 ** t2 ** t1) }`; >`${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `${typeof (t1 ** t2 ** t1)}${typeof (t1 ** t2 ** t1)}`; >`${typeof (t1 ** t2 ** t1)}${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }`; >`${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types index a005dd074630c..0bc65c31b1255 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types @@ -54,7 +54,7 @@ var s; `${typeof (t1 ** t2 ** t1) }`; >`${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `${typeof (t1 ** t2 ** t1)}${typeof (t1 ** t2 ** t1)}`; >`${typeof (t1 ** t2 ** t1)}${typeof (t1 ** t2 ** t1)}` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }`; >`${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types index 156851b60b946..9b77f4bc3fccd 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types @@ -54,7 +54,7 @@ var s; `hello ${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`hello ${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `hello ${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `hello ${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types index dbeee05554eb0..ed0be973e5b80 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types @@ -54,7 +54,7 @@ var s; `hello ${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`hello ${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `hello ${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `hello ${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }`; >`hello ${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1) }` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types index d3472beac1254..16fe31dde5edc 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types @@ -54,7 +54,7 @@ var s; `${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`${1 + typeof (t1 ** t2 ** t1) } world` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1)} !!`; >`${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1)} !!` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types index 239ef02a52953..86eb42efc0593 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types @@ -54,7 +54,7 @@ var s; `${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -66,7 +66,7 @@ var s; >`${1 + typeof (t1 ** t2 ** t1) } world` : string >1 + typeof (t1 ** t2 ** t1) : string >1 : 1 ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -141,14 +141,14 @@ var s; `${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) } world`; >`${typeof (t1 ** t2 ** t1) }${typeof (t1 ** t2 ** t1) } world` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number @@ -223,14 +223,14 @@ var s; `${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1)} !!`; >`${typeof (t1 ** t2 ** t1) } hello world ${typeof (t1 ** t2 ** t1)} !!` : string ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number >t2 ** t1 : number >t2 : number >t1 : number ->typeof (t1 ** t2 ** t1) : string +>typeof (t1 ** t2 ** t1) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number >t1 : number diff --git a/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types b/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types index 4f60c5d36cc57..eae55bc09d1ed 100644 --- a/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types +++ b/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types @@ -5,7 +5,7 @@ var x: StringTree; if (typeof x !== "string") { >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : StringTree >"string" : "string" diff --git a/tests/baselines/reference/intersectionTypeNormalization.types b/tests/baselines/reference/intersectionTypeNormalization.types index 3ffe7484afecd..7d8ba117eec32 100644 --- a/tests/baselines/reference/intersectionTypeNormalization.types +++ b/tests/baselines/reference/intersectionTypeNormalization.types @@ -227,9 +227,9 @@ function getValueAsString(value: IntersectionFail): string { if (value.kind === 'int') { >value.kind === 'int' : boolean ->value.kind : "int" | "string" +>value.kind : "string" | "int" >value : IntersectionFail ->kind : "int" | "string" +>kind : "string" | "int" >'int' : "int" return '' + value.num; diff --git a/tests/baselines/reference/mappedTypes4.types b/tests/baselines/reference/mappedTypes4.types index a2fec06cceca8..1d0c4c16b8955 100644 --- a/tests/baselines/reference/mappedTypes4.types +++ b/tests/baselines/reference/mappedTypes4.types @@ -29,7 +29,7 @@ function boxify(obj: T): Boxified { if (typeof obj === "object") { >typeof obj === "object" : boolean ->typeof obj : string +>typeof obj : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >obj : T >"object" : "object" diff --git a/tests/baselines/reference/modularizeLibrary_Dom.iterable.types b/tests/baselines/reference/modularizeLibrary_Dom.iterable.types index b375800891808..f9a58d554cf9b 100644 --- a/tests/baselines/reference/modularizeLibrary_Dom.iterable.types +++ b/tests/baselines/reference/modularizeLibrary_Dom.iterable.types @@ -3,9 +3,9 @@ for (const element of document.getElementsByTagName("a")) { >element : HTMLAnchorElement >document.getElementsByTagName("a") : NodeListOf ->document.getElementsByTagName : { (tagname: K): ElementListTagNameMap[K]; (tagname: string): NodeListOf; } +>document.getElementsByTagName : { (tagname: K): ElementListTagNameMap[K]; (tagname: string): NodeListOf; } >document : Document ->getElementsByTagName : { (tagname: K): ElementListTagNameMap[K]; (tagname: string): NodeListOf; } +>getElementsByTagName : { (tagname: K): ElementListTagNameMap[K]; (tagname: string): NodeListOf; } >"a" : "a" element.href; diff --git a/tests/baselines/reference/narrowingConstrainedTypeParameter.types b/tests/baselines/reference/narrowingConstrainedTypeParameter.types index 942b9f7055d8d..348716ab3c450 100644 --- a/tests/baselines/reference/narrowingConstrainedTypeParameter.types +++ b/tests/baselines/reference/narrowingConstrainedTypeParameter.types @@ -17,7 +17,7 @@ function isPet(pet: any): pet is Pet { return typeof pet.name === "string"; >typeof pet.name === "string" : boolean ->typeof pet.name : string +>typeof pet.name : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >pet.name : any >pet : any >name : any diff --git a/tests/baselines/reference/nestedLoopTypeGuards.types b/tests/baselines/reference/nestedLoopTypeGuards.types index 9d7b793badf96..e027932501259 100644 --- a/tests/baselines/reference/nestedLoopTypeGuards.types +++ b/tests/baselines/reference/nestedLoopTypeGuards.types @@ -9,7 +9,7 @@ function f1() { if (typeof a !== 'boolean') { >typeof a !== 'boolean' : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : string | number | boolean >'boolean' : "boolean" @@ -34,7 +34,7 @@ function f1() { if (typeof a === 'string') { >typeof a === 'string' : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : string | number >'string' : "string" @@ -66,7 +66,7 @@ function f2() { if (typeof a === 'string') { >typeof a === 'string' : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : string | number >'string' : "string" @@ -78,7 +78,7 @@ function f2() { if (typeof a === 'string') { >typeof a === 'string' : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : string >'string' : "string" diff --git a/tests/baselines/reference/neverType.types b/tests/baselines/reference/neverType.types index bdb1ff56c3e4e..9555285e4be8c 100644 --- a/tests/baselines/reference/neverType.types +++ b/tests/baselines/reference/neverType.types @@ -164,7 +164,7 @@ function f1(x: string | number) { if (typeof x === "boolean") { >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"boolean" : "boolean" @@ -182,7 +182,7 @@ function f2(x: string | number) { if (typeof x === "boolean") { >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"boolean" : "boolean" diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types index ee5c336ba9ce7..a4de1666d0bb5 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types @@ -32,7 +32,7 @@ module Bugs { return typeof args[index] !== 'undefined' >typeof args[index] !== 'undefined' ? args[index] : match : any >typeof args[index] !== 'undefined' : boolean ->typeof args[index] : string +>typeof args[index] : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >args[index] : any >args : any[] >index : any diff --git a/tests/baselines/reference/overloadReturnTypes.types b/tests/baselines/reference/overloadReturnTypes.types index c0f573fb98074..daf790b9a9234 100644 --- a/tests/baselines/reference/overloadReturnTypes.types +++ b/tests/baselines/reference/overloadReturnTypes.types @@ -26,7 +26,7 @@ function attr(nameOrMap: any, value?: string): any { >nameOrMap && typeof nameOrMap === "object" : boolean >nameOrMap : any >typeof nameOrMap === "object" : boolean ->typeof nameOrMap : string +>typeof nameOrMap : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >nameOrMap : any >"object" : "object" diff --git a/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types index 4e4dbe93372f3..41df41af51bf8 100644 --- a/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types +++ b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types @@ -39,7 +39,7 @@ if (void x) { } if (typeof x) { ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : false } diff --git a/tests/baselines/reference/symbolType17.types b/tests/baselines/reference/symbolType17.types index c186f915cd0ac..6ba36d335a7ee 100644 --- a/tests/baselines/reference/symbolType17.types +++ b/tests/baselines/reference/symbolType17.types @@ -12,7 +12,7 @@ x; if (typeof x === "symbol") { >typeof x === "symbol" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : symbol | Foo >"symbol" : "symbol" diff --git a/tests/baselines/reference/symbolType18.types b/tests/baselines/reference/symbolType18.types index 8f0012f4f118b..9c58320ed3bb1 100644 --- a/tests/baselines/reference/symbolType18.types +++ b/tests/baselines/reference/symbolType18.types @@ -12,7 +12,7 @@ x; if (typeof x === "object") { >typeof x === "object" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : symbol | Foo >"object" : "object" diff --git a/tests/baselines/reference/symbolType19.types b/tests/baselines/reference/symbolType19.types index 18daa27fd00d7..66bd80b33d8a6 100644 --- a/tests/baselines/reference/symbolType19.types +++ b/tests/baselines/reference/symbolType19.types @@ -11,7 +11,7 @@ x; if (typeof x === "number") { >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : symbol | E >"number" : "number" diff --git a/tests/baselines/reference/templateStringInTypeOf.types b/tests/baselines/reference/templateStringInTypeOf.types index 0d7d26a82b29a..5de62164a703c 100644 --- a/tests/baselines/reference/templateStringInTypeOf.types +++ b/tests/baselines/reference/templateStringInTypeOf.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/templates/templateStringInTypeOf.ts === var x = typeof `abc${ 123 }def`; ->x : string ->typeof `abc${ 123 }def` : string +>x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof `abc${ 123 }def` : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >`abc${ 123 }def` : string >123 : 123 diff --git a/tests/baselines/reference/templateStringInTypeOfES6.types b/tests/baselines/reference/templateStringInTypeOfES6.types index ad142d13fe5f8..cc035a2550175 100644 --- a/tests/baselines/reference/templateStringInTypeOfES6.types +++ b/tests/baselines/reference/templateStringInTypeOfES6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/templates/templateStringInTypeOfES6.ts === var x = typeof `abc${ 123 }def`; ->x : string ->typeof `abc${ 123 }def` : string +>x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>typeof `abc${ 123 }def` : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >`abc${ 123 }def` : string >123 : 123 diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types index 48330140ad347..a7811bd03bdf5 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types @@ -2,6 +2,6 @@ var x = `abc${ typeof "hi" }def`; >x : string >`abc${ typeof "hi" }def` : string ->typeof "hi" : string +>typeof "hi" : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >"hi" : "hi" diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types index 3d7eba45c1912..27e593bf4b398 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types @@ -2,6 +2,6 @@ var x = `abc${ typeof "hi" }def`; >x : string >`abc${ typeof "hi" }def` : string ->typeof "hi" : string +>typeof "hi" : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >"hi" : "hi" diff --git a/tests/baselines/reference/throwStatements.types b/tests/baselines/reference/throwStatements.types index 19b8988ed47e4..3c8fd64ee3978 100644 --- a/tests/baselines/reference/throwStatements.types +++ b/tests/baselines/reference/throwStatements.types @@ -174,7 +174,7 @@ throw aModule; >aModule : typeof M throw typeof M; ->typeof M : string +>typeof M : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >M : typeof M var aClassInModule = new M.A(); diff --git a/tests/baselines/reference/typeGuardEnums.types b/tests/baselines/reference/typeGuardEnums.types index f9d5cb1754e8a..cf62bccebd32e 100644 --- a/tests/baselines/reference/typeGuardEnums.types +++ b/tests/baselines/reference/typeGuardEnums.types @@ -12,7 +12,7 @@ let x: number|string|E|V; if (typeof x === "number") { >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | E | V >"number" : "number" @@ -26,7 +26,7 @@ else { if (typeof x !== "number") { >typeof x !== "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | E | V >"number" : "number" diff --git a/tests/baselines/reference/typeGuardIntersectionTypes.types b/tests/baselines/reference/typeGuardIntersectionTypes.types index 6b6dbae8ca27e..b6206ed200765 100644 --- a/tests/baselines/reference/typeGuardIntersectionTypes.types +++ b/tests/baselines/reference/typeGuardIntersectionTypes.types @@ -163,7 +163,7 @@ function hasLegs(x: Beast): x is Legged { return x && typeof x.legs === 'number' >x && typeof x.legs === 'number' : boolean >x : Beast >typeof x.legs === 'number' : boolean ->typeof x.legs : string +>typeof x.legs : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x.legs : number | undefined >x : Beast >legs : number | undefined diff --git a/tests/baselines/reference/typeGuardNesting.types b/tests/baselines/reference/typeGuardNesting.types index 29f6cba10db59..c1396130c053a 100644 --- a/tests/baselines/reference/typeGuardNesting.types +++ b/tests/baselines/reference/typeGuardNesting.types @@ -7,13 +7,13 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >(typeof strOrBool === 'boolean' && !strOrBool) : boolean >typeof strOrBool === 'boolean' && !strOrBool : boolean >typeof strOrBool === 'boolean' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >'boolean' : "boolean" >!strOrBool : boolean >strOrBool : boolean >typeof strOrBool === 'string' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | true >'string' : "string" @@ -22,7 +22,7 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >(typeof strOrBool === 'string') ? strOrBool : "string" : string >(typeof strOrBool === 'string') : boolean >typeof strOrBool === 'string' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >'string' : "string" >strOrBool : string @@ -33,7 +33,7 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >(typeof strOrBool === 'boolean') ? strOrBool : false : boolean >(typeof strOrBool === 'boolean') : boolean >typeof strOrBool === 'boolean' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >'boolean' : "boolean" >strOrBool : boolean @@ -44,7 +44,7 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >(typeof strOrBool !== 'boolean') ? strOrBool : "string" : string >(typeof strOrBool !== 'boolean') : boolean >typeof strOrBool !== 'boolean' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >'boolean' : "boolean" >strOrBool : string @@ -55,7 +55,7 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >(typeof strOrBool !== 'string') ? strOrBool : false : boolean >(typeof strOrBool !== 'string') : boolean >typeof strOrBool !== 'string' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >'string' : "string" >strOrBool : boolean @@ -67,13 +67,13 @@ if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boole >(typeof strOrBool !== 'string' && !strOrBool) : boolean >typeof strOrBool !== 'string' && !strOrBool : boolean >typeof strOrBool !== 'string' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >'string' : "string" >!strOrBool : boolean >strOrBool : boolean >typeof strOrBool !== 'boolean' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | true >'boolean' : "boolean" @@ -82,7 +82,7 @@ if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boole >(typeof strOrBool === 'string') ? strOrBool : "string" : string >(typeof strOrBool === 'string') : boolean >typeof strOrBool === 'string' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >'string' : "string" >strOrBool : string @@ -93,7 +93,7 @@ if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boole >(typeof strOrBool === 'boolean') ? strOrBool : false : boolean >(typeof strOrBool === 'boolean') : boolean >typeof strOrBool === 'boolean' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >'boolean' : "boolean" >strOrBool : boolean @@ -104,7 +104,7 @@ if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boole >(typeof strOrBool !== 'boolean') ? strOrBool : "string" : string >(typeof strOrBool !== 'boolean') : boolean >typeof strOrBool !== 'boolean' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >'boolean' : "boolean" >strOrBool : string @@ -115,7 +115,7 @@ if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boole >(typeof strOrBool !== 'string') ? strOrBool : false : boolean >(typeof strOrBool !== 'string') : boolean >typeof strOrBool !== 'string' : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >'string' : "string" >strOrBool : boolean diff --git a/tests/baselines/reference/typeGuardOfFormExpr1AndExpr2.types b/tests/baselines/reference/typeGuardOfFormExpr1AndExpr2.types index b24b63f61dc44..78d419d7dcdae 100644 --- a/tests/baselines/reference/typeGuardOfFormExpr1AndExpr2.types +++ b/tests/baselines/reference/typeGuardOfFormExpr1AndExpr2.types @@ -42,11 +42,11 @@ var strOrNumOrBoolOrC: string | number | boolean | C; if (typeof strOrNumOrBool !== "string" && typeof strOrNumOrBool !== "number") { >typeof strOrNumOrBool !== "string" && typeof strOrNumOrBool !== "number" : boolean >typeof strOrNumOrBool !== "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" >typeof strOrNumOrBool !== "number" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : number | boolean >"number" : "number" @@ -66,15 +66,15 @@ if (typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "numbe >typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" && typeof strOrNumOrBoolOrC !== "boolean" : boolean >typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" : boolean >typeof strOrNumOrBoolOrC !== "string" : boolean ->typeof strOrNumOrBoolOrC : string +>typeof strOrNumOrBoolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBoolOrC : string | number | boolean | C >"string" : "string" >typeof strOrNumOrBoolOrC !== "number" : boolean ->typeof strOrNumOrBoolOrC : string +>typeof strOrNumOrBoolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBoolOrC : number | boolean | C >"number" : "number" >typeof strOrNumOrBoolOrC !== "boolean" : boolean ->typeof strOrNumOrBoolOrC : string +>typeof strOrNumOrBoolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBoolOrC : boolean | C >"boolean" : "boolean" @@ -94,15 +94,15 @@ if (typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "numbe >typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" && typeof strOrNumOrBool === "boolean" : boolean >typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" : boolean >typeof strOrNumOrBoolOrC !== "string" : boolean ->typeof strOrNumOrBoolOrC : string +>typeof strOrNumOrBoolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBoolOrC : string | number | boolean | C >"string" : "string" >typeof strOrNumOrBoolOrC !== "number" : boolean ->typeof strOrNumOrBoolOrC : string +>typeof strOrNumOrBoolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBoolOrC : number | boolean | C >"number" : "number" >typeof strOrNumOrBool === "boolean" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"boolean" : "boolean" @@ -130,7 +130,7 @@ else { if (typeof strOrNumOrBool !== "string" && numOrBool !== strOrNumOrBool) { >typeof strOrNumOrBool !== "string" && numOrBool !== strOrNumOrBool : boolean >typeof strOrNumOrBool !== "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" >numOrBool !== strOrNumOrBool : boolean diff --git a/tests/baselines/reference/typeGuardOfFormExpr1OrExpr2.types b/tests/baselines/reference/typeGuardOfFormExpr1OrExpr2.types index eb428bcb6795d..e2a06a817af21 100644 --- a/tests/baselines/reference/typeGuardOfFormExpr1OrExpr2.types +++ b/tests/baselines/reference/typeGuardOfFormExpr1OrExpr2.types @@ -42,11 +42,11 @@ var strOrNumOrBoolOrC: string | number | boolean | C; if (typeof strOrNumOrBool === "string" || typeof strOrNumOrBool === "number") { >typeof strOrNumOrBool === "string" || typeof strOrNumOrBool === "number" : boolean >typeof strOrNumOrBool === "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" >typeof strOrNumOrBool === "number" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : number | boolean >"number" : "number" @@ -66,15 +66,15 @@ if (typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "numbe >typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" || typeof strOrNumOrBoolOrC === "boolean" : boolean >typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" : boolean >typeof strOrNumOrBoolOrC === "string" : boolean ->typeof strOrNumOrBoolOrC : string +>typeof strOrNumOrBoolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBoolOrC : string | number | boolean | C >"string" : "string" >typeof strOrNumOrBoolOrC === "number" : boolean ->typeof strOrNumOrBoolOrC : string +>typeof strOrNumOrBoolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBoolOrC : number | boolean | C >"number" : "number" >typeof strOrNumOrBoolOrC === "boolean" : boolean ->typeof strOrNumOrBoolOrC : string +>typeof strOrNumOrBoolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBoolOrC : boolean | C >"boolean" : "boolean" @@ -94,15 +94,15 @@ if (typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "numbe >typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" || typeof strOrNumOrBool !== "boolean" : boolean >typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" : boolean >typeof strOrNumOrBoolOrC === "string" : boolean ->typeof strOrNumOrBoolOrC : string +>typeof strOrNumOrBoolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBoolOrC : string | number | boolean | C >"string" : "string" >typeof strOrNumOrBoolOrC === "number" : boolean ->typeof strOrNumOrBoolOrC : string +>typeof strOrNumOrBoolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBoolOrC : number | boolean | C >"number" : "number" >typeof strOrNumOrBool !== "boolean" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"boolean" : "boolean" @@ -130,7 +130,7 @@ else { if (typeof strOrNumOrBool === "string" || numOrBool !== strOrNumOrBool) { >typeof strOrNumOrBool === "string" || numOrBool !== strOrNumOrBool : boolean >typeof strOrNumOrBool === "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" >numOrBool !== strOrNumOrBool : boolean diff --git a/tests/baselines/reference/typeGuardOfFormNotExpr.types b/tests/baselines/reference/typeGuardOfFormNotExpr.types index e4490d42dae3c..624bd7c71fced 100644 --- a/tests/baselines/reference/typeGuardOfFormNotExpr.types +++ b/tests/baselines/reference/typeGuardOfFormNotExpr.types @@ -26,7 +26,7 @@ if (!(typeof strOrNum === "string")) { >!(typeof strOrNum === "string") : boolean >(typeof strOrNum === "string") : boolean >typeof strOrNum === "string" : boolean ->typeof strOrNum : string +>typeof strOrNum : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNum : string | number >"string" : "string" @@ -47,11 +47,11 @@ if (!(typeof strOrNumOrBool === "string" || typeof strOrNumOrBool === "number")) >(typeof strOrNumOrBool === "string" || typeof strOrNumOrBool === "number") : boolean >typeof strOrNumOrBool === "string" || typeof strOrNumOrBool === "number" : boolean >typeof strOrNumOrBool === "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" >typeof strOrNumOrBool === "number" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : number | boolean >"number" : "number" @@ -72,13 +72,13 @@ if (!(typeof strOrNumOrBool !== "string") || !(typeof strOrNumOrBool !== "number >!(typeof strOrNumOrBool !== "string") : boolean >(typeof strOrNumOrBool !== "string") : boolean >typeof strOrNumOrBool !== "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" >!(typeof strOrNumOrBool !== "number") : boolean >(typeof strOrNumOrBool !== "number") : boolean >typeof strOrNumOrBool !== "number" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : number | boolean >"number" : "number" @@ -99,11 +99,11 @@ if (!(typeof strOrNumOrBool !== "string" && typeof strOrNumOrBool !== "number")) >(typeof strOrNumOrBool !== "string" && typeof strOrNumOrBool !== "number") : boolean >typeof strOrNumOrBool !== "string" && typeof strOrNumOrBool !== "number" : boolean >typeof strOrNumOrBool !== "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" >typeof strOrNumOrBool !== "number" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : number | boolean >"number" : "number" @@ -124,13 +124,13 @@ if (!(typeof strOrNumOrBool === "string") && !(typeof strOrNumOrBool === "number >!(typeof strOrNumOrBool === "string") : boolean >(typeof strOrNumOrBool === "string") : boolean >typeof strOrNumOrBool === "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" >!(typeof strOrNumOrBool === "number") : boolean >(typeof strOrNumOrBool === "number") : boolean >typeof strOrNumOrBool === "number" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : number | boolean >"number" : "number" @@ -151,7 +151,7 @@ if (!(typeof strOrNumOrBool === "string") && numOrBool !== strOrNumOrBool) { >!(typeof strOrNumOrBool === "string") : boolean >(typeof strOrNumOrBool === "string") : boolean >typeof strOrNumOrBool === "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" >numOrBool !== strOrNumOrBool : boolean diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types b/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types index c06c16e331dea..a2cfdf64ea835 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfBoolean.types @@ -46,7 +46,7 @@ var c: C; // - when false, removes the primitive type from the type of x. if (typeof strOrBool === "boolean") { >typeof strOrBool === "boolean" : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >"boolean" : "boolean" @@ -63,7 +63,7 @@ else { } if (typeof numOrBool === "boolean") { >typeof numOrBool === "boolean" : boolean ->typeof numOrBool : string +>typeof numOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >numOrBool : number | boolean >"boolean" : "boolean" @@ -80,7 +80,7 @@ else { } if (typeof strOrNumOrBool === "boolean") { >typeof strOrNumOrBool === "boolean" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"boolean" : "boolean" @@ -97,7 +97,7 @@ else { } if (typeof boolOrC === "boolean") { >typeof boolOrC === "boolean" : boolean ->typeof boolOrC : string +>typeof boolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >boolOrC : boolean | C >"boolean" : "boolean" @@ -115,7 +115,7 @@ else { if (typeof strOrNum === "boolean") { >typeof strOrNum === "boolean" : boolean ->typeof strOrNum : string +>typeof strOrNum : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNum : string | number >"boolean" : "boolean" @@ -135,7 +135,7 @@ else { // - when false, narrows the type of x by typeof x === s when true. if (typeof strOrBool !== "boolean") { >typeof strOrBool !== "boolean" : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >"boolean" : "boolean" @@ -152,7 +152,7 @@ else { } if (typeof numOrBool !== "boolean") { >typeof numOrBool !== "boolean" : boolean ->typeof numOrBool : string +>typeof numOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >numOrBool : number | boolean >"boolean" : "boolean" @@ -169,7 +169,7 @@ else { } if (typeof strOrNumOrBool !== "boolean") { >typeof strOrNumOrBool !== "boolean" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"boolean" : "boolean" @@ -186,7 +186,7 @@ else { } if (typeof boolOrC !== "boolean") { >typeof boolOrC !== "boolean" : boolean ->typeof boolOrC : string +>typeof boolOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >boolOrC : boolean | C >"boolean" : "boolean" @@ -204,7 +204,7 @@ else { if (typeof strOrNum !== "boolean") { >typeof strOrNum !== "boolean" : boolean ->typeof strOrNum : string +>typeof strOrNum : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNum : string | number >"boolean" : "boolean" diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfEqualEqualHasNoEffect.errors.txt b/tests/baselines/reference/typeGuardOfFormTypeOfEqualEqualHasNoEffect.errors.txt index c76c6e819df11..1845d2e9775f2 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfEqualEqualHasNoEffect.errors.txt +++ b/tests/baselines/reference/typeGuardOfFormTypeOfEqualEqualHasNoEffect.errors.txt @@ -1,10 +1,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts(13,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r1' must be of type 'string', but here has type 'number'. tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts(20,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r2' must be of type 'boolean', but here has type 'string'. tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts(27,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r3' must be of type 'number', but here has type 'boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts(30,5): error TS2365: Operator '==' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts(34,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r4' must be of type 'C', but here has type 'string'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts (4 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHasNoEffect.ts (5 errors) ==== class C { private p: string }; var strOrNum: string | number; @@ -41,6 +42,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfEqualEqualHa } if (typeof strOrC == "Object") { + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. var r4 = strOrC; // string | C } else { diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfIsOrderIndependent.types b/tests/baselines/reference/typeGuardOfFormTypeOfIsOrderIndependent.types index 43cc37f98e837..be5949837791b 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfIsOrderIndependent.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfIsOrderIndependent.types @@ -26,7 +26,7 @@ var func: () => void; if ("string" === typeof strOrNum) { >"string" === typeof strOrNum : boolean >"string" : "string" ->typeof strOrNum : string +>typeof strOrNum : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNum : string | number str = strOrNum; @@ -43,7 +43,7 @@ else { if ("function" === typeof strOrFunc) { >"function" === typeof strOrFunc : boolean >"function" : "function" ->typeof strOrFunc : string +>typeof strOrFunc : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrFunc : string | (() => void) func = strOrFunc; @@ -60,7 +60,7 @@ else { if ("number" === typeof numOrBool) { >"number" === typeof numOrBool : boolean >"number" : "number" ->typeof numOrBool : string +>typeof numOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >numOrBool : number | boolean num = numOrBool; @@ -77,7 +77,7 @@ else { if ("boolean" === typeof strOrBool) { >"boolean" === typeof strOrBool : boolean >"boolean" : "boolean" ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean bool = strOrBool; diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfNotEqualHasNoEffect.errors.txt b/tests/baselines/reference/typeGuardOfFormTypeOfNotEqualHasNoEffect.errors.txt index 3b29f3ecba841..1814abec82380 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfNotEqualHasNoEffect.errors.txt +++ b/tests/baselines/reference/typeGuardOfFormTypeOfNotEqualHasNoEffect.errors.txt @@ -1,10 +1,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts(13,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r1' must be of type 'number', but here has type 'string'. tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts(20,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r2' must be of type 'string', but here has type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts(27,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r3' must be of type 'boolean', but here has type 'number'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts(30,5): error TS2365: Operator '!=' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts(34,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'r4' must be of type 'string', but here has type 'C'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts (4 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasNoEffect.ts (5 errors) ==== class C { private p: string }; var strOrNum: string | number; @@ -41,6 +42,8 @@ tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfNotEqualHasN } if (typeof strOrC != "Object") { + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '!=' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. var r4 = strOrC; // string | C } else { diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types b/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types index 17787d06486ca..ec0854f6bc2be 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfNumber.types @@ -46,7 +46,7 @@ var c: C; // - when false, removes the primitive type from the type of x. if (typeof strOrNum === "number") { >typeof strOrNum === "number" : boolean ->typeof strOrNum : string +>typeof strOrNum : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNum : string | number >"number" : "number" @@ -63,7 +63,7 @@ else { } if (typeof numOrBool === "number") { >typeof numOrBool === "number" : boolean ->typeof numOrBool : string +>typeof numOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >numOrBool : number | boolean >"number" : "number" @@ -79,7 +79,7 @@ else { } if (typeof strOrNumOrBool === "number") { >typeof strOrNumOrBool === "number" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"number" : "number" @@ -96,7 +96,7 @@ else { } if (typeof numOrC === "number") { >typeof numOrC === "number" : boolean ->typeof numOrC : string +>typeof numOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >numOrC : number | C >"number" : "number" @@ -114,7 +114,7 @@ else { if (typeof strOrBool === "number") { >typeof strOrBool === "number" : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >"number" : "number" @@ -133,7 +133,7 @@ else { // - when false, narrows the type of x by typeof x === s when true. if (typeof strOrNum !== "number") { >typeof strOrNum !== "number" : boolean ->typeof strOrNum : string +>typeof strOrNum : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNum : string | number >"number" : "number" @@ -150,7 +150,7 @@ else { } if (typeof numOrBool !== "number") { >typeof numOrBool !== "number" : boolean ->typeof numOrBool : string +>typeof numOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >numOrBool : number | boolean >"number" : "number" @@ -166,7 +166,7 @@ else { } if (typeof strOrNumOrBool !== "number") { >typeof strOrNumOrBool !== "number" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"number" : "number" @@ -183,7 +183,7 @@ else { } if (typeof numOrC !== "number") { >typeof numOrC !== "number" : boolean ->typeof numOrC : string +>typeof numOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >numOrC : number | C >"number" : "number" @@ -201,7 +201,7 @@ else { if (typeof strOrBool !== "number") { >typeof strOrBool !== "number" : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >"number" : "number" diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.errors.txt b/tests/baselines/reference/typeGuardOfFormTypeOfOther.errors.txt new file mode 100644 index 0000000000000..c9cb9fdd4561c --- /dev/null +++ b/tests/baselines/reference/typeGuardOfFormTypeOfOther.errors.txt @@ -0,0 +1,118 @@ +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts(21,5): error TS2365: Operator '===' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts(27,5): error TS2365: Operator '===' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts(33,5): error TS2365: Operator '===' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts(40,5): error TS2322: Type 'string | C' is not assignable to type 'C'. + Type 'string' is not assignable to type 'C'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts(43,9): error TS2322: Type 'string | C' is not assignable to type 'string'. + Type 'C' is not assignable to type 'string'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts(46,5): error TS2365: Operator '===' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts(56,5): error TS2365: Operator '!==' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts(62,5): error TS2365: Operator '!==' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts(68,5): error TS2365: Operator '!==' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. +tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts(75,5): error TS2365: Operator '!==' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. + + +==== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts (10 errors) ==== + class C { private p: string }; + + var str: string; + var bool: boolean; + var num: number; + var strOrNum: string | number; + var strOrBool: string | boolean; + var numOrBool: number | boolean + var strOrNumOrBool: string | number | boolean; + var strOrC: string | C; + var numOrC: number | C; + var boolOrC: boolean | C; + var emptyObj: {}; + var c: C; + + // A type guard of the form typeof x === s, + // where s is a string literal with any value but 'string', 'number' or 'boolean', + // - when true, removes the primitive types string, number, and boolean from the type of x, or + // - when false, has no effect on the type of x. + + if (typeof strOrC === "Object") { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. + c = strOrC; // C + } + else { + var r2: string = strOrC; // string + } + if (typeof numOrC === "Object") { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. + c = numOrC; // C + } + else { + var r3: number = numOrC; // number + } + if (typeof boolOrC === "Object") { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. + c = boolOrC; // C + } + else { + var r4: boolean = boolOrC; // boolean + } + if (typeof strOrC === "Object" as string) { // comparison is OK with cast + c = strOrC; // error: but no narrowing to C + ~ +!!! error TS2322: Type 'string | C' is not assignable to type 'C'. +!!! error TS2322: Type 'string' is not assignable to type 'C'. + } + else { + var r5: string = strOrC; // error: no narrowing to string + ~~ +!!! error TS2322: Type 'string | C' is not assignable to type 'string'. +!!! error TS2322: Type 'C' is not assignable to type 'string'. + } + + if (typeof strOrNumOrBool === "Object") { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '===' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. + let q1: {} = strOrNumOrBool; // {} + } + else { + let q2: string | number | boolean = strOrNumOrBool; // string | number | boolean + } + + // A type guard of the form typeof x !== s, where s is a string literal, + // - when true, narrows the type of x by typeof x === s when false, or + // - when false, narrows the type of x by typeof x === s when true. + if (typeof strOrC !== "Object") { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '!==' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. + var r2: string = strOrC; // string + } + else { + c = strOrC; // C + } + if (typeof numOrC !== "Object") { + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '!==' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. + var r3: number = numOrC; // number + } + else { + c = numOrC; // C + } + if (typeof boolOrC !== "Object") { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '!==' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. + var r4: boolean = boolOrC; // boolean + } + else { + c = boolOrC; // C + } + + if (typeof strOrNumOrBool !== "Object") { + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2365: Operator '!==' cannot be applied to types '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' and '"Object"'. + let q1: string | number | boolean = strOrNumOrBool; // string | number | boolean + } + else { + let q2: {} = strOrNumOrBool; // {} + } + \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.js b/tests/baselines/reference/typeGuardOfFormTypeOfOther.js index ee0b6f6633279..571edc7e5a2e8 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.js +++ b/tests/baselines/reference/typeGuardOfFormTypeOfOther.js @@ -37,6 +37,12 @@ if (typeof boolOrC === "Object") { else { var r4: boolean = boolOrC; // boolean } +if (typeof strOrC === "Object" as string) { // comparison is OK with cast + c = strOrC; // error: but no narrowing to C +} +else { + var r5: string = strOrC; // error: no narrowing to string +} if (typeof strOrNumOrBool === "Object") { let q1: {} = strOrNumOrBool; // {} @@ -116,6 +122,12 @@ if (typeof boolOrC === "Object") { else { var r4 = boolOrC; // boolean } +if (typeof strOrC === "Object") { + c = strOrC; // error: but no narrowing to C +} +else { + var r5 = strOrC; // error: no narrowing to string +} if (typeof strOrNumOrBool === "Object") { var q1 = strOrNumOrBool; // {} } diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols b/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols deleted file mode 100644 index a8760feda4515..0000000000000 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.symbols +++ /dev/null @@ -1,153 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts === -class C { private p: string }; ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) ->p : Symbol(C.p, Decl(typeGuardOfFormTypeOfOther.ts, 0, 9)) - -var str: string; ->str : Symbol(str, Decl(typeGuardOfFormTypeOfOther.ts, 2, 3)) - -var bool: boolean; ->bool : Symbol(bool, Decl(typeGuardOfFormTypeOfOther.ts, 3, 3)) - -var num: number; ->num : Symbol(num, Decl(typeGuardOfFormTypeOfOther.ts, 4, 3)) - -var strOrNum: string | number; ->strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfOther.ts, 5, 3)) - -var strOrBool: string | boolean; ->strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 6, 3)) - -var numOrBool: number | boolean ->numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 7, 3)) - -var strOrNumOrBool: string | number | boolean; ->strOrNumOrBool : Symbol(strOrNumOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 8, 3)) - -var strOrC: string | C; ->strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) - -var numOrC: number | C; ->numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) - -var boolOrC: boolean | C; ->boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) - -var emptyObj: {}; ->emptyObj : Symbol(emptyObj, Decl(typeGuardOfFormTypeOfOther.ts, 12, 3)) - -var c: C; ->c : Symbol(c, Decl(typeGuardOfFormTypeOfOther.ts, 13, 3)) ->C : Symbol(C, Decl(typeGuardOfFormTypeOfOther.ts, 0, 0)) - -// A type guard of the form typeof x === s, -// where s is a string literal with any value but 'string', 'number' or 'boolean', -// - when true, removes the primitive types string, number, and boolean from the type of x, or -// - when false, has no effect on the type of x. - -if (typeof strOrC === "Object") { ->strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) - - c = strOrC; // C ->c : Symbol(c, Decl(typeGuardOfFormTypeOfOther.ts, 13, 3)) ->strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) -} -else { - var r2: string = strOrC; // string ->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") { ->numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) - - c = numOrC; // C ->c : Symbol(c, Decl(typeGuardOfFormTypeOfOther.ts, 13, 3)) ->numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) -} -else { - var r3: number = numOrC; // number ->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") { ->boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) - - c = boolOrC; // C ->c : Symbol(c, Decl(typeGuardOfFormTypeOfOther.ts, 13, 3)) ->boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) -} -else { - var r4: boolean = boolOrC; // boolean ->r4 : Symbol(r4, Decl(typeGuardOfFormTypeOfOther.ts, 36, 7), Decl(typeGuardOfFormTypeOfOther.ts, 62, 7)) ->boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) -} - -if (typeof strOrNumOrBool === "Object") { ->strOrNumOrBool : Symbol(strOrNumOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 8, 3)) - - let q1: {} = strOrNumOrBool; // {} ->q1 : Symbol(q1, Decl(typeGuardOfFormTypeOfOther.ts, 40, 7)) ->strOrNumOrBool : Symbol(strOrNumOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 8, 3)) -} -else { - 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)) -} - -// A type guard of the form typeof x !== s, where s is a string literal, -// - when true, narrows the type of x by typeof x === s when false, or -// - when false, narrows the type of x by typeof x === s when true. -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, 50, 7)) ->strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) -} -else { - c = strOrC; // C ->c : Symbol(c, Decl(typeGuardOfFormTypeOfOther.ts, 13, 3)) ->strOrC : Symbol(strOrC, Decl(typeGuardOfFormTypeOfOther.ts, 9, 3)) -} -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, 56, 7)) ->numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) -} -else { - c = numOrC; // C ->c : Symbol(c, Decl(typeGuardOfFormTypeOfOther.ts, 13, 3)) ->numOrC : Symbol(numOrC, Decl(typeGuardOfFormTypeOfOther.ts, 10, 3)) -} -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, 62, 7)) ->boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) -} -else { - c = boolOrC; // C ->c : Symbol(c, Decl(typeGuardOfFormTypeOfOther.ts, 13, 3)) ->boolOrC : Symbol(boolOrC, Decl(typeGuardOfFormTypeOfOther.ts, 11, 3)) -} - -if (typeof strOrNumOrBool !== "Object") { ->strOrNumOrBool : Symbol(strOrNumOrBool, Decl(typeGuardOfFormTypeOfOther.ts, 8, 3)) - - 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 { - 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 deleted file mode 100644 index b87f6a2a004b3..0000000000000 --- a/tests/baselines/reference/typeGuardOfFormTypeOfOther.types +++ /dev/null @@ -1,183 +0,0 @@ -=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts === -class C { private p: string }; ->C : C ->p : string - -var str: string; ->str : string - -var bool: boolean; ->bool : boolean - -var num: number; ->num : number - -var strOrNum: string | number; ->strOrNum : string | number - -var strOrBool: string | boolean; ->strOrBool : string | boolean - -var numOrBool: number | boolean ->numOrBool : number | boolean - -var strOrNumOrBool: string | number | boolean; ->strOrNumOrBool : string | number | boolean - -var strOrC: string | C; ->strOrC : string | C ->C : C - -var numOrC: number | C; ->numOrC : number | C ->C : C - -var boolOrC: boolean | C; ->boolOrC : boolean | C ->C : C - -var emptyObj: {}; ->emptyObj : {} - -var c: C; ->c : C ->C : C - -// A type guard of the form typeof x === s, -// where s is a string literal with any value but 'string', 'number' or 'boolean', -// - when true, removes the primitive types string, number, and boolean from the type of x, or -// - when false, has no effect on the type of x. - -if (typeof strOrC === "Object") { ->typeof strOrC === "Object" : boolean ->typeof strOrC : string ->strOrC : string | C ->"Object" : "Object" - - c = strOrC; // C ->c = strOrC : C ->c : C ->strOrC : C -} -else { - var r2: string = strOrC; // string ->r2 : string ->strOrC : string -} -if (typeof numOrC === "Object") { ->typeof numOrC === "Object" : boolean ->typeof numOrC : string ->numOrC : number | C ->"Object" : "Object" - - c = numOrC; // C ->c = numOrC : C ->c : C ->numOrC : C -} -else { - var r3: number = numOrC; // number ->r3 : number ->numOrC : number -} -if (typeof boolOrC === "Object") { ->typeof boolOrC === "Object" : boolean ->typeof boolOrC : string ->boolOrC : boolean | C ->"Object" : "Object" - - c = boolOrC; // C ->c = boolOrC : C ->c : C ->boolOrC : C -} -else { - var r4: boolean = boolOrC; // boolean ->r4 : boolean ->boolOrC : boolean -} - -if (typeof strOrNumOrBool === "Object") { ->typeof strOrNumOrBool === "Object" : boolean ->typeof strOrNumOrBool : string ->strOrNumOrBool : string | number | boolean ->"Object" : "Object" - - let q1: {} = strOrNumOrBool; // {} ->q1 : {} ->strOrNumOrBool : never -} -else { - let q2: string | number | boolean = strOrNumOrBool; // string | number | boolean ->q2 : string | number | boolean ->strOrNumOrBool : string | number | boolean -} - -// A type guard of the form typeof x !== s, where s is a string literal, -// - when true, narrows the type of x by typeof x === s when false, or -// - when false, narrows the type of x by typeof x === s when true. -if (typeof strOrC !== "Object") { ->typeof strOrC !== "Object" : boolean ->typeof strOrC : string ->strOrC : string | C ->"Object" : "Object" - - var r2: string = strOrC; // string ->r2 : string ->strOrC : string -} -else { - c = strOrC; // C ->c = strOrC : C ->c : C ->strOrC : C -} -if (typeof numOrC !== "Object") { ->typeof numOrC !== "Object" : boolean ->typeof numOrC : string ->numOrC : number | C ->"Object" : "Object" - - var r3: number = numOrC; // number ->r3 : number ->numOrC : number -} -else { - c = numOrC; // C ->c = numOrC : C ->c : C ->numOrC : C -} -if (typeof boolOrC !== "Object") { ->typeof boolOrC !== "Object" : boolean ->typeof boolOrC : string ->boolOrC : boolean | C ->"Object" : "Object" - - var r4: boolean = boolOrC; // boolean ->r4 : boolean ->boolOrC : boolean -} -else { - c = boolOrC; // C ->c = boolOrC : C ->c : C ->boolOrC : C -} - -if (typeof strOrNumOrBool !== "Object") { ->typeof strOrNumOrBool !== "Object" : boolean ->typeof strOrNumOrBool : string ->strOrNumOrBool : string | number | boolean ->"Object" : "Object" - - let q1: string | number | boolean = strOrNumOrBool; // string | number | boolean ->q1 : string | number | boolean ->strOrNumOrBool : string | number | boolean -} -else { - let q2: {} = strOrNumOrBool; // {} ->q2 : {} ->strOrNumOrBool : never -} - diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types b/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types index 6302ef58005c9..4787c07d75807 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfPrimitiveSubtype.types @@ -8,7 +8,7 @@ let b: {toString(): string}; if (typeof a === "number") { >typeof a === "number" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : {} >"number" : "number" @@ -18,7 +18,7 @@ if (typeof a === "number") { } if (typeof a === "string") { >typeof a === "string" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : {} >"string" : "string" @@ -28,7 +28,7 @@ if (typeof a === "string") { } if (typeof a === "boolean") { >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : {} >"boolean" : "boolean" @@ -39,7 +39,7 @@ if (typeof a === "boolean") { if (typeof b === "number") { >typeof b === "number" : boolean ->typeof b : string +>typeof b : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >b : { toString(): string; } >"number" : "number" @@ -49,7 +49,7 @@ if (typeof b === "number") { } if (typeof b === "string") { >typeof b === "string" : boolean ->typeof b : string +>typeof b : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >b : { toString(): string; } >"string" : "string" @@ -59,7 +59,7 @@ if (typeof b === "string") { } if (typeof b === "boolean") { >typeof b === "boolean" : boolean ->typeof b : string +>typeof b : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >b : { toString(): string; } >"boolean" : "boolean" diff --git a/tests/baselines/reference/typeGuardOfFormTypeOfString.types b/tests/baselines/reference/typeGuardOfFormTypeOfString.types index e9960ac3019db..6b3e048212a6e 100644 --- a/tests/baselines/reference/typeGuardOfFormTypeOfString.types +++ b/tests/baselines/reference/typeGuardOfFormTypeOfString.types @@ -46,7 +46,7 @@ var c: C; // - when false, removes the primitive type from the type of x. if (typeof strOrNum === "string") { >typeof strOrNum === "string" : boolean ->typeof strOrNum : string +>typeof strOrNum : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNum : string | number >"string" : "string" @@ -63,7 +63,7 @@ else { } if (typeof strOrBool === "string") { >typeof strOrBool === "string" : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >"string" : "string" @@ -80,7 +80,7 @@ else { } if (typeof strOrNumOrBool === "string") { >typeof strOrNumOrBool === "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" @@ -97,7 +97,7 @@ else { } if (typeof strOrC === "string") { >typeof strOrC === "string" : boolean ->typeof strOrC : string +>typeof strOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrC : string | C >"string" : "string" @@ -115,7 +115,7 @@ else { if (typeof numOrBool === "string") { >typeof numOrBool === "string" : boolean ->typeof numOrBool : string +>typeof numOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >numOrBool : number | boolean >"string" : "string" @@ -134,7 +134,7 @@ else { // - when false, narrows the type of x by typeof x === s when true. if (typeof strOrNum !== "string") { >typeof strOrNum !== "string" : boolean ->typeof strOrNum : string +>typeof strOrNum : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNum : string | number >"string" : "string" @@ -151,7 +151,7 @@ else { } if (typeof strOrBool !== "string") { >typeof strOrBool !== "string" : boolean ->typeof strOrBool : string +>typeof strOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrBool : string | boolean >"string" : "string" @@ -168,7 +168,7 @@ else { } if (typeof strOrNumOrBool !== "string") { >typeof strOrNumOrBool !== "string" : boolean ->typeof strOrNumOrBool : string +>typeof strOrNumOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrNumOrBool : string | number | boolean >"string" : "string" @@ -185,7 +185,7 @@ else { } if (typeof strOrC !== "string") { >typeof strOrC !== "string" : boolean ->typeof strOrC : string +>typeof strOrC : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >strOrC : string | C >"string" : "string" @@ -203,7 +203,7 @@ else { if (typeof numOrBool !== "string") { >typeof numOrBool !== "string" : boolean ->typeof numOrBool : string +>typeof numOrBool : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >numOrBool : number | boolean >"string" : "string" diff --git a/tests/baselines/reference/typeGuardRedundancy.types b/tests/baselines/reference/typeGuardRedundancy.types index 80de5f54acea7..2023defbb43ca 100644 --- a/tests/baselines/reference/typeGuardRedundancy.types +++ b/tests/baselines/reference/typeGuardRedundancy.types @@ -7,11 +7,11 @@ var r1 = typeof x === "string" && typeof x === "string" ? x.substr : x.toFixed; >typeof x === "string" && typeof x === "string" ? x.substr : x.toFixed : (from: number, length?: number) => string >typeof x === "string" && typeof x === "string" : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string >"string" : "string" >x.substr : (from: number, length?: number) => string @@ -28,11 +28,11 @@ var r2 = !(typeof x === "string" && typeof x === "string") ? x.toFixed : x.subst >(typeof x === "string" && typeof x === "string") : boolean >typeof x === "string" && typeof x === "string" : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string >"string" : "string" >x.toFixed : (fractionDigits?: number) => string @@ -47,11 +47,11 @@ var r3 = typeof x === "string" || typeof x === "string" ? x.substr : x.toFixed; >typeof x === "string" || typeof x === "string" ? x.substr : x.toFixed : (from: number, length?: number) => string >typeof x === "string" || typeof x === "string" : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number >"string" : "string" >x.substr : (from: number, length?: number) => string @@ -68,11 +68,11 @@ var r4 = !(typeof x === "string" || typeof x === "string") ? x.toFixed : x.subst >(typeof x === "string" || typeof x === "string") : boolean >typeof x === "string" || typeof x === "string" : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number >"string" : "string" >x.toFixed : (fractionDigits?: number) => string diff --git a/tests/baselines/reference/typeGuardTautologicalConsistiency.types b/tests/baselines/reference/typeGuardTautologicalConsistiency.types index 0a6524dd26f23..136b09674d891 100644 --- a/tests/baselines/reference/typeGuardTautologicalConsistiency.types +++ b/tests/baselines/reference/typeGuardTautologicalConsistiency.types @@ -4,13 +4,13 @@ let stringOrNumber: string | number; if (typeof stringOrNumber === "number") { >typeof stringOrNumber === "number" : boolean ->typeof stringOrNumber : string +>typeof stringOrNumber : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >stringOrNumber : string | number >"number" : "number" if (typeof stringOrNumber !== "number") { >typeof stringOrNumber !== "number" : boolean ->typeof stringOrNumber : string +>typeof stringOrNumber : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >stringOrNumber : number >"number" : "number" @@ -22,11 +22,11 @@ if (typeof stringOrNumber === "number") { if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { >typeof stringOrNumber === "number" && typeof stringOrNumber !== "number" : boolean >typeof stringOrNumber === "number" : boolean ->typeof stringOrNumber : string +>typeof stringOrNumber : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >stringOrNumber : string | number >"number" : "number" >typeof stringOrNumber !== "number" : boolean ->typeof stringOrNumber : string +>typeof stringOrNumber : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >stringOrNumber : number >"number" : "number" diff --git a/tests/baselines/reference/typeGuardTypeOfUndefined.types b/tests/baselines/reference/typeGuardTypeOfUndefined.types index 520d045d9e0d1..a28dab044907a 100644 --- a/tests/baselines/reference/typeGuardTypeOfUndefined.types +++ b/tests/baselines/reference/typeGuardTypeOfUndefined.types @@ -6,13 +6,13 @@ function test1(a: any) { if (typeof a !== "undefined") { >typeof a !== "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : any >"undefined" : "undefined" if (typeof a === "boolean") { >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : any >"boolean" : "boolean" @@ -36,13 +36,13 @@ function test2(a: any) { if (typeof a === "undefined") { >typeof a === "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : any >"undefined" : "undefined" if (typeof a === "boolean") { >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : undefined >"boolean" : "boolean" @@ -67,11 +67,11 @@ function test3(a: any) { if (typeof a === "undefined" || typeof a === "boolean") { >typeof a === "undefined" || typeof a === "boolean" : boolean >typeof a === "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : any >"undefined" : "undefined" >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : any >"boolean" : "boolean" @@ -91,11 +91,11 @@ function test4(a: any) { if (typeof a !== "undefined" && typeof a === "boolean") { >typeof a !== "undefined" && typeof a === "boolean" : boolean >typeof a !== "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : any >"undefined" : "undefined" >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : any >"boolean" : "boolean" @@ -114,13 +114,13 @@ function test5(a: boolean | void) { if (typeof a !== "undefined") { >typeof a !== "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : boolean | void >"undefined" : "undefined" if (typeof a === "boolean") { >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : boolean >"boolean" : "boolean" @@ -144,13 +144,13 @@ function test6(a: boolean | void) { if (typeof a === "undefined") { >typeof a === "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : boolean | void >"undefined" : "undefined" if (typeof a === "boolean") { >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : boolean | void >"boolean" : "boolean" @@ -175,11 +175,11 @@ function test7(a: boolean | void) { if (typeof a === "undefined" || typeof a === "boolean") { >typeof a === "undefined" || typeof a === "boolean" : boolean >typeof a === "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : boolean | void >"undefined" : "undefined" >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : boolean >"boolean" : "boolean" @@ -199,11 +199,11 @@ function test8(a: boolean | void) { if (typeof a !== "undefined" && typeof a === "boolean") { >typeof a !== "undefined" && typeof a === "boolean" : boolean >typeof a !== "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : boolean | void >"undefined" : "undefined" >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : boolean >"boolean" : "boolean" @@ -222,13 +222,13 @@ function test9(a: boolean | number) { if (typeof a !== "undefined") { >typeof a !== "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"undefined" : "undefined" if (typeof a === "boolean") { >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"boolean" : "boolean" @@ -252,13 +252,13 @@ function test10(a: boolean | number) { if (typeof a === "undefined") { >typeof a === "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"undefined" : "undefined" if (typeof a === "boolean") { >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"boolean" : "boolean" @@ -283,11 +283,11 @@ function test11(a: boolean | number) { if (typeof a === "undefined" || typeof a === "boolean") { >typeof a === "undefined" || typeof a === "boolean" : boolean >typeof a === "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"undefined" : "undefined" >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"boolean" : "boolean" @@ -307,11 +307,11 @@ function test12(a: boolean | number) { if (typeof a !== "undefined" && typeof a === "boolean") { >typeof a !== "undefined" && typeof a === "boolean" : boolean >typeof a !== "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"undefined" : "undefined" >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"boolean" : "boolean" @@ -330,13 +330,13 @@ function test13(a: boolean | number | void) { if (typeof a !== "undefined") { >typeof a !== "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean | void >"undefined" : "undefined" if (typeof a === "boolean") { >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"boolean" : "boolean" @@ -360,13 +360,13 @@ function test14(a: boolean | number | void) { if (typeof a === "undefined") { >typeof a === "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean | void >"undefined" : "undefined" if (typeof a === "boolean") { >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean | void >"boolean" : "boolean" @@ -391,11 +391,11 @@ function test15(a: boolean | number | void) { if (typeof a === "undefined" || typeof a === "boolean") { >typeof a === "undefined" || typeof a === "boolean" : boolean >typeof a === "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean | void >"undefined" : "undefined" >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"boolean" : "boolean" @@ -415,11 +415,11 @@ function test16(a: boolean | number | void) { if (typeof a !== "undefined" && typeof a === "boolean") { >typeof a !== "undefined" && typeof a === "boolean" : boolean >typeof a !== "undefined" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean | void >"undefined" : "undefined" >typeof a === "boolean" : boolean ->typeof a : string +>typeof a : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >a : number | boolean >"boolean" : "boolean" diff --git a/tests/baselines/reference/typeGuardsAsAssertions.types b/tests/baselines/reference/typeGuardsAsAssertions.types index bdda2eafefd9d..06dda2691be8e 100644 --- a/tests/baselines/reference/typeGuardsAsAssertions.types +++ b/tests/baselines/reference/typeGuardsAsAssertions.types @@ -118,7 +118,7 @@ function foo1() { >x : string | number | boolean >typeof x === "string" ? x.slice() : "abc" : string >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >x.slice() : string @@ -152,7 +152,7 @@ function foo2() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -211,7 +211,7 @@ function f2() { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : undefined >"string" : "string" @@ -254,7 +254,7 @@ function f4() { if (typeof x === "boolean") { >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : undefined >"boolean" : "boolean" @@ -272,11 +272,11 @@ function f5(x: string | number) { if (typeof x === "string" && typeof x === "number") { >typeof x === "string" && typeof x === "number" : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string >"number" : "number" diff --git a/tests/baselines/reference/typeGuardsInClassAccessors.types b/tests/baselines/reference/typeGuardsInClassAccessors.types index 2250657e453a9..71e427124c47c 100644 --- a/tests/baselines/reference/typeGuardsInClassAccessors.types +++ b/tests/baselines/reference/typeGuardsInClassAccessors.types @@ -26,7 +26,7 @@ class ClassWithAccessors { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -42,7 +42,7 @@ class ClassWithAccessors { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -63,7 +63,7 @@ class ClassWithAccessors { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -76,7 +76,7 @@ class ClassWithAccessors { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -92,7 +92,7 @@ class ClassWithAccessors { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -109,7 +109,7 @@ class ClassWithAccessors { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -125,7 +125,7 @@ class ClassWithAccessors { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -146,7 +146,7 @@ class ClassWithAccessors { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -159,7 +159,7 @@ class ClassWithAccessors { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -175,7 +175,7 @@ class ClassWithAccessors { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -192,7 +192,7 @@ class ClassWithAccessors { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -208,7 +208,7 @@ class ClassWithAccessors { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -229,7 +229,7 @@ class ClassWithAccessors { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -242,7 +242,7 @@ class ClassWithAccessors { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -258,7 +258,7 @@ class ClassWithAccessors { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -275,7 +275,7 @@ class ClassWithAccessors { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -291,7 +291,7 @@ class ClassWithAccessors { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -312,7 +312,7 @@ class ClassWithAccessors { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -325,7 +325,7 @@ class ClassWithAccessors { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -341,7 +341,7 @@ class ClassWithAccessors { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number diff --git a/tests/baselines/reference/typeGuardsInClassMethods.types b/tests/baselines/reference/typeGuardsInClassMethods.types index 600e3e36ab0f2..3a45abcf1556d 100644 --- a/tests/baselines/reference/typeGuardsInClassMethods.types +++ b/tests/baselines/reference/typeGuardsInClassMethods.types @@ -21,7 +21,7 @@ class C1 { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -37,7 +37,7 @@ class C1 { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -50,7 +50,7 @@ class C1 { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -68,7 +68,7 @@ class C1 { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -84,7 +84,7 @@ class C1 { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -97,7 +97,7 @@ class C1 { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -115,7 +115,7 @@ class C1 { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -131,7 +131,7 @@ class C1 { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -144,7 +144,7 @@ class C1 { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -162,7 +162,7 @@ class C1 { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -178,7 +178,7 @@ class C1 { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -191,7 +191,7 @@ class C1 { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -209,7 +209,7 @@ class C1 { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -225,7 +225,7 @@ class C1 { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -238,7 +238,7 @@ class C1 { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.types b/tests/baselines/reference/typeGuardsInConditionalExpression.types index 165eecd3514f3..85d5380675d20 100644 --- a/tests/baselines/reference/typeGuardsInConditionalExpression.types +++ b/tests/baselines/reference/typeGuardsInConditionalExpression.types @@ -13,7 +13,7 @@ function foo(x: number | string) { return typeof x === "string" >typeof x === "string" ? x.length // string : x++ : number >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -33,7 +33,7 @@ function foo2(x: number | string) { return typeof x === "string" >typeof x === "string" ? ((x = "hello") && x) // string : x : string | number >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -56,7 +56,7 @@ function foo3(x: number | string) { return typeof x === "string" >typeof x === "string" ? ((x = 10) && x) // number : x : number >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -79,7 +79,7 @@ function foo4(x: number | string) { return typeof x === "string" >typeof x === "string" ? x // string : ((x = 10) && x) : string | number >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -102,7 +102,7 @@ function foo5(x: number | string) { return typeof x === "string" >typeof x === "string" ? x // string : ((x = "hello") && x) : string >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -126,7 +126,7 @@ function foo6(x: number | string) { return typeof x === "string" >typeof x === "string" ? ((x = 10) && x) // number : ((x = "hello") && x) : string | number >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -155,7 +155,7 @@ function foo7(x: number | string | boolean) { return typeof x === "string" >typeof x === "string" ? x === "hello" // boolean : typeof x === "boolean" ? x // boolean : x == 10 : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -167,7 +167,7 @@ function foo7(x: number | string | boolean) { : typeof x === "boolean" >typeof x === "boolean" ? x // boolean : x == 10 : boolean >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"boolean" : "boolean" @@ -189,7 +189,7 @@ function foo8(x: number | string | boolean) { return typeof x === "string" >typeof x === "string" ? x === "hello" : ((b = x) && // number | boolean (typeof x === "boolean" ? x // boolean : x == 10)) : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -210,7 +210,7 @@ function foo8(x: number | string | boolean) { >(typeof x === "boolean" ? x // boolean : x == 10) : boolean >typeof x === "boolean" ? x // boolean : x == 10 : boolean >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"boolean" : "boolean" @@ -234,7 +234,7 @@ function foo9(x: number | string) { return typeof x === "string" >typeof x === "string" ? ((y = x.length) && x === "hello") // boolean : x === 10 : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -267,7 +267,7 @@ function foo10(x: number | string | boolean) { return typeof x === "string" >typeof x === "string" ? x // string : ((b = x) // x is number | boolean && typeof x === "number" && x.toString()) : string >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -285,7 +285,7 @@ function foo10(x: number | string | boolean) { && typeof x === "number" >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" @@ -306,7 +306,7 @@ function foo11(x: number | string | boolean) { return typeof x === "string" >typeof x === "string" ? x // string : ((b = x) // x is number | boolean && typeof x === "number" && (x = 10) // assignment to x && x) : string | number >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -325,7 +325,7 @@ function foo11(x: number | string | boolean) { && typeof x === "number" >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" @@ -349,7 +349,7 @@ function foo12(x: number | string | boolean) { return typeof x === "string" >typeof x === "string" ? ((x = 10) && x.toString().length) // number : ((b = x) // x is number | boolean && typeof x === "number" && x) : number >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -378,7 +378,7 @@ function foo12(x: number | string | boolean) { && typeof x === "number" >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" diff --git a/tests/baselines/reference/typeGuardsInDoStatement.types b/tests/baselines/reference/typeGuardsInDoStatement.types index fe14cff375fc2..c663ebbea54a7 100644 --- a/tests/baselines/reference/typeGuardsInDoStatement.types +++ b/tests/baselines/reference/typeGuardsInDoStatement.types @@ -22,7 +22,7 @@ function a(x: string | number | boolean) { } while (typeof x === "string") >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -52,7 +52,7 @@ function b(x: string | number | boolean) { } while (typeof x === "string") >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -82,7 +82,7 @@ function c(x: string | number) { } while (typeof x === "string") >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" diff --git a/tests/baselines/reference/typeGuardsInExternalModule.types b/tests/baselines/reference/typeGuardsInExternalModule.types index a0c33af455742..86b47f9b5c626 100644 --- a/tests/baselines/reference/typeGuardsInExternalModule.types +++ b/tests/baselines/reference/typeGuardsInExternalModule.types @@ -11,7 +11,7 @@ var var1: string | number; if (typeof var1 === "string") { >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" @@ -38,7 +38,7 @@ export var var2: string | number; if (typeof var2 === "string") { >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" diff --git a/tests/baselines/reference/typeGuardsInForStatement.types b/tests/baselines/reference/typeGuardsInForStatement.types index 1d600d52d132e..4ad1a283d40cb 100644 --- a/tests/baselines/reference/typeGuardsInForStatement.types +++ b/tests/baselines/reference/typeGuardsInForStatement.types @@ -11,7 +11,7 @@ function a(x: string | number) { >x : string | number >undefined : undefined >typeof x !== "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"number" : "number" >x = undefined : undefined @@ -33,7 +33,7 @@ function b(x: string | number) { >x : string | number >undefined : undefined >typeof x !== "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"number" : "number" >x = undefined : undefined @@ -58,7 +58,7 @@ function c(x: string | number) { >x : string | number >undefined : undefined >typeof x !== "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"number" : "number" >x = undefined : undefined diff --git a/tests/baselines/reference/typeGuardsInFunction.types b/tests/baselines/reference/typeGuardsInFunction.types index 6a007dd7c955e..a7dca0f709b30 100644 --- a/tests/baselines/reference/typeGuardsInFunction.types +++ b/tests/baselines/reference/typeGuardsInFunction.types @@ -20,7 +20,7 @@ function f(param: string | number) { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -36,7 +36,7 @@ function f(param: string | number) { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -49,7 +49,7 @@ function f(param: string | number) { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -74,7 +74,7 @@ function f1(param: string | number) { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -87,7 +87,7 @@ function f1(param: string | number) { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -100,7 +100,7 @@ function f1(param: string | number) { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -116,7 +116,7 @@ function f1(param: string | number) { >num : number >typeof var3 === "string" && var3.length : number >typeof var3 === "string" : boolean ->typeof var3 : string +>typeof var3 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var3 : string | number >"string" : "string" >var3.length : number @@ -128,7 +128,7 @@ function f1(param: string | number) { >num : number >typeof param1 === "string" && param1.length : number >typeof param1 === "string" : boolean ->typeof param1 : string +>typeof param1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param1 : string | number >"string" : "string" >param1.length : number @@ -158,7 +158,7 @@ function f2(param: string | number) { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -171,7 +171,7 @@ function f2(param: string | number) { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -184,7 +184,7 @@ function f2(param: string | number) { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -200,7 +200,7 @@ function f2(param: string | number) { >num : number >typeof var3 === "string" && var3.length : number >typeof var3 === "string" : boolean ->typeof var3 : string +>typeof var3 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var3 : string | number >"string" : "string" >var3.length : number @@ -212,7 +212,7 @@ function f2(param: string | number) { >num : number >typeof param1 === "string" && param1.length : number >typeof param1 === "string" : boolean ->typeof param1 : string +>typeof param1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param1 : string | number >"string" : "string" >param1.length : number @@ -245,7 +245,7 @@ function f3(param: string | number) { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -258,7 +258,7 @@ function f3(param: string | number) { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -271,7 +271,7 @@ function f3(param: string | number) { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -287,7 +287,7 @@ function f3(param: string | number) { >num : number >typeof var3 === "string" && var3.length : number >typeof var3 === "string" : boolean ->typeof var3 : string +>typeof var3 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var3 : string | number >"string" : "string" >var3.length : number @@ -299,7 +299,7 @@ function f3(param: string | number) { >num : number >typeof param1 === "string" && param1.length : number >typeof param1 === "string" : boolean ->typeof param1 : string +>typeof param1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param1 : string | number >"string" : "string" >param1.length : number @@ -329,7 +329,7 @@ strOrNum = typeof f4() === "string" && f4(); // string | number >strOrNum : string | number >typeof f4() === "string" && f4() : string | number >typeof f4() === "string" : boolean ->typeof f4() : string +>typeof f4() : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >f4() : string | number >f4 : () => string | number >"string" : "string" diff --git a/tests/baselines/reference/typeGuardsInFunctionAndModuleBlock.types b/tests/baselines/reference/typeGuardsInFunctionAndModuleBlock.types index 0cb312ffb1a86..a425e4d632eba 100644 --- a/tests/baselines/reference/typeGuardsInFunctionAndModuleBlock.types +++ b/tests/baselines/reference/typeGuardsInFunctionAndModuleBlock.types @@ -8,7 +8,7 @@ function foo(x: number | string | boolean) { return typeof x === "string" >typeof x === "string" ? x : function f() { var b = x; // number | boolean return typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number } () : string >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -27,7 +27,7 @@ function foo(x: number | string | boolean) { return typeof x === "boolean" >typeof x === "boolean" ? x.toString() // boolean : x.toString() : string >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"boolean" : "boolean" @@ -52,7 +52,7 @@ function foo2(x: number | string | boolean) { return typeof x === "string" >typeof x === "string" ? x : function f(a: number | boolean) { var b = x; // new scope - number | boolean return typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number } (x) : string >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -72,7 +72,7 @@ function foo2(x: number | string | boolean) { return typeof x === "boolean" >typeof x === "boolean" ? x.toString() // boolean : x.toString() : string >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"boolean" : "boolean" @@ -98,7 +98,7 @@ function foo3(x: number | string | boolean) { return typeof x === "string" >typeof x === "string" ? x : (() => { var b = x; // new scope - number | boolean return typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number })() : string >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -117,7 +117,7 @@ function foo3(x: number | string | boolean) { return typeof x === "boolean" >typeof x === "boolean" ? x.toString() // boolean : x.toString() : string >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"boolean" : "boolean" @@ -142,7 +142,7 @@ function foo4(x: number | string | boolean) { return typeof x === "string" >typeof x === "string" ? x : ((a: number | boolean) => { var b = x; // new scope - number | boolean return typeof x === "boolean" ? x.toString() // boolean : x.toString(); // number })(x) : string >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -162,7 +162,7 @@ function foo4(x: number | string | boolean) { return typeof x === "boolean" >typeof x === "boolean" ? x.toString() // boolean : x.toString() : string >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"boolean" : "boolean" @@ -188,7 +188,7 @@ function foo5(x: number | string | boolean) { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -223,7 +223,7 @@ module m { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -238,7 +238,7 @@ module m { >y : string >typeof x === "boolean" ? x.toString() // boolean : x.toString() : string >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"boolean" : "boolean" @@ -275,7 +275,7 @@ module m1 { if (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -290,7 +290,7 @@ module m1 { >y : string >typeof x === "boolean" ? x.toString() // boolean : x.toString() : string >typeof x === "boolean" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"boolean" : "boolean" diff --git a/tests/baselines/reference/typeGuardsInGlobal.types b/tests/baselines/reference/typeGuardsInGlobal.types index 7935c05411e2e..7ccc2defe27ba 100644 --- a/tests/baselines/reference/typeGuardsInGlobal.types +++ b/tests/baselines/reference/typeGuardsInGlobal.types @@ -11,7 +11,7 @@ var var1: string | number; if (typeof var1 === "string") { >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" diff --git a/tests/baselines/reference/typeGuardsInModule.types b/tests/baselines/reference/typeGuardsInModule.types index f1efc45a2484f..a14c47e3ccaa4 100644 --- a/tests/baselines/reference/typeGuardsInModule.types +++ b/tests/baselines/reference/typeGuardsInModule.types @@ -22,7 +22,7 @@ module m1 { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -35,7 +35,7 @@ module m1 { if (typeof var2 === "string") { >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" @@ -59,7 +59,7 @@ module m1 { if (typeof var3 === "string") { >typeof var3 === "string" : boolean ->typeof var3 : string +>typeof var3 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var3 : string | number >"string" : "string" @@ -94,7 +94,7 @@ module m2 { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -107,7 +107,7 @@ module m2 { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -120,7 +120,7 @@ module m2 { >strOrNum : string | number >typeof var3 === "string" && var3 : string >typeof var3 === "string" : boolean ->typeof var3 : string +>typeof var3 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var3 : string | number >"string" : "string" >var3 : string @@ -131,7 +131,7 @@ module m2 { if (typeof var4 === "string") { >typeof var4 === "string" : boolean ->typeof var4 : string +>typeof var4 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var4 : string | number >"string" : "string" @@ -155,7 +155,7 @@ module m2 { if (typeof var5 === "string") { >typeof var5 === "string" : boolean ->typeof var5 : string +>typeof var5 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var5 : string | number >"string" : "string" @@ -183,7 +183,7 @@ module m3.m4 { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -196,7 +196,7 @@ module m3.m4 { if (typeof var2 === "string") { >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" @@ -220,7 +220,7 @@ module m3.m4 { if (typeof var3 === "string") { >typeof var3 === "string" : boolean ->typeof var3 : string +>typeof var3 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var3 : string | number >"string" : "string" diff --git a/tests/baselines/reference/typeGuardsInProperties.types b/tests/baselines/reference/typeGuardsInProperties.types index 1f8151dff7133..d40de30bd97b0 100644 --- a/tests/baselines/reference/typeGuardsInProperties.types +++ b/tests/baselines/reference/typeGuardsInProperties.types @@ -33,7 +33,7 @@ class C1 { >strOrNum : string | number >typeof this.pp1 === "string" && this.pp1 : string >typeof this.pp1 === "string" : boolean ->typeof this.pp1 : string +>typeof this.pp1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >this.pp1 : string | number >this : this >pp1 : string | number @@ -47,7 +47,7 @@ class C1 { >strOrNum : string | number >typeof this.pp2 === "string" && this.pp2 : string >typeof this.pp2 === "string" : boolean ->typeof this.pp2 : string +>typeof this.pp2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >this.pp2 : string | number >this : this >pp2 : string | number @@ -61,7 +61,7 @@ class C1 { >strOrNum : string | number >typeof this.pp3 === "string" && this.pp3 : string >typeof this.pp3 === "string" : boolean ->typeof this.pp3 : string +>typeof this.pp3 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >this.pp3 : string | number >this : this >pp3 : string | number @@ -80,7 +80,7 @@ strOrNum = typeof c1.pp2 === "string" && c1.pp2; // string | number >strOrNum : string | number >typeof c1.pp2 === "string" && c1.pp2 : string >typeof c1.pp2 === "string" : boolean ->typeof c1.pp2 : string +>typeof c1.pp2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >c1.pp2 : string | number >c1 : C1 >pp2 : string | number @@ -94,7 +94,7 @@ strOrNum = typeof c1.pp3 === "string" && c1.pp3; // string | number >strOrNum : string | number >typeof c1.pp3 === "string" && c1.pp3 : string >typeof c1.pp3 === "string" : boolean ->typeof c1.pp3 : string +>typeof c1.pp3 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >c1.pp3 : string | number >c1 : C1 >pp3 : string | number @@ -115,7 +115,7 @@ strOrNum = typeof obj1.x === "string" && obj1.x; // string | number >strOrNum : string | number >typeof obj1.x === "string" && obj1.x : string >typeof obj1.x === "string" : boolean ->typeof obj1.x : string +>typeof obj1.x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >obj1.x : string | number >obj1 : { x: string | number; } >x : string | number diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types index 54c1d0270b5b9..7235a1d80c23e 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types +++ b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types @@ -8,7 +8,7 @@ function foo(x: number | string) { return typeof x === "string" && x.length === 10; // string >typeof x === "string" && x.length === 10 : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >x.length === 10 : boolean @@ -25,7 +25,7 @@ function foo2(x: number | string) { return typeof x === "string" && ((x = 10) && x); // string | number >typeof x === "string" && ((x = 10) && x) : number >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >((x = 10) && x) : number @@ -44,7 +44,7 @@ function foo3(x: number | string) { return typeof x === "string" && ((x = "hello") && x); // string | number >typeof x === "string" && ((x = "hello") && x) : string >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >((x = "hello") && x) : string @@ -63,13 +63,13 @@ function foo4(x: number | string | boolean) { >typeof x !== "string" // string | number | boolean && typeof x !== "number" // number | boolean && x : boolean >typeof x !== "string" // string | number | boolean && typeof x !== "number" : boolean >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" && typeof x !== "number" // number | boolean >typeof x !== "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" @@ -87,7 +87,7 @@ function foo5(x: number | string | boolean) { return typeof x !== "string" // string | number | boolean >typeof x !== "string" // string | number | boolean && ((b = x) && (typeof x !== "number" // number | boolean && x)) : boolean >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -101,7 +101,7 @@ function foo5(x: number | string | boolean) { >(typeof x !== "number" // number | boolean && x) : boolean >typeof x !== "number" // number | boolean && x : boolean >typeof x !== "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" @@ -116,7 +116,7 @@ function foo6(x: number | string | boolean) { return typeof x !== "string" // string | number | boolean >typeof x !== "string" // string | number | boolean && (typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -124,7 +124,7 @@ function foo6(x: number | string | boolean) { >(typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean >typeof x !== "number" // number | boolean ? x // boolean : x === 10 : boolean >typeof x !== "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" @@ -150,7 +150,7 @@ function foo7(x: number | string | boolean) { return typeof x !== "string" >typeof x !== "string" && ((z = x) // number | boolean && (typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // x is number // do not change value : ((y = x) && x.toString()))) : string >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -166,7 +166,7 @@ function foo7(x: number | string | boolean) { >(typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // x is number // do not change value : ((y = x) && x.toString())) : string >typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // x is number // do not change value : ((y = x) && x.toString()) : string >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types index e8548ab1ef6b8..d8d807bad7032 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types +++ b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types @@ -9,7 +9,7 @@ function foo(x: number | string) { return typeof x !== "string" || x.length === 10; // string >typeof x !== "string" || x.length === 10 : boolean >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >x.length === 10 : boolean @@ -26,7 +26,7 @@ function foo2(x: number | string) { return typeof x !== "string" || ((x = 10) || x); // string | number >typeof x !== "string" || ((x = 10) || x) : number | true >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >((x = 10) || x) : number @@ -45,7 +45,7 @@ function foo3(x: number | string) { return typeof x !== "string" || ((x = "hello") || x); // string | number >typeof x !== "string" || ((x = "hello") || x) : string | true >typeof x !== "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" >((x = "hello") || x) : string @@ -64,13 +64,13 @@ function foo4(x: number | string | boolean) { >typeof x === "string" // string | number | boolean || typeof x === "number" // number | boolean || x : boolean >typeof x === "string" // string | number | boolean || typeof x === "number" : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" || typeof x === "number" // number | boolean >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" @@ -88,7 +88,7 @@ function foo5(x: number | string | boolean) { return typeof x === "string" // string | number | boolean >typeof x === "string" // string | number | boolean || ((b = x) || (typeof x === "number" // number | boolean || x)) : number | boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -102,7 +102,7 @@ function foo5(x: number | string | boolean) { >(typeof x === "number" // number | boolean || x) : boolean >typeof x === "number" // number | boolean || x : boolean >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" @@ -117,7 +117,7 @@ function foo6(x: number | string | boolean) { return typeof x === "string" // string | number | boolean >typeof x === "string" // string | number | boolean || (typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -125,7 +125,7 @@ function foo6(x: number | string | boolean) { >(typeof x !== "number" // number | boolean ? x // boolean : x === 10) : boolean >typeof x !== "number" // number | boolean ? x // boolean : x === 10 : boolean >typeof x !== "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" @@ -151,7 +151,7 @@ function foo7(x: number | string | boolean) { return typeof x === "string" >typeof x === "string" || ((z = x) // number | boolean || (typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // number | boolean | string // do not change value : ((y = x) && x.toString()))) : string | number | true >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number | boolean >"string" : "string" @@ -167,7 +167,7 @@ function foo7(x: number | string | boolean) { >(typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // number | boolean | string // do not change value : ((y = x) && x.toString())) : string >typeof x === "number" // change value of x ? ((x = 10) && x.toString()) // number | boolean | string // do not change value : ((y = x) && x.toString()) : string >typeof x === "number" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : number | boolean >"number" : "number" diff --git a/tests/baselines/reference/typeGuardsInWhileStatement.types b/tests/baselines/reference/typeGuardsInWhileStatement.types index b0ea7959ec59c..cdcff209c0816 100644 --- a/tests/baselines/reference/typeGuardsInWhileStatement.types +++ b/tests/baselines/reference/typeGuardsInWhileStatement.types @@ -8,7 +8,7 @@ function a(x: string | number) { while (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -29,7 +29,7 @@ function b(x: string | number) { while (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" @@ -53,7 +53,7 @@ function c(x: string | number) { while (typeof x === "string") { >typeof x === "string" : boolean ->typeof x : string +>typeof x : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >x : string | number >"string" : "string" diff --git a/tests/baselines/reference/typeGuardsNestedAssignments.types b/tests/baselines/reference/typeGuardsNestedAssignments.types index 32ac85e270b34..ba26f6c07aa83 100644 --- a/tests/baselines/reference/typeGuardsNestedAssignments.types +++ b/tests/baselines/reference/typeGuardsNestedAssignments.types @@ -103,7 +103,7 @@ function f4() { if (typeof (x = getStringOrNumberOrNull()) === "number") { >typeof (x = getStringOrNumberOrNull()) === "number" : boolean ->typeof (x = getStringOrNumberOrNull()) : string +>typeof (x = getStringOrNumberOrNull()) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >(x = getStringOrNumberOrNull()) : string | number | null >x = getStringOrNumberOrNull() : string | number | null >x : string | number | null diff --git a/tests/baselines/reference/typeGuardsObjectMethods.types b/tests/baselines/reference/typeGuardsObjectMethods.types index 5a795c336e257..4f3e888d76e85 100644 --- a/tests/baselines/reference/typeGuardsObjectMethods.types +++ b/tests/baselines/reference/typeGuardsObjectMethods.types @@ -28,7 +28,7 @@ var obj1 = { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -44,7 +44,7 @@ var obj1 = { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -57,7 +57,7 @@ var obj1 = { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -77,7 +77,7 @@ var obj1 = { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -93,7 +93,7 @@ var obj1 = { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -114,7 +114,7 @@ var obj1 = { >num : number >typeof var1 === "string" && var1.length : number >typeof var1 === "string" : boolean ->typeof var1 : string +>typeof var1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var1 : string | number >"string" : "string" >var1.length : number @@ -130,7 +130,7 @@ var obj1 = { >num : number >typeof var2 === "string" && var2.length : number >typeof var2 === "string" : boolean ->typeof var2 : string +>typeof var2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >var2 : string | number >"string" : "string" >var2.length : number @@ -143,7 +143,7 @@ var obj1 = { >num : number >typeof param === "string" && param.length : number >typeof param === "string" : boolean ->typeof param : string +>typeof param : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >param : string | number >"string" : "string" >param.length : number @@ -157,7 +157,7 @@ strOrNum = typeof obj1.method(strOrNum) === "string" && obj1.method(strOrNum); >strOrNum : string | number >typeof obj1.method(strOrNum) === "string" && obj1.method(strOrNum) : string | number >typeof obj1.method(strOrNum) === "string" : boolean ->typeof obj1.method(strOrNum) : string +>typeof obj1.method(strOrNum) : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >obj1.method(strOrNum) : string | number >obj1.method : (param: string | number) => string | number >obj1 : { method(param: string | number): string | number; prop: string | number; } @@ -176,7 +176,7 @@ strOrNum = typeof obj1.prop === "string" && obj1.prop; >strOrNum : string | number >typeof obj1.prop === "string" && obj1.prop : string >typeof obj1.prop === "string" : boolean ->typeof obj1.prop : string +>typeof obj1.prop : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >obj1.prop : string | number >obj1 : { method(param: string | number): string | number; prop: string | number; } >prop : string | number diff --git a/tests/baselines/reference/typeGuardsOnClassProperty.types b/tests/baselines/reference/typeGuardsOnClassProperty.types index 1b663ef209ff1..f4c3542344f2f 100644 --- a/tests/baselines/reference/typeGuardsOnClassProperty.types +++ b/tests/baselines/reference/typeGuardsOnClassProperty.types @@ -22,7 +22,7 @@ class D { return typeof data === "string" ? data : data.join(" "); >typeof data === "string" ? data : data.join(" ") : string >typeof data === "string" : boolean ->typeof data : string +>typeof data : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >data : string | string[] >"string" : "string" >data : string @@ -39,7 +39,7 @@ class D { return typeof this.data === "string" ? this.data : this.data.join(" "); >typeof this.data === "string" ? this.data : this.data.join(" ") : string >typeof this.data === "string" : boolean ->typeof this.data : string +>typeof this.data : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >this.data : string | string[] >this : this >data : string | string[] @@ -81,7 +81,7 @@ var o: { if (typeof o.prop1 === "string" && o.prop1.toLowerCase()) {} >typeof o.prop1 === "string" && o.prop1.toLowerCase() : string >typeof o.prop1 === "string" : boolean ->typeof o.prop1 : string +>typeof o.prop1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >o.prop1 : string | number >o : { prop1: string | number; prop2: string | boolean; } >prop1 : string | number @@ -102,7 +102,7 @@ var prop1 = o.prop1; if (typeof prop1 === "string" && prop1.toLocaleLowerCase()) { } >typeof prop1 === "string" && prop1.toLocaleLowerCase() : string >typeof prop1 === "string" : boolean ->typeof prop1 : string +>typeof prop1 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" >prop1 : string | number >"string" : "string" >prop1.toLocaleLowerCase() : string diff --git a/tests/baselines/reference/typeOfOperator1.errors.txt b/tests/baselines/reference/typeOfOperator1.errors.txt index 764463a308723..75fc25d243cfb 100644 --- a/tests/baselines/reference/typeOfOperator1.errors.txt +++ b/tests/baselines/reference/typeOfOperator1.errors.txt @@ -1,4 +1,5 @@ -tests/cases/compiler/typeOfOperator1.ts(3,5): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/typeOfOperator1.ts(3,5): error TS2322: Type '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' is not assignable to type 'number'. + Type '"string"' is not assignable to type 'number'. ==== tests/cases/compiler/typeOfOperator1.ts (1 errors) ==== @@ -6,4 +7,5 @@ tests/cases/compiler/typeOfOperator1.ts(3,5): error TS2322: Type 'string' is not var y: string = typeof x; var z: number = typeof x; ~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: Type '"string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function"' is not assignable to type 'number'. +!!! error TS2322: Type '"string"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts index 44b064c321941..92b3103723e57 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfOther.ts @@ -36,6 +36,12 @@ if (typeof boolOrC === "Object") { else { var r4: boolean = boolOrC; // boolean } +if (typeof strOrC === "Object" as string) { // comparison is OK with cast + c = strOrC; // error: but no narrowing to C +} +else { + var r5: string = strOrC; // error: no narrowing to string +} if (typeof strOrNumOrBool === "Object") { let q1: {} = strOrNumOrBool; // {}