I did everything you said I followed all the rules
This commit is contained in:
parent
99cdb64839
commit
d4825ab90f
|
@ -15489,13 +15489,23 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
if (isLiteralType(source) && !forEachType(target, isUnitType)) {
|
||||
if (isLiteralType(source) && !typeCouldHaveNoTopLevelSingletonTypes(target)) {
|
||||
generalizedSourceType = getTypeNameForErrorDisplay(getBaseTypeOfLiteralType(source));
|
||||
}
|
||||
|
||||
reportError(message, generalizedSourceType, targetType);
|
||||
}
|
||||
|
||||
function typeCouldHaveNoTopLevelSingletonTypes(type: Type) {
|
||||
return forEachType(type, typeCouldHaveNoTopLevelSingletonTypesWorker);
|
||||
}
|
||||
|
||||
function typeCouldHaveNoTopLevelSingletonTypesWorker(type: Type): boolean {
|
||||
return (type.flags & TypeFlags.Intersection)
|
||||
? !!forEach((type as IntersectionType).types, typeCouldHaveNoTopLevelSingletonTypesWorker)
|
||||
: isUnitType(type) || !!(type.flags & TypeFlags.Instantiable);
|
||||
}
|
||||
|
||||
function tryElaborateErrorsForPrimitivesAndObjects(source: Type, target: Type) {
|
||||
const sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
|
||||
const targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
|
||||
|
|
|
@ -2,19 +2,19 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t
|
|||
Type '{ type: T; localChannelId: string; }' is not assignable to type 'Pick<ChannelOfType<T, TextChannel> | ChannelOfType<T, EmailChannel>, "type">'.
|
||||
Types of property 'type' are incompatible.
|
||||
Type 'T' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
|
||||
Type 'string' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
|
||||
Type 'string' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
|
||||
Type 'string' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
|
||||
Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
|
||||
Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
Type 'T' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
Type 'string' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
Type 'string' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
Type 'string' is not assignable to type 'T & "text"'.
|
||||
Type 'string' is not assignable to type 'T'.
|
||||
Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
Type '"text"' is not assignable to type 'T & "text"'.
|
||||
Type '"text"' 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 'string' is not assignable to type 'T & "text"'.
|
||||
Type 'string' is not assignable to type 'T'.
|
||||
Type '"text" | "email"' is not assignable to type 'T & "text"'.
|
||||
Type '"text"' is not assignable to type 'T & "text"'.
|
||||
Type '"text"' 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 '"text"'.
|
||||
Type '"text" | "email"' is not assignable to type '"text"'.
|
||||
|
@ -60,19 +60,19 @@ tests/cases/compiler/complicatedIndexedAccessKeyofReliesOnKeyofNeverUpperBound.t
|
|||
!!! error TS2322: Type '{ type: T; localChannelId: string; }' is not assignable to type 'Pick<ChannelOfType<T, TextChannel> | ChannelOfType<T, EmailChannel>, "type">'.
|
||||
!!! error TS2322: Types of property 'type' are incompatible.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
!!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
|
||||
!!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"] & ChannelOfType<T, EmailChannel>["type"]'.
|
||||
!!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
!!! error TS2322: Type 'T' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'T & "text"'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '"text" | "email"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
!!! error TS2322: Type '"text"' is not assignable to type 'ChannelOfType<T, TextChannel>["type"]'.
|
||||
!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'.
|
||||
!!! error TS2322: Type '"text"' 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 'string' is not assignable to type 'T & "text"'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '"text" | "email"' is not assignable to type 'T & "text"'.
|
||||
!!! error TS2322: Type '"text"' is not assignable to type 'T & "text"'.
|
||||
!!! error TS2322: Type '"text"' 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 '"text"'.
|
||||
!!! error TS2322: Type '"text" | "email"' is not assignable to type '"text"'.
|
||||
|
|
|
@ -43,11 +43,11 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(159,5): error TS2
|
|||
'ZeroOf<T>' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'.
|
||||
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'.
|
||||
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 | 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'.
|
||||
Type '""' 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'.
|
||||
tests/cases/conformance/types/conditional/conditionalTypes1.ts(160,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf<T>'.
|
||||
Type 'string | number' is not assignable to type 'ZeroOf<T>'.
|
||||
|
@ -283,11 +283,11 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS
|
|||
!!! error TS2322: 'ZeroOf<T>' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'.
|
||||
!!! 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: 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 | 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: Type '""' 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'.
|
||||
y = x; // Error
|
||||
~
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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'.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(10,17): error TS2322: Type '1' is not assignable to type 'T'.
|
||||
'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'.
|
||||
|
@ -21,7 +21,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co
|
|||
constructor(x: T, y: U);
|
||||
constructor(x: T = 1, public y: U = x) { // error
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '1' is not assignable to type 'T'.
|
||||
!!! 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'.
|
||||
|
|
|
@ -2,9 +2,9 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC
|
|||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
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'.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type '""' 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'.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,9): error TS2322: Type 'string' is not assignable to type 'T'.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(32,9): error TS2322: Type '""' 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'.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(41,1): error TS2322: Type 'E<string>' is not assignable to type 'C<number>'.
|
||||
Types of property 'x' are incompatible.
|
||||
|
@ -51,12 +51,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: Type '""' 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'.
|
||||
foo(): T {
|
||||
return ''; // error
|
||||
~~~~~~~~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '""' 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'.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,15 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun
|
|||
Type 'string' is not assignable to type '1'.
|
||||
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'.
|
||||
Type '1' is not assignable to type 'T'.
|
||||
'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'.
|
||||
Type '1' is not assignable to type 'T'.
|
||||
'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'.
|
||||
Type '1' is not assignable to type 'T'.
|
||||
'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'.
|
||||
|
@ -53,7 +53,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: Type '1' is not assignable to type 'T'.
|
||||
!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'.
|
||||
var r10 = foo2(1, (x) => ''); // string
|
||||
|
||||
|
@ -61,13 +61,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: Type '1' is not assignable to type 'T'.
|
||||
!!! 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: Type '1' is not assignable to type 'T'.
|
||||
!!! 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
|
||||
~~~~~~~~
|
||||
|
|
|
@ -3,7 +3,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen
|
|||
Type 'number' is not assignable to type 'string'.
|
||||
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'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(16,22): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
|
||||
'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.
|
||||
|
@ -12,7 +12,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen
|
|||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(37,43): error TS2322: Type 'F' is not assignable to type 'E'.
|
||||
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'.
|
||||
tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(51,22): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
|
||||
'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.
|
||||
|
@ -47,7 +47,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen
|
|||
!!! error TS2345: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
var r10 = r7(1); // error
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
|
||||
!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
|
||||
!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'.
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen
|
|||
!!! error TS2345: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
var r10 = r7(1);
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
|
||||
!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
|
||||
!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'.
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(5,33): error TS2322: Type 'number' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(5,33): error TS2322: Type '1' is not assignable to type 'T'.
|
||||
'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'.
|
||||
|
@ -15,7 +15,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericC
|
|||
function foo2<T>(x: T = undefined) { return x; } // ok
|
||||
function foo3<T extends Number>(x: T = 1) { } // error
|
||||
~~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'T'.
|
||||
!!! error TS2322: Type '1' is not assignable to type 'T'.
|
||||
!!! 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<T, U extends T>(x: T, y: U = x) { } // error
|
||||
~~~~~~~~
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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'.
|
||||
tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(3,16): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
|
||||
'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.
|
||||
|
@ -17,7 +17,7 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(14,17
|
|||
!!! error TS2558: Expected 0 type arguments, but got 1.
|
||||
var r2 = f(1);
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
|
||||
!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
|
||||
!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'.
|
||||
var r3 = f<any>(null);
|
||||
~~~
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
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'.
|
||||
Type '1' is not assignable to type 'T'.
|
||||
'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'.
|
||||
Type '1' is not assignable to type 'T'.
|
||||
'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'.
|
||||
Type '1' is not assignable to type 'T'.
|
||||
'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'.
|
||||
|
@ -75,7 +75,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: Type '1' is not assignable to type 'T'.
|
||||
!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'.
|
||||
var r10 = c.foo2(1, (x) => ''); // string
|
||||
|
||||
|
@ -83,13 +83,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: Type '1' is not assignable to type 'T'.
|
||||
!!! 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: Type '1' is not assignable to type 'T'.
|
||||
!!! 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
|
||||
~~~~~~~~
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
tests/cases/compiler/genericWithOpenTypeParameters1.ts(7,40): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
|
||||
tests/cases/compiler/genericWithOpenTypeParameters1.ts(7,40): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
|
||||
'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.
|
||||
|
@ -13,7 +13,7 @@ tests/cases/compiler/genericWithOpenTypeParameters1.ts(9,41): error TS2558: Expe
|
|||
x.foo(1); // no error
|
||||
var f = <T>(x: B<T>) => { return x.foo(1); } // error
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
|
||||
!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
|
||||
!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'.
|
||||
var f2 = <T>(x: B<T>) => { return x.foo<T>(1); } // error
|
||||
~
|
||||
|
|
|
@ -12,19 +12,19 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(18,5): error TS232
|
|||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(19,5): error TS2322: Type '{ [key: string]: number; }' is not assignable to type 'T'.
|
||||
'{ [key: string]: number; }' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{ [key: string]: number; }'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(26,7): error TS2339: Property 'x' does not exist on type 'T'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(27,5): error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(27,5): error TS2322: Type '1' is not assignable to type 'T[keyof T]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(31,5): error TS2322: Type '{ [key: string]: number; }' is not assignable to type '{ [P in K]: number; }'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(38,5): error TS2322: Type '{ [x: string]: number; }' is not assignable to type '{ [P in K]: number; }'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(50,3): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Item'.
|
||||
No index signature with a parameter of type 'string' was found on type 'Item'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(51,3): error TS2322: Type 'number' is not assignable to type 'never'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(52,3): error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(53,3): error TS2322: Type 'number' is not assignable to type 'T[K]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(52,3): error TS2322: Type '123' is not assignable to type 'T[keyof T]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(53,3): error TS2322: Type '123' is not assignable to type 'T[K]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(65,7): error TS2339: Property 'foo' does not exist on type 'T'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(66,3): error TS2536: Type 'string' cannot be used to index type 'T'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(67,3): error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(68,3): error TS2322: Type 'number' is not assignable to type 'T[K]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS2322: Type 'number' is not assignable to type 'Type[K]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(67,3): error TS2322: Type '123' is not assignable to type 'T[keyof T]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(68,3): error TS2322: Type '123' is not assignable to type 'T[K]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS2322: Type '123' is not assignable to type 'Type[K]'.
|
||||
Type 'number' is not assignable to type 'never'.
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS23
|
|||
!!! error TS2339: Property 'x' does not exist on type 'T'.
|
||||
c[k] = 1; // Error, cannot write to index signature through constraint
|
||||
~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
|
||||
!!! error TS2322: Type '1' is not assignable to type 'T[keyof T]'.
|
||||
}
|
||||
|
||||
function f3<K extends string>(a: { [P in K]: number }, b: { [key: string]: number }, k: K) {
|
||||
|
@ -118,10 +118,10 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS23
|
|||
!!! error TS2322: Type 'number' is not assignable to type 'never'.
|
||||
obj[k3] = 123; // Error
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
|
||||
!!! error TS2322: Type '123' is not assignable to type 'T[keyof T]'.
|
||||
obj[k4] = 123; // Error
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'T[K]'.
|
||||
!!! error TS2322: Type '123' is not assignable to type 'T[K]'.
|
||||
}
|
||||
|
||||
type Dict = Record<string, number>;
|
||||
|
@ -141,10 +141,10 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS23
|
|||
!!! error TS2536: Type 'string' cannot be used to index type 'T'.
|
||||
obj[k2] = 123; // Error
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'T[keyof T]'.
|
||||
!!! error TS2322: Type '123' is not assignable to type 'T[keyof T]'.
|
||||
obj[k3] = 123; // Error
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'T[K]'.
|
||||
!!! error TS2322: Type '123' is not assignable to type 'T[K]'.
|
||||
}
|
||||
|
||||
// Repro from #27895
|
||||
|
@ -186,7 +186,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS23
|
|||
function get123<K extends keyof Type>(): Type[K] {
|
||||
return 123; // Error
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'Type[K]'.
|
||||
!!! error TS2322: Type '123' is not assignable to type 'Type[K]'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'never'.
|
||||
}
|
||||
|
||||
|
|
|
@ -69,10 +69,10 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(114,5): error
|
|||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(117,5): error TS2322: Type 'T[K]' is not assignable to type 'U[J]'.
|
||||
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/keyof/keyofAndIndexedAccessErrors.ts(122,5): error TS2322: Type 'number' is not assignable to type 'keyof T'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(123,5): error TS2322: Type 'string' is not assignable to type 'keyof T'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(140,5): error TS2322: Type 'number' is not assignable to type 'T[K]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(141,5): error TS2322: Type 'string' is not assignable to type 'T[K]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(122,5): error TS2322: Type '42' is not assignable to type 'keyof T'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(123,5): error TS2322: Type '"hello"' is not assignable to type 'keyof T'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(140,5): error TS2322: Type '42' is not assignable to type 'T[K]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(141,5): error TS2322: Type '"hello"' is not assignable to type 'T[K]'.
|
||||
tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error TS2322: Type 'number[]' is not assignable to type 'T[K]'.
|
||||
|
||||
|
||||
|
@ -306,10 +306,10 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error
|
|||
function f4<T extends { [K in keyof T]: string }>(k: keyof T) {
|
||||
k = 42; // error
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'keyof T'.
|
||||
!!! error TS2322: Type '42' is not assignable to type 'keyof T'.
|
||||
k = "hello"; // error
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'keyof T'.
|
||||
!!! error TS2322: Type '"hello"' is not assignable to type 'keyof T'.
|
||||
}
|
||||
|
||||
// Repro from #27470
|
||||
|
@ -328,10 +328,10 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error
|
|||
function test1<T extends Record<string, any>, K extends keyof T>(t: T, k: K) {
|
||||
t[k] = 42; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'T[K]'.
|
||||
!!! error TS2322: Type '42' is not assignable to type 'T[K]'.
|
||||
t[k] = "hello"; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'T[K]'.
|
||||
!!! error TS2322: Type '"hello"' is not assignable to type 'T[K]'.
|
||||
t[k] = [10, 20]; // Error
|
||||
~~~~
|
||||
!!! error TS2322: Type 'number[]' is not assignable to type 'T[K]'.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
tests/cases/compiler/keyofIsLiteralContexualType.ts(5,37): error TS2322: Type 'string' is not assignable to type 'keyof T'.
|
||||
tests/cases/compiler/keyofIsLiteralContexualType.ts(5,37): error TS2322: Type '"c"' is not assignable to type 'keyof T'.
|
||||
Type '"c"' is not assignable to type '"a" | "b"'.
|
||||
tests/cases/compiler/keyofIsLiteralContexualType.ts(13,11): error TS2339: Property 'b' does not exist on type 'Pick<{ a: number; b: number; c: number; }, "a" | "c">'.
|
||||
|
||||
|
@ -10,7 +10,7 @@ tests/cases/compiler/keyofIsLiteralContexualType.ts(13,11): error TS2339: Proper
|
|||
let a: (keyof T)[] = ["a", "b"];
|
||||
let b: (keyof T)[] = ["a", "b", "c"];
|
||||
~~~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'keyof T'.
|
||||
!!! error TS2322: Type '"c"' is not assignable to type 'keyof T'.
|
||||
!!! error TS2322: Type '"c"' is not assignable to type '"a" | "b"'.
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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'.
|
||||
tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(3,15): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
|
||||
'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.
|
||||
|
||||
|
@ -11,7 +11,7 @@ tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(4,15): erro
|
|||
!!! error TS2558: Expected 0 type arguments, but got 1.
|
||||
var r2 = f(1);
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'.
|
||||
!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'.
|
||||
!!! error TS2345: 'T' could be instantiated with an arbitrary type which could be unrelated to '1'.
|
||||
var r3 = f<any>(null);
|
||||
~~~
|
||||
|
|
Loading…
Reference in a new issue