From 769a2f2cfc234cc4c83cd36532fb0cbcb14df113 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 19 Apr 2020 20:25:24 -0400 Subject: [PATCH] Eased up on some of the more aggressive reporting changes --- src/compiler/checker.ts | 10 ++++++---- src/testRunner/unittests/tsserver/openFile.ts | 2 +- .../unittests/tsserver/projectReferenceErrors.ts | 4 ++-- ...ccessKeyofReliesOnKeyofNeverUpperBound.errors.txt | 8 ++++---- .../baselines/reference/conditionalTypes1.errors.txt | 12 ++++++------ ...ructorImplementationWithDefaultValues2.errors.txt | 4 ++-- .../reference/derivedGenericClassWithAny.errors.txt | 8 ++++---- .../genericCallWithFunctionTypedArguments.errors.txt | 12 ++++++------ ...ericCallWithGenericSignatureArguments2.errors.txt | 8 ++++---- ...cCallWithObjectTypeArgsAndInitializers.errors.txt | 4 ++-- ...ackInvokedInsideItsContainingFunction1.errors.txt | 4 ++-- ...cClassWithFunctionTypedMemberArguments.errors.txt | 12 ++++++------ .../genericWithOpenTypeParameters1.errors.txt | 4 ++-- .../stringLiteralsWithEqualityChecks03.errors.txt | 8 ++++---- .../stringLiteralsWithEqualityChecks04.errors.txt | 8 ++++---- ...gumentsOnFunctionsWithNoTypeParameters.errors.txt | 4 ++-- 16 files changed, 57 insertions(+), 55 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4fee6c27924..e7b6cb16aa5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4073,9 +4073,6 @@ namespace ts { leftStr = getTypeNameForErrorDisplay(left); rightStr = getTypeNameForErrorDisplay(right); } - else if (isLiteralType(left) && !isLiteralType(right)) { - leftStr = getTypeNameForErrorDisplay(getBaseTypeOfLiteralType(left)) - } return [leftStr, rightStr]; } @@ -15458,6 +15455,7 @@ namespace ts { function reportRelationError(message: DiagnosticMessage | undefined, source: Type, target: Type) { if (incompatibleStack.length) reportIncompatibleStack(); const [sourceType, targetType] = getTypeNamesForErrorDisplay(source, target); + let generalizedSourceType = sourceType; if (target.flags & TypeFlags.TypeParameter) { const constraint = getBaseConstraintOfType(target); @@ -15491,7 +15489,11 @@ namespace ts { } } - reportError(message, sourceType, targetType); + if (isLiteralType(source) && !isLiteralType(target)) { + generalizedSourceType = getTypeNameForErrorDisplay(getBaseTypeOfLiteralType(source)) + } + + reportError(message, generalizedSourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source: Type, target: Type) { diff --git a/src/testRunner/unittests/tsserver/openFile.ts b/src/testRunner/unittests/tsserver/openFile.ts index 52949ab821a..1bc7f10cf9f 100644 --- a/src/testRunner/unittests/tsserver/openFile.ts +++ b/src/testRunner/unittests/tsserver/openFile.ts @@ -175,7 +175,7 @@ bar();` file, syntax: [], semantic: [ - createDiagnostic(locationOfY.start, locationOfY.end, Diagnostics.Type_0_is_not_assignable_to_type_1, ["number", "string"]), + createDiagnostic(locationOfY.start, locationOfY.end, Diagnostics.Type_0_is_not_assignable_to_type_1, ["10", "string"]), ], suggestion: [] }, diff --git a/src/testRunner/unittests/tsserver/projectReferenceErrors.ts b/src/testRunner/unittests/tsserver/projectReferenceErrors.ts index 0fb2f8d883f..9444ccb7a9d 100644 --- a/src/testRunner/unittests/tsserver/projectReferenceErrors.ts +++ b/src/testRunner/unittests/tsserver/projectReferenceErrors.ts @@ -166,7 +166,7 @@ fnErr(); { line: 6, offset: 12 }, { line: 6, offset: 13 }, Diagnostics.Type_0_is_not_assignable_to_type_1, - ["number", "string"], + ["10", "string"], "error", ) ], @@ -235,7 +235,7 @@ fnErr(); { line: 6, offset: 5 }, { line: 6, offset: 6 }, Diagnostics.Type_0_is_not_assignable_to_type_1, - ["number", "string"], + ["10", "string"], "error", ) ], diff --git a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt index 4edd2a5a09b..5276e42c4de 100644 --- a/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt +++ b/tests/baselines/reference/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.errors.txt @@ -10,12 +10,12 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t 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'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. + '"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 'string' is not assignable to type 'T & "text"'. Type 'string' is not assignable to type 'T'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. + '"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 '"text"'. Type '"text" | "email"' is not assignable to type '"text"'. Type '"email"' is not assignable to type '"text"'. @@ -68,12 +68,12 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t !!! 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: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. +!!! 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 'string' is not assignable to type 'T & "text"'. !!! error TS2322: Type 'string' is not assignable to type 'T'. -!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '"text" | "email"'. +!!! 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 '"text"'. !!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'. !!! error TS2322: Type '"email"' is not assignable to type '"text"'. diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt index 16a81ba69c6..e15d0ba769c 100644 --- a/tests/baselines/reference/conditionalTypes1.errors.txt +++ b/tests/baselines/reference/conditionalTypes1.errors.txt @@ -44,11 +44,11 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(159,5): error TS2 Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. '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'. - 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. + '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'. - 'string | number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. + '"" | 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'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. + '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(160,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf'. Type 'string | number' is not assignable to type 'ZeroOf'. Type 'string' is not assignable to type 'ZeroOf'. @@ -284,11 +284,11 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS !!! error TS2322: Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. !!! 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: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. +!!! 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: 'string | number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. +!!! 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: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. +!!! error TS2322: '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. y = x; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'ZeroOf'. diff --git a/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt b/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt index 3d22f3fb320..2cceb88175a 100644 --- a/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt +++ b/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(3,17): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(10,17): error TS2322: Type 'number' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(10,27): error TS2322: Type 'T' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(17,17): error TS2322: Type 'Date' is not assignable to type 'T'. @@ -22,7 +22,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co constructor(x: T = 1, public y: U = x) { // error ~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. !!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. diff --git a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt index 3e717a6d59a..4abd4a4cd09 100644 --- a/tests/baselines/reference/derivedGenericClassWithAny.errors.txt +++ b/tests/baselines/reference/derivedGenericClassWithAny.errors.txt @@ -3,9 +3,9 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type 'string' is not assignable to type 'T'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. + '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,9): error TS2322: Type 'string' is not assignable to type 'T'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. + '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(41,1): error TS2322: Type 'E' is not assignable to type 'C'. Types of property 'x' are incompatible. Type 'string' is not assignable to type 'number'. @@ -52,12 +52,12 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. -!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. +!!! error TS2322: '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. foo(): T { return ''; // error ~~~~~~~~~~ !!! error TS2322: Type 'string' is not assignable to type 'T'. -!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. +!!! error TS2322: '""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'. } } diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt index aef8a5ad372..53ef67b340d 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments.errors.txt @@ -3,15 +3,15 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(30,23): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type 'number' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(33,23): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type 'number' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(34,24): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type 'number' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments.ts(35,23): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'. Type 'string' is not assignable to type '1'. @@ -54,7 +54,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. var r10 = foo2(1, (x) => ''); // string var r11 = foo3(1, (x: T) => '', ''); // error @@ -62,13 +62,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. var r11b = foo3(1, (x: T) => '', 1); // error ~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. var r12 = foo3(1, function (a) { return '' }, 1); // error ~~~~~~~~ !!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'. diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt index 08330d4a586..2e6ced0af86 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt @@ -4,7 +4,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(15,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(16,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(25,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. Types of parameters 'a' and 'x' are incompatible. Type 'Date' is not assignable to type 'T'. @@ -13,7 +13,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(50,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(51,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(60,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. Types of parameters 'a' and 'x' are incompatible. Type 'Date' is not assignable to type 'T'. @@ -48,7 +48,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen var r10 = r7(1); // error ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. } function foo2(a: (x: T) => T, b: (x: T) => T) { @@ -97,7 +97,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen var r10 = r7(1); ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. } function foo2(a: (x: T) => T, b: (x: U) => U) { diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt index 545a8b47a79..b37937c9edb 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(5,33): error TS2322: Type 'number' is not assignable to type 'T'. - 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Number'. + '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(6,37): error TS2322: Type 'T' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(8,56): error TS2322: Type 'U' is not assignable to type 'V'. @@ -16,7 +16,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericC function foo3(x: T = 1) { } // error ~~~~~~~~ !!! error TS2322: Type 'number' is not assignable to type 'T'. -!!! error TS2322: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Number'. +!!! error TS2322: '1' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Number'. function foo4(x: T, y: U = x) { } // error ~~~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. diff --git a/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt b/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt index 25915c23a88..1f179fb3267 100644 --- a/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt +++ b/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(2,16): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(3,16): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(4,16): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(8,17): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(9,17): error TS2558: Expected 0 type arguments, but got 1. @@ -18,7 +18,7 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(14,17 var r2 = f(1); ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. var r3 = f(null); ~~~ !!! error TS2558: Expected 0 type arguments, but got 1. diff --git a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt index 440c8d113cb..db9943c5ba2 100644 --- a/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt +++ b/tests/baselines/reference/genericClassWithFunctionTypedMemberArguments.errors.txt @@ -1,15 +1,15 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(57,29): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type 'number' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(60,30): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type 'number' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(61,31): error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. Types of parameters 'x' and 'a' are incompatible. Type 'number' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFunctionTypedMemberArguments.ts(62,30): error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'. Type 'string' is not assignable to type '1'. @@ -76,7 +76,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFu !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. var r10 = c.foo2(1, (x) => ''); // string var r11 = c3.foo3(1, (x: T) => '', ''); // error @@ -84,13 +84,13 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericClassWithFu !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. var r11b = c3.foo3(1, (x: T) => '', 1); // error ~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T) => string' is not assignable to parameter of type '(a: 1) => string'. !!! error TS2345: Types of parameters 'x' and 'a' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. var r12 = c3.foo3(1, function (a) { return '' }, 1); // error ~~~~~~~~ !!! error TS2345: Argument of type '(a: number) => string' is not assignable to parameter of type '(a: number) => 1'. diff --git a/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt b/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt index f348a0fb974..e8705615424 100644 --- a/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt +++ b/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/genericWithOpenTypeParameters1.ts(7,40): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/compiler/genericWithOpenTypeParameters1.ts(8,41): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/genericWithOpenTypeParameters1.ts(9,41): error TS2558: Expected 0 type arguments, but got 1. @@ -14,7 +14,7 @@ tests/cases/compiler/genericWithOpenTypeParameters1.ts(9,41): error TS2558: Expe var f = (x: B) => { return x.foo(1); } // error ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. var f2 = (x: B) => { return x.foo(1); } // error ~ !!! error TS2558: Expected 0 type arguments, but got 1. diff --git a/tests/baselines/reference/stringLiteralsWithEqualityChecks03.errors.txt b/tests/baselines/reference/stringLiteralsWithEqualityChecks03.errors.txt index f182c6721cf..cbefbbac978 100644 --- a/tests/baselines/reference/stringLiteralsWithEqualityChecks03.errors.txt +++ b/tests/baselines/reference/stringLiteralsWithEqualityChecks03.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts(16,5): error TS2367: This condition will always return 'false' since the types '"foo"' and '"bar"' have no overlap. tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts(19,5): error TS2367: This condition will always return 'false' since the types 'Refrigerator | "foo"' and '"bar"' have no overlap. -tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts(20,5): error TS2367: This condition will always return 'false' since the types 'string' and 'Refrigerator | "foo"' have no overlap. +tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts(20,5): error TS2367: This condition will always return 'false' since the types '"bar"' and 'Refrigerator | "foo"' have no overlap. tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts(25,5): error TS2367: This condition will always return 'true' since the types '"foo"' and '"bar"' have no overlap. tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts(28,5): error TS2367: This condition will always return 'true' since the types 'Refrigerator | "foo"' and '"bar"' have no overlap. -tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts(29,5): error TS2367: This condition will always return 'true' since the types 'string' and 'Refrigerator | "foo"' have no overlap. +tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts(29,5): error TS2367: This condition will always return 'true' since the types '"bar"' and 'Refrigerator | "foo"' have no overlap. ==== tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts (6 errors) ==== @@ -32,7 +32,7 @@ tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts(29,5 !!! error TS2367: This condition will always return 'false' since the types 'Refrigerator | "foo"' and '"bar"' have no overlap. b = "bar" === y; ~~~~~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'Refrigerator | "foo"' have no overlap. +!!! error TS2367: This condition will always return 'false' since the types '"bar"' and 'Refrigerator | "foo"' have no overlap. b = x !== y; b = "foo" !== y @@ -47,5 +47,5 @@ tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks03.ts(29,5 !!! error TS2367: This condition will always return 'true' since the types 'Refrigerator | "foo"' and '"bar"' have no overlap. b = "bar" !== y; ~~~~~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'string' and 'Refrigerator | "foo"' have no overlap. +!!! error TS2367: This condition will always return 'true' since the types '"bar"' and 'Refrigerator | "foo"' have no overlap. \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralsWithEqualityChecks04.errors.txt b/tests/baselines/reference/stringLiteralsWithEqualityChecks04.errors.txt index 3b8e39c3eb4..293abe0b5c5 100644 --- a/tests/baselines/reference/stringLiteralsWithEqualityChecks04.errors.txt +++ b/tests/baselines/reference/stringLiteralsWithEqualityChecks04.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts(16,5): error TS2367: This condition will always return 'false' since the types '"foo"' and '"bar"' have no overlap. tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts(19,5): error TS2367: This condition will always return 'false' since the types 'Refrigerator | "foo"' and '"bar"' have no overlap. -tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts(20,5): error TS2367: This condition will always return 'false' since the types 'string' and 'Refrigerator | "foo"' have no overlap. +tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts(20,5): error TS2367: This condition will always return 'false' since the types '"bar"' and 'Refrigerator | "foo"' have no overlap. tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts(25,5): error TS2367: This condition will always return 'true' since the types '"foo"' and '"bar"' have no overlap. tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts(28,5): error TS2367: This condition will always return 'true' since the types 'Refrigerator | "foo"' and '"bar"' have no overlap. -tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts(29,5): error TS2367: This condition will always return 'true' since the types 'string' and 'Refrigerator | "foo"' have no overlap. +tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts(29,5): error TS2367: This condition will always return 'true' since the types '"bar"' and 'Refrigerator | "foo"' have no overlap. ==== tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts (6 errors) ==== @@ -32,7 +32,7 @@ tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts(29,5 !!! error TS2367: This condition will always return 'false' since the types 'Refrigerator | "foo"' and '"bar"' have no overlap. b = "bar" == y; ~~~~~~~~~~ -!!! error TS2367: This condition will always return 'false' since the types 'string' and 'Refrigerator | "foo"' have no overlap. +!!! error TS2367: This condition will always return 'false' since the types '"bar"' and 'Refrigerator | "foo"' have no overlap. b = x != y; b = "foo" != y @@ -47,5 +47,5 @@ tests/cases/conformance/types/literal/stringLiteralsWithEqualityChecks04.ts(29,5 !!! error TS2367: This condition will always return 'true' since the types 'Refrigerator | "foo"' and '"bar"' have no overlap. b = "bar" != y; ~~~~~~~~~~ -!!! error TS2367: This condition will always return 'true' since the types 'string' and 'Refrigerator | "foo"' have no overlap. +!!! error TS2367: This condition will always return 'true' since the types '"bar"' and 'Refrigerator | "foo"' have no overlap. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt b/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt index c415f5d9a49..5da4df50ef1 100644 --- a/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt +++ b/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(2,15): error TS2558: Expected 0 type arguments, but got 1. tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(3,15): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(4,15): error TS2558: Expected 0 type arguments, but got 1. @@ -12,7 +12,7 @@ tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(4,15): erro var r2 = f(1); ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. -!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to 'number'. +!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'. var r3 = f(null); ~~~ !!! error TS2558: Expected 0 type arguments, but got 1.