From d12b741004bf4cea14875328e605a70a290e41bf Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 20 Apr 2020 23:32:34 -0400 Subject: [PATCH] Excluded type unions from the generale source types --- src/compiler/checker.ts | 2 +- .../reference/bigintIndex.errors.txt | 4 ++-- .../reference/checkJsdocReturnTag2.errors.txt | 8 +++---- .../classPropertyErrorOnNameOnly.errors.txt | 8 +++---- ...yofReliesOnKeyofNeverUpperBound.errors.txt | 12 +++++----- .../reference/conditionalTypes1.errors.txt | 4 ++-- .../controlFlowArrayErrors.errors.txt | 8 +++---- ...tructuringParameterDeclaration2.errors.txt | 4 ++-- ...tructuringParameterDeclaration4.errors.txt | 4 ++-- .../intersectionPropertyCheck.errors.txt | 4 ++-- .../reference/noErrorTruncation.errors.txt | 4 ++-- .../reference/objectCreate-errors.errors.txt | 24 +++++++++---------- .../reference/strictBindCallApply1.errors.txt | 12 +++++----- .../tsxAttributeResolution14.errors.txt | 4 ++-- .../typeFromJSConstructor.errors.txt | 4 ++-- .../typeFromJSInitializer.errors.txt | 4 ++-- .../reference/typeOfOperator1.errors.txt | 4 ++-- 17 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 009c7356ad..1dd9fb9255 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15489,7 +15489,7 @@ namespace ts { } } - if (isLiteralType(source) && !isLiteralType(target)) { + if (isLiteralType(source) && !(source.flags & TypeFlags.Union) && !isLiteralType(target) && !(target.flags & TypeFlags.Union)) { generalizedSourceType = getTypeNameForErrorDisplay(getBaseTypeOfLiteralType(source)); } diff --git a/tests/baselines/reference/bigintIndex.errors.txt b/tests/baselines/reference/bigintIndex.errors.txt index 216e2d4857..daf9fa7562 100644 --- a/tests/baselines/reference/bigintIndex.errors.txt +++ b/tests/baselines/reference/bigintIndex.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/a.ts(2,6): error TS1023: An index signature parameter type must be either 'string' or 'number'. tests/cases/compiler/a.ts(8,11): error TS2538: Type '1n' cannot be used as an index type. -tests/cases/compiler/a.ts(14,1): error TS2322: Type 'bigint' is not assignable to type 'string | number | symbol'. +tests/cases/compiler/a.ts(14,1): error TS2322: Type '123n' is not assignable to type 'string | number | symbol'. tests/cases/compiler/a.ts(19,12): error TS2538: Type 'bigint' cannot be used as an index type. tests/cases/compiler/b.ts(2,12): error TS1136: Property assignment expected. tests/cases/compiler/b.ts(2,14): error TS1005: ';' expected. @@ -29,7 +29,7 @@ tests/cases/compiler/b.ts(4,12): error TS2464: A computed property name must be key = Symbol(); key = 123n; // should error ~~~ -!!! error TS2322: Type 'bigint' is not assignable to type 'string | number | symbol'. +!!! error TS2322: Type '123n' is not assignable to type 'string | number | symbol'. // Show correct usage of bigint index: explicitly convert to string const bigNum: bigint = 0n; diff --git a/tests/baselines/reference/checkJsdocReturnTag2.errors.txt b/tests/baselines/reference/checkJsdocReturnTag2.errors.txt index 8ff291f2e5..fcc4f25694 100644 --- a/tests/baselines/reference/checkJsdocReturnTag2.errors.txt +++ b/tests/baselines/reference/checkJsdocReturnTag2.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/jsdoc/returns.js(6,5): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/jsdoc/returns.js(13,5): error TS2322: Type 'number | boolean' is not assignable to type 'string | number'. - Type 'boolean' is not assignable to type 'string | number'. +tests/cases/conformance/jsdoc/returns.js(13,5): error TS2322: Type 'true | 5' is not assignable to type 'string | number'. + Type 'true' is not assignable to type 'string | number'. ==== tests/cases/conformance/jsdoc/returns.js (2 errors) ==== @@ -20,6 +20,6 @@ tests/cases/conformance/jsdoc/returns.js(13,5): error TS2322: Type 'number | boo function f1() { return 5 || true; ~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'number | boolean' is not assignable to type 'string | number'. -!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'. +!!! error TS2322: Type 'true | 5' is not assignable to type 'string | number'. +!!! error TS2322: Type 'true' is not assignable to type 'string | number'. } \ No newline at end of file diff --git a/tests/baselines/reference/classPropertyErrorOnNameOnly.errors.txt b/tests/baselines/reference/classPropertyErrorOnNameOnly.errors.txt index 6a7e077de4..7ef791997d 100644 --- a/tests/baselines/reference/classPropertyErrorOnNameOnly.errors.txt +++ b/tests/baselines/reference/classPropertyErrorOnNameOnly.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/classPropertyErrorOnNameOnly.ts(7,3): error TS2322: Type '(val: Values) => "1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'FuncType'. - Type 'string | undefined' is not assignable to type 'string'. + Type '"1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. tests/cases/compiler/classPropertyErrorOnNameOnly.ts(24,7): error TS2322: Type '(val: Values) => "1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'FuncType'. - Type 'string | undefined' is not assignable to type 'string'. + Type '"1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'string'. Type 'undefined' is not assignable to type 'string'. @@ -16,7 +16,7 @@ tests/cases/compiler/classPropertyErrorOnNameOnly.ts(24,7): error TS2322: Type ' insideClass: FuncType = function(val) { // error span goes from here ~~~~~~~~~~~ !!! error TS2322: Type '(val: Values) => "1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'FuncType'. -!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type '"1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'string'. !!! error TS2322: Type 'undefined' is not assignable to type 'string'. switch (val) { case 1: @@ -37,7 +37,7 @@ tests/cases/compiler/classPropertyErrorOnNameOnly.ts(24,7): error TS2322: Type ' const outsideClass: FuncType = function(val) { // compare to errors only on this line in this case ~~~~~~~~~~~~ !!! error TS2322: Type '(val: Values) => "1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'FuncType'. -!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type '"1" | "2" | "3" | "4" | "5" | undefined' is not assignable to type 'string'. !!! error TS2322: Type 'undefined' is not assignable to type 'string'. switch (val) { case 1: diff --git a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt index 5276e42c4d..0fffac781b 100644 --- a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt +++ b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt @@ -2,17 +2,17 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t Type '{ type: T; localChannelId: string; }' is not assignable to type 'Pick | ChannelOfType, "type">'. Types of property 'type' are incompatible. Type 'T' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. - Type 'string' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. + Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. Type 'string' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. Type 'string' is not assignable to type 'ChannelOfType["type"]'. Type 'T' is not assignable to type 'ChannelOfType["type"]'. - Type 'string' is not assignable to type 'ChannelOfType["type"]'. + Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"]'. Type 'string' is not assignable to type 'ChannelOfType["type"]'. Type 'string' is not assignable to type 'T & "text"'. Type 'string' is not assignable to type 'T'. '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. Type 'T' is not assignable to type 'T & "text"'. - Type 'string' is not assignable to type 'T & "text"'. + Type '"text" | "email"' is not assignable to type 'T & "text"'. Type 'string' is not assignable to type 'T & "text"'. Type 'string' is not assignable to type 'T'. '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. @@ -60,17 +60,17 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t !!! error TS2322: Type '{ type: T; localChannelId: string; }' is not assignable to type 'Pick | ChannelOfType, "type">'. !!! error TS2322: Types of property 'type' are incompatible. !!! error TS2322: Type 'T' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. -!!! error TS2322: Type 'string' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. +!!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. !!! error TS2322: Type 'string' is not assignable to type 'ChannelOfType["type"] & ChannelOfType["type"]'. !!! error TS2322: Type 'string' is not assignable to type 'ChannelOfType["type"]'. !!! error TS2322: Type 'T' is not assignable to type 'ChannelOfType["type"]'. -!!! error TS2322: Type 'string' is not assignable to type 'ChannelOfType["type"]'. +!!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType["type"]'. !!! error TS2322: Type 'string' is not assignable to type 'ChannelOfType["type"]'. !!! error TS2322: Type 'string' is not assignable to type 'T & "text"'. !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. !!! error TS2322: Type 'T' is not assignable to type 'T & "text"'. -!!! error TS2322: Type 'string' is not assignable to type 'T & "text"'. +!!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'. !!! error TS2322: Type 'string' is not assignable to type 'T & "text"'. !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: '"text"' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt index e15d0ba769..f4175aa793 100644 --- a/tests/baselines/reference/conditionalTypes1.errors.txt +++ b/tests/baselines/reference/conditionalTypes1.errors.txt @@ -45,7 +45,7 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(159,5): error TS2 'T' could be instantiated with an arbitrary type which could be unrelated to '0 | (T extends string ? "" : false)'. Type 'number' is not assignable to type 'T'. '0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. - Type 'string | number' is not assignable to type 'T'. + Type '"" | 0' is not assignable to type 'T'. '"" | 0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. Type 'string' is not assignable to type 'T'. '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. @@ -285,7 +285,7 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to '0 | (T extends string ? "" : false)'. !!! error TS2322: Type 'number' is not assignable to type 'T'. !!! error TS2322: '0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'T'. +!!! error TS2322: Type '"" | 0' is not assignable to type 'T'. !!! error TS2322: '"" | 0' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. !!! error TS2322: Type 'string' is not assignable to type 'T'. !!! error TS2322: '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. diff --git a/tests/baselines/reference/controlFlowArrayErrors.errors.txt b/tests/baselines/reference/controlFlowArrayErrors.errors.txt index 91ff3032c6..317dba264e 100644 --- a/tests/baselines/reference/controlFlowArrayErrors.errors.txt +++ b/tests/baselines/reference/controlFlowArrayErrors.errors.txt @@ -4,8 +4,8 @@ tests/cases/compiler/controlFlowArrayErrors.ts(11,9): error TS7034: Variable 'x' tests/cases/compiler/controlFlowArrayErrors.ts(13,13): error TS7005: Variable 'x' implicitly has an 'any[]' type. tests/cases/compiler/controlFlowArrayErrors.ts(19,9): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. tests/cases/compiler/controlFlowArrayErrors.ts(22,9): error TS7005: Variable 'x' implicitly has an 'any[]' type. -tests/cases/compiler/controlFlowArrayErrors.ts(29,12): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. -tests/cases/compiler/controlFlowArrayErrors.ts(34,12): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. +tests/cases/compiler/controlFlowArrayErrors.ts(29,12): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. +tests/cases/compiler/controlFlowArrayErrors.ts(34,12): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. tests/cases/compiler/controlFlowArrayErrors.ts(48,12): error TS2345: Argument of type 'number' is not assignable to parameter of type 'never'. tests/cases/compiler/controlFlowArrayErrors.ts(56,12): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/compiler/controlFlowArrayErrors.ts(60,11): error TS7034: Variable 'x' implicitly has type 'any[]' in some locations where its type cannot be determined. @@ -55,14 +55,14 @@ tests/cases/compiler/controlFlowArrayErrors.ts(63,9): error TS7005: Variable 'x' x = [5, "hello"]; // Non-evolving array x.push(true); // Error ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. } function f5() { let x = [5, "hello"]; // Non-evolving array x.push(true); // Error ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. } function f6() { diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt index 12beead1af..b959911266 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -13,7 +13,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( Property 'z' is missing in type '{}' but required in type '{ z: number; }'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(36,6): error TS2322: Type 'boolean' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(37,6): error TS2322: Type 'boolean' is not assignable to type 'number'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,6): error TS2322: Type 'boolean' is not assignable to type 'string | number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(38,6): error TS2322: Type 'true' is not assignable to type 'string | number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(39,11): error TS2322: Type 'boolean' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,13): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(46,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. @@ -98,7 +98,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( !!! error TS2322: Type 'boolean' is not assignable to type 'number'. c3({ b: true }); // Error, implied type is { b: number|string }. ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'. +!!! error TS2322: Type 'true' is not assignable to type 'string | number'. !!! related TS6500 tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts:29:20: The expected type comes from property 'b' which is declared here on type '{ b: string | number; }' c5([1, 2, false, true]); // Error, implied type is [any, any, [[any]]] ~~~~~ diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index 98a9ff93f7..1f7d1b48d6 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(14,17): error TS1047: A rest parameter cannot be optional. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(15,16): error TS1048: A rest parameter cannot have an initializer. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2552: Cannot find name 'array2'. Did you mean 'Array'? tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,11): error TS2322: Type 'string' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(23,4): error TS2345: Argument of type '[number, number]' is not assignable to parameter of type '[any, any, [[any]]]'. @@ -37,7 +37,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( a1(1, 2, "hello", true); // Error, parameter type is (number|string)[] ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. a1(...array2); // Error parameter type is (number|string)[] ~~~~~~ !!! error TS2552: Cannot find name 'array2'. Did you mean 'Array'? diff --git a/tests/baselines/reference/intersectionPropertyCheck.errors.txt b/tests/baselines/reference/intersectionPropertyCheck.errors.txt index 568c3a82ad..7c74c3512e 100644 --- a/tests/baselines/reference/intersectionPropertyCheck.errors.txt +++ b/tests/baselines/reference/intersectionPropertyCheck.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/intersectionPropertyCheck.ts(4,5): error TS2322: Type '{ a: tests/cases/compiler/intersectionPropertyCheck.ts(7,3): error TS2322: Type 'T & { a: boolean; }' is not assignable to type '{ a?: string | undefined; }'. Types of property 'a' are incompatible. Type 'boolean' is not assignable to type 'string | undefined'. -tests/cases/compiler/intersectionPropertyCheck.ts(17,22): error TS2322: Type 'boolean' is not assignable to type 'string[] | undefined'. +tests/cases/compiler/intersectionPropertyCheck.ts(17,22): error TS2322: Type 'true' is not assignable to type 'string[] | undefined'. ==== tests/cases/compiler/intersectionPropertyCheck.ts (4 errors) ==== @@ -40,7 +40,7 @@ tests/cases/compiler/intersectionPropertyCheck.ts(17,22): error TS2322: Type 'bo function test(value: T): Test { return { ...value, hi: true } ~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string[] | undefined'. +!!! error TS2322: Type 'true' is not assignable to type 'string[] | undefined'. !!! related TS6500 tests/cases/compiler/intersectionPropertyCheck.ts:13:12: The expected type comes from property 'hi' which is declared here on type 'Test' } \ No newline at end of file diff --git a/tests/baselines/reference/noErrorTruncation.errors.txt b/tests/baselines/reference/noErrorTruncation.errors.txt index 0bc6d295c0..d5244df81a 100644 --- a/tests/baselines/reference/noErrorTruncation.errors.txt +++ b/tests/baselines/reference/noErrorTruncation.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/noErrorTruncation.ts(10,7): error TS2322: Type 'number' is not assignable to type 'SomeLongOptionA | SomeLongOptionB | SomeLongOptionC | SomeLongOptionD | SomeLongOptionE | SomeLongOptionF'. +tests/cases/compiler/noErrorTruncation.ts(10,7): error TS2322: Type '42' is not assignable to type 'SomeLongOptionA | SomeLongOptionB | SomeLongOptionC | SomeLongOptionD | SomeLongOptionE | SomeLongOptionF'. ==== tests/cases/compiler/noErrorTruncation.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/noErrorTruncation.ts(10,7): error TS2322: Type 'number' is const x: SomeLongOptionA ~ -!!! error TS2322: Type 'number' is not assignable to type 'SomeLongOptionA | SomeLongOptionB | SomeLongOptionC | SomeLongOptionD | SomeLongOptionE | SomeLongOptionF'. +!!! error TS2322: Type '42' is not assignable to type 'SomeLongOptionA | SomeLongOptionB | SomeLongOptionC | SomeLongOptionD | SomeLongOptionE | SomeLongOptionF'. | SomeLongOptionB | SomeLongOptionC | SomeLongOptionD diff --git a/tests/baselines/reference/objectCreate-errors.errors.txt b/tests/baselines/reference/objectCreate-errors.errors.txt index 7303795d93..12f62cc4d2 100644 --- a/tests/baselines/reference/objectCreate-errors.errors.txt +++ b/tests/baselines/reference/objectCreate-errors.errors.txt @@ -1,23 +1,23 @@ -tests/cases/compiler/objectCreate-errors.ts(1,24): error TS2345: Argument of type 'number' is not assignable to parameter of type 'object | null'. -tests/cases/compiler/objectCreate-errors.ts(2,24): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object | null'. -tests/cases/compiler/objectCreate-errors.ts(3,24): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(1,24): error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(2,24): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(3,24): error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. tests/cases/compiler/objectCreate-errors.ts(4,24): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. -tests/cases/compiler/objectCreate-errors.ts(7,24): error TS2345: Argument of type 'number' is not assignable to parameter of type 'object | null'. -tests/cases/compiler/objectCreate-errors.ts(8,24): error TS2345: Argument of type 'string' is not assignable to parameter of type 'object | null'. -tests/cases/compiler/objectCreate-errors.ts(9,24): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(7,24): error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(8,24): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. +tests/cases/compiler/objectCreate-errors.ts(9,24): error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. tests/cases/compiler/objectCreate-errors.ts(10,24): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. ==== tests/cases/compiler/objectCreate-errors.ts (8 errors) ==== var e1 = Object.create(1); // Error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'object | null'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. var e2 = Object.create("string"); // Error ~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object | null'. +!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. var e3 = Object.create(false); // Error ~~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object | null'. +!!! error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. var e4 = Object.create(undefined); // Error ~~~~~~~~~ !!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. @@ -25,13 +25,13 @@ tests/cases/compiler/objectCreate-errors.ts(10,24): error TS2345: Argument of ty var e5 = Object.create(1, {}); // Error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'object | null'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'object | null'. var e6 = Object.create("string", {}); // Error ~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'object | null'. +!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'object | null'. var e7 = Object.create(false, {}); // Error ~~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'object | null'. +!!! error TS2345: Argument of type 'false' is not assignable to parameter of type 'object | null'. var e8 = Object.create(undefined, {}); // Error ~~~~~~~~~ !!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'object | null'. \ No newline at end of file diff --git a/tests/baselines/reference/strictBindCallApply1.errors.txt b/tests/baselines/reference/strictBindCallApply1.errors.txt index 7996f2807c..8b5518e958 100644 --- a/tests/baselines/reference/strictBindCallApply1.errors.txt +++ b/tests/baselines/reference/strictBindCallApply1.errors.txt @@ -4,7 +4,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(11,11): error TS2769: Overload 2 of 6, '(this: (this: undefined, ...args: (10 | 20)[]) => string, thisArg: undefined, ...args: (10 | 20)[]): (...args: (10 | 20)[]) => string', gave the following error. The 'this' context of type '(a: number, b: string) => string' is not assignable to method's 'this' of type '(this: undefined, ...args: (10 | 20)[]) => string'. Types of parameters 'b' and 'args' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '10 | 20' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/functions/strictBindCallApply1.ts(17,15): error TS2554: Expected 3 arguments, but got 2. tests/cases/conformance/functions/strictBindCallApply1.ts(18,35): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. @@ -21,7 +21,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(41,11): error TS2769: Overload 2 of 6, '(this: (this: C, ...args: (10 | 20)[]) => string, thisArg: C, ...args: (10 | 20)[]): (...args: (10 | 20)[]) => string', gave the following error. The 'this' context of type '(this: C, a: number, b: string) => string' is not assignable to method's 'this' of type '(this: C, ...args: (10 | 20)[]) => string'. Types of parameters 'b' and 'args' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '10 | 20' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/functions/strictBindCallApply1.ts(42,11): error TS2769: No overload matches this call. Overload 1 of 6, '(this: (this: C, a: number, b: string) => string, thisArg: C): (a: number, b: string) => string', gave the following error. @@ -45,7 +45,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(62,11): error TS2769: Overload 2 of 6, '(this: new (...args: (10 | 20)[]) => C, thisArg: any, ...args: (10 | 20)[]): new (...args: (10 | 20)[]) => C', gave the following error. The 'this' context of type 'typeof C' is not assignable to method's 'this' of type 'new (...args: (10 | 20)[]) => C'. Types of parameters 'b' and 'args' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '10 | 20' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/functions/strictBindCallApply1.ts(65,3): error TS2554: Expected 3 arguments, but got 2. tests/cases/conformance/functions/strictBindCallApply1.ts(66,15): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. @@ -74,7 +74,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345: !!! error TS2769: Overload 2 of 6, '(this: (this: undefined, ...args: (10 | 20)[]) => string, thisArg: undefined, ...args: (10 | 20)[]): (...args: (10 | 20)[]) => string', gave the following error. !!! error TS2769: The 'this' context of type '(a: number, b: string) => string' is not assignable to method's 'this' of type '(this: undefined, ...args: (10 | 20)[]) => string'. !!! error TS2769: Types of parameters 'b' and 'args' are incompatible. -!!! error TS2769: Type 'number' is not assignable to type 'string'. +!!! error TS2769: Type '10 | 20' is not assignable to type 'string'. !!! error TS2769: Type 'number' is not assignable to type 'string'. let f04 = overloaded.bind(undefined); // typeof overloaded @@ -128,7 +128,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345: !!! error TS2769: Overload 2 of 6, '(this: (this: C, ...args: (10 | 20)[]) => string, thisArg: C, ...args: (10 | 20)[]): (...args: (10 | 20)[]) => string', gave the following error. !!! error TS2769: The 'this' context of type '(this: C, a: number, b: string) => string' is not assignable to method's 'this' of type '(this: C, ...args: (10 | 20)[]) => string'. !!! error TS2769: Types of parameters 'b' and 'args' are incompatible. -!!! error TS2769: Type 'number' is not assignable to type 'string'. +!!! error TS2769: Type '10 | 20' is not assignable to type 'string'. !!! error TS2769: Type 'number' is not assignable to type 'string'. let f14 = c.foo.bind(undefined); // Error ~~~~~~~~~~~~~~~~~~~~~ @@ -183,7 +183,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345: !!! error TS2769: Overload 2 of 6, '(this: new (...args: (10 | 20)[]) => C, thisArg: any, ...args: (10 | 20)[]): new (...args: (10 | 20)[]) => C', gave the following error. !!! error TS2769: The 'this' context of type 'typeof C' is not assignable to method's 'this' of type 'new (...args: (10 | 20)[]) => C'. !!! error TS2769: Types of parameters 'b' and 'args' are incompatible. -!!! error TS2769: Type 'number' is not assignable to type 'string'. +!!! error TS2769: Type '10 | 20' is not assignable to type 'string'. !!! error TS2769: Type 'number' is not assignable to type 'string'. C.call(c, 10, "hello"); diff --git a/tests/baselines/reference/tsxAttributeResolution14.errors.txt b/tests/baselines/reference/tsxAttributeResolution14.errors.txt index 84fa778968..71b5e329f4 100644 --- a/tests/baselines/reference/tsxAttributeResolution14.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution14.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/jsx/file.tsx(13,28): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/jsx/file.tsx(15,28): error TS2322: Type 'boolean' is not assignable to type 'string | number'. +tests/cases/conformance/jsx/file.tsx(15,28): error TS2322: Type 'true' is not assignable to type 'string | number'. ==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== @@ -31,7 +31,7 @@ tests/cases/conformance/jsx/file.tsx(15,28): error TS2322: Type 'boolean' is not // ok // error ~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'. +!!! error TS2322: Type 'true' is not assignable to type 'string | number'. !!! related TS6501 tests/cases/conformance/jsx/file.tsx:3:3: The expected type comes from this index signature. ) diff --git a/tests/baselines/reference/typeFromJSConstructor.errors.txt b/tests/baselines/reference/typeFromJSConstructor.errors.txt index 9124b5044d..9a883a7b4a 100644 --- a/tests/baselines/reference/typeFromJSConstructor.errors.txt +++ b/tests/baselines/reference/typeFromJSConstructor.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/salsa/a.js(10,5): error TS7008: Member 'twices' implicit tests/cases/conformance/salsa/a.js(14,5): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/salsa/a.js(21,5): error TS2322: Type 'boolean' is not assignable to type 'number'. tests/cases/conformance/salsa/a.js(24,5): error TS2322: Type 'null' is not assignable to type 'string | undefined'. -tests/cases/conformance/salsa/a.js(25,5): error TS2322: Type 'boolean' is not assignable to type 'string | undefined'. +tests/cases/conformance/salsa/a.js(25,5): error TS2322: Type 'false' is not assignable to type 'string | undefined'. tests/cases/conformance/salsa/a.js(26,5): error TS2531: Object is possibly 'null'. @@ -41,7 +41,7 @@ tests/cases/conformance/salsa/a.js(26,5): error TS2531: Object is possibly 'null !!! error TS2322: Type 'null' is not assignable to type 'string | undefined'. this.twice = false // error ~~~~~~~~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string | undefined'. +!!! error TS2322: Type 'false' is not assignable to type 'string | undefined'. this.twices.push(1) // error: Object is possibly null ~~~~~~~~~~~ !!! error TS2531: Object is possibly 'null'. diff --git a/tests/baselines/reference/typeFromJSInitializer.errors.txt b/tests/baselines/reference/typeFromJSInitializer.errors.txt index 91ab058fac..08d66a2a9f 100644 --- a/tests/baselines/reference/typeFromJSInitializer.errors.txt +++ b/tests/baselines/reference/typeFromJSInitializer.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/salsa/a.js(4,5): error TS7008: Member 'unknowable' impli tests/cases/conformance/salsa/a.js(5,5): error TS7008: Member 'empty' implicitly has an 'any[]' type. tests/cases/conformance/salsa/a.js(25,12): error TS7006: Parameter 'a' implicitly has an 'any' type. tests/cases/conformance/salsa/a.js(25,29): error TS7006: Parameter 'l' implicitly has an 'any[]' type. -tests/cases/conformance/salsa/a.js(37,5): error TS2322: Type 'string' is not assignable to type 'number | undefined'. +tests/cases/conformance/salsa/a.js(37,5): error TS2322: Type '"error"' is not assignable to type 'number | undefined'. ==== tests/cases/conformance/salsa/a.js (6 errors) ==== @@ -55,7 +55,7 @@ tests/cases/conformance/salsa/a.js(37,5): error TS2322: Type 'string' is not ass b = undefined b = 'error' ~ -!!! error TS2322: Type 'string' is not assignable to type 'number | undefined'. +!!! error TS2322: Type '"error"' is not assignable to type 'number | undefined'. // l should be any[] l.push(1) diff --git a/tests/baselines/reference/typeOfOperator1.errors.txt b/tests/baselines/reference/typeOfOperator1.errors.txt index 6349e2b4ee..b83f1c01de 100644 --- a/tests/baselines/reference/typeOfOperator1.errors.txt +++ b/tests/baselines/reference/typeOfOperator1.errors.txt @@ -1,4 +1,4 @@ -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" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"' is not assignable to type 'number'. Type 'string' is not assignable to type 'number'. @@ -7,5 +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'. +!!! error TS2322: Type '"string" | "number" | "bigint" | "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