diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 63f9f8fd863..b65e6f69bef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18263,6 +18263,20 @@ namespace ts { } } else if (target.flags & TypeFlags.IndexedAccess) { + if (source.flags & TypeFlags.IndexedAccess) { + // Relate components directly before falling back to constraint relationships + // A type S[K] is related to a type T[J] if S is related to T and K is related to J. + if (result = isRelatedTo((source).objectType, (target).objectType, reportErrors)) { + result &= isRelatedTo((source).indexType, (target).indexType, reportErrors); + } + if (result) { + resetErrorInfo(saveErrorInfo); + return result; + } + if (reportErrors) { + originalErrorInfo = errorInfo; + } + } // A type S is related to a type T[K] if S is related to C, where C is the base // constraint of T[K] for writing. if (relation === assignableRelation || relation === comparableRelation) { @@ -18273,11 +18287,24 @@ namespace ts { if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { const accessFlags = AccessFlags.Writing | (baseObjectType !== objectType ? AccessFlags.NoIndexSignatures : 0); const constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, (target).noUncheckedIndexedAccessCandidate, /*accessNode*/ undefined, accessFlags); - if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) { - return result; + if (constraint) { + if (reportErrors && originalErrorInfo) { + // create a new chain for the constraint error + resetErrorInfo(saveErrorInfo); + } + if (result = isRelatedTo(source, constraint, reportErrors)) { + return result; + } + // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain + if (reportErrors && originalErrorInfo && errorInfo) { + errorInfo = countMessageChainBreadth([originalErrorInfo]) <= countMessageChainBreadth([errorInfo]) ? originalErrorInfo : errorInfo; + } } } } + if (reportErrors) { + originalErrorInfo = undefined; + } } else if (isGenericMappedType(target) && !target.declaration.nameType) { // A source type T is related to a target type { [P in X]: T[P] } @@ -18365,17 +18392,8 @@ namespace ts { } if (source.flags & TypeFlags.TypeVariable) { - if (source.flags & TypeFlags.IndexedAccess && target.flags & TypeFlags.IndexedAccess) { - // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo((source).objectType, (target).objectType, reportErrors)) { - result &= isRelatedTo((source).indexType, (target).indexType, reportErrors); - } - if (result) { - resetErrorInfo(saveErrorInfo); - return result; - } - } - else { + // IndexedAccess comparisons are handled above in the `target.flags & TypeFlage.IndexedAccess` branch + if (!(source.flags & TypeFlags.IndexedAccess && target.flags & TypeFlags.IndexedAccess)) { const constraint = getConstraintOfType(source); if (!constraint || (source.flags & TypeFlags.TypeParameter && constraint.flags & TypeFlags.Any)) { // A type variable with no constraint is not related to the non-primitive object type. @@ -18390,7 +18408,7 @@ namespace ts { return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, intersectionState)) { + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors && !(target.flags & source.flags & TypeFlags.TypeParameter), /*headMessage*/ undefined, intersectionState)) { resetErrorInfo(saveErrorInfo); return result; } @@ -18561,6 +18579,11 @@ namespace ts { } return Ternary.False; + function countMessageChainBreadth(info: DiagnosticMessageChain[] | undefined): number { + if (!info) return 0; + return reduceLeft(info, (value, chain) => value + 1 + countMessageChainBreadth(chain.next), 0); + } + function relateVariances(sourceTypeArguments: readonly Type[] | undefined, targetTypeArguments: readonly Type[] | undefined, variances: VarianceFlags[], intersectionState: IntersectionState) { if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; diff --git a/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.errors.txt b/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.errors.txt new file mode 100644 index 00000000000..1626db671f2 --- /dev/null +++ b/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/errorInfoForRelatedIndexTypesNoConstraintElaboration.ts(6,15): error TS2322: Type 'IntrinsicElements[T1]' is not assignable to type 'IntrinsicElements[T2]'. + Type 'T1' is not assignable to type 'T2'. + 'T1' is assignable to the constraint of type 'T2', but 'T2' could be instantiated with a different subtype of constraint 'keyof IntrinsicElements'. + + +==== tests/cases/compiler/errorInfoForRelatedIndexTypesNoConstraintElaboration.ts (1 errors) ==== + /// + + class I { + M() { + let c1: JSX.IntrinsicElements[T1] = {}; + const c2: JSX.IntrinsicElements[T2] = c1; + ~~ +!!! error TS2322: Type 'IntrinsicElements[T1]' is not assignable to type 'IntrinsicElements[T2]'. +!!! error TS2322: Type 'T1' is not assignable to type 'T2'. +!!! error TS2322: 'T1' is assignable to the constraint of type 'T2', but 'T2' could be instantiated with a different subtype of constraint 'keyof IntrinsicElements'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.js b/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.js new file mode 100644 index 00000000000..553807f4b9f --- /dev/null +++ b/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.js @@ -0,0 +1,21 @@ +//// [errorInfoForRelatedIndexTypesNoConstraintElaboration.ts] +/// + +class I { + M() { + let c1: JSX.IntrinsicElements[T1] = {}; + const c2: JSX.IntrinsicElements[T2] = c1; + } +} + +//// [errorInfoForRelatedIndexTypesNoConstraintElaboration.js] +/// +var I = /** @class */ (function () { + function I() { + } + I.prototype.M = function () { + var c1 = {}; + var c2 = c1; + }; + return I; +}()); diff --git a/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.symbols b/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.symbols new file mode 100644 index 00000000000..d58da24aa89 --- /dev/null +++ b/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/errorInfoForRelatedIndexTypesNoConstraintElaboration.ts === +/// + +class I { +>I : Symbol(I, Decl(errorInfoForRelatedIndexTypesNoConstraintElaboration.ts, 0, 0)) +>T1 : Symbol(T1, Decl(errorInfoForRelatedIndexTypesNoConstraintElaboration.ts, 2, 8)) +>JSX : Symbol(JSX, Decl(react16.d.ts, 2493, 12)) +>IntrinsicElements : Symbol(JSX.IntrinsicElements, Decl(react16.d.ts, 2514, 86)) +>T2 : Symbol(T2, Decl(errorInfoForRelatedIndexTypesNoConstraintElaboration.ts, 2, 47)) +>JSX : Symbol(JSX, Decl(react16.d.ts, 2493, 12)) +>IntrinsicElements : Symbol(JSX.IntrinsicElements, Decl(react16.d.ts, 2514, 86)) + + M() { +>M : Symbol(I.M, Decl(errorInfoForRelatedIndexTypesNoConstraintElaboration.ts, 2, 89)) + + let c1: JSX.IntrinsicElements[T1] = {}; +>c1 : Symbol(c1, Decl(errorInfoForRelatedIndexTypesNoConstraintElaboration.ts, 4, 11)) +>JSX : Symbol(JSX, Decl(react16.d.ts, 2493, 12)) +>IntrinsicElements : Symbol(JSX.IntrinsicElements, Decl(react16.d.ts, 2514, 86)) +>T1 : Symbol(T1, Decl(errorInfoForRelatedIndexTypesNoConstraintElaboration.ts, 2, 8)) + + const c2: JSX.IntrinsicElements[T2] = c1; +>c2 : Symbol(c2, Decl(errorInfoForRelatedIndexTypesNoConstraintElaboration.ts, 5, 13)) +>JSX : Symbol(JSX, Decl(react16.d.ts, 2493, 12)) +>IntrinsicElements : Symbol(JSX.IntrinsicElements, Decl(react16.d.ts, 2514, 86)) +>T2 : Symbol(T2, Decl(errorInfoForRelatedIndexTypesNoConstraintElaboration.ts, 2, 47)) +>c1 : Symbol(c1, Decl(errorInfoForRelatedIndexTypesNoConstraintElaboration.ts, 4, 11)) + } +} diff --git a/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.types b/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.types new file mode 100644 index 00000000000..0e96bb36d89 --- /dev/null +++ b/tests/baselines/reference/errorInfoForRelatedIndexTypesNoConstraintElaboration.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/errorInfoForRelatedIndexTypesNoConstraintElaboration.ts === +/// + +class I { +>I : I +>JSX : any +>JSX : any + + M() { +>M : () => void + + let c1: JSX.IntrinsicElements[T1] = {}; +>c1 : JSX.IntrinsicElements[T1] +>JSX : any +>{} : {} + + const c2: JSX.IntrinsicElements[T2] = c1; +>c2 : JSX.IntrinsicElements[T2] +>JSX : any +>c1 : JSX.IntrinsicElements[T1] + } +} diff --git a/tests/baselines/reference/genericTypeAssertions6.errors.txt b/tests/baselines/reference/genericTypeAssertions6.errors.txt index 027d718dc37..84c68176da2 100644 --- a/tests/baselines/reference/genericTypeAssertions6.errors.txt +++ b/tests/baselines/reference/genericTypeAssertions6.errors.txt @@ -4,8 +4,6 @@ tests/cases/compiler/genericTypeAssertions6.ts(9,13): error TS2352: Conversion o 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Conversion of type 'U' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. - Type 'Date' is not comparable to 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/compiler/genericTypeAssertions6.ts (3 errors) ==== @@ -37,8 +35,6 @@ tests/cases/compiler/genericTypeAssertions6.ts(19,17): error TS2352: Conversion ~~~~~~~~~~~~~~~~ !!! error TS2352: Conversion of type 'U' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. !!! error TS2352: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2352: Type 'Date' is not comparable to type 'T'. -!!! error TS2352: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. } } diff --git a/tests/baselines/reference/intrinsicTypes.errors.txt b/tests/baselines/reference/intrinsicTypes.errors.txt index 46a3ab82ec1..1be87618949 100644 --- a/tests/baselines/reference/intrinsicTypes.errors.txt +++ b/tests/baselines/reference/intrinsicTypes.errors.txt @@ -8,8 +8,6 @@ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(42,5): error TS2322: tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(43,5): error TS2322: Type 'Uppercase' is not assignable to type 'Uppercase'. Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string'. - Type 'string' is not assignable to type 'U'. - 'string' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string'. ==== tests/cases/conformance/types/typeAliases/intrinsicTypes.ts (8 errors) ==== @@ -74,8 +72,6 @@ tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(43,5): error TS2322: !!! error TS2322: Type 'Uppercase' is not assignable to type 'Uppercase'. !!! error TS2322: Type 'T' is not assignable to type 'U'. !!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string'. -!!! error TS2322: Type 'string' is not assignable to type 'U'. -!!! error TS2322: 'string' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string'. } function foo2(x: Uppercase) { diff --git a/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt b/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt index c845f44d7de..ba319beca32 100644 --- a/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt +++ b/tests/baselines/reference/keyofAndIndexedAccessErrors.errors.txt @@ -53,12 +53,6 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(111,5): error tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(114,5): error TS2322: Type 'T[K]' is not assignable to type 'T[J]'. Type 'K' is not assignable to type 'J'. 'K' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. - Type 'Extract' is not assignable to type 'J'. - 'Extract' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. - Type 'string & keyof T' is not assignable to type 'J'. - 'string & keyof T' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. - Type 'string' is not assignable to type 'J'. - 'string' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. 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'. @@ -273,12 +267,6 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccessErrors.ts(142,5): error !!! error TS2322: Type 'T[K]' is not assignable to type 'T[J]'. !!! error TS2322: Type 'K' is not assignable to type 'J'. !!! error TS2322: 'K' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. -!!! error TS2322: Type 'Extract' is not assignable to type 'J'. -!!! error TS2322: 'Extract' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. -!!! error TS2322: Type 'string & keyof T' is not assignable to type 'J'. -!!! error TS2322: 'string & keyof T' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. -!!! error TS2322: Type 'string' is not assignable to type 'J'. -!!! error TS2322: 'string' is assignable to the constraint of type 'J', but 'J' could be instantiated with a different subtype of constraint 'string'. tk = uj; uj = tk; // error diff --git a/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt b/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt index 8f2ebf0131a..6d5d0673735 100644 --- a/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt +++ b/tests/baselines/reference/objectTypeWithRecursiveWrappedPropertyCheckedNominally.errors.txt @@ -6,16 +6,10 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRec Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(30,5): error TS2322: Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'List'. - Type 'MyList' is not assignable to type 'T'. - 'MyList' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'List'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(31,5): error TS2322: Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'MyList'. - Type 'List' is not assignable to type 'U'. - 'List' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'MyList'. tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts(42,5): error TS2322: Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'MyList'. - Type 'MyList' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'MyList'. ==== tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRecursiveWrappedPropertyCheckedNominally.ts (5 errors) ==== @@ -60,14 +54,10 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRec ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. !!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'List'. -!!! error TS2322: Type 'MyList' is not assignable to type 'T'. -!!! error TS2322: 'MyList' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'List'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. !!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'MyList'. -!!! error TS2322: Type 'List' is not assignable to type 'U'. -!!! error TS2322: 'List' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'MyList'. var a: List; var b: MyList; @@ -82,8 +72,6 @@ tests/cases/conformance/types/typeRelationships/recursiveTypes/objectTypeWithRec ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. !!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'MyList'. -!!! error TS2322: Type 'MyList' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'MyList'. u = t; // was error, ok after constraint made illegal, doesn't matter var a: List; diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt index 8365be24788..8c8a65f9f7c 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt @@ -18,22 +18,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2416: Property 'foo' in type 'D19' is not assignable to the same property in base type 'C3'. Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. - Type 'V' is not assignable to type 'T'. - 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. - Type 'Date' is not assignable to 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/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2416: Property 'foo' in type 'D23' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'T'. 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. - Type 'Date' is not assignable to 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/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2416: Property 'foo' in type 'D24' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'U'. 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. - Type 'Date' is not assignable to type 'U'. - 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2416: Property 'foo' in type 'D27' is not assignable to the same property in base type 'C3'. Type 'Date' is not assignable to type 'T'. @@ -191,10 +183,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D19' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2416: Type 'V' is not assignable to type 'T'. -!!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2416: Type 'Date' is not assignable to type 'T'. -!!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. } class D20 extends C3 { @@ -223,8 +211,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D23' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'V' is not assignable to type 'T'. !!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2416: Type 'Date' is not assignable to type 'T'. -!!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. } class D24 extends C3 { @@ -236,8 +222,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D24' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'V' is not assignable to type 'U'. !!! error TS2416: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2416: Type 'Date' is not assignable to type 'U'. -!!! error TS2416: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. } class D25 extends C3 { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt index b6e2b87fd83..0f63d274130 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints4.errors.txt @@ -5,8 +5,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'B1'. Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. - Type 'Foo' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'B1'. Type 'V' is not assignable to type 'T'. @@ -15,8 +13,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'B1'. Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. - Type 'Foo' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2416: Property 'foo' in type 'D9' is not assignable to the same property in base type 'B1'. Type 'V' is not assignable to type 'U'. @@ -92,8 +88,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. -!!! error TS2416: Type 'Foo' is not assignable to type 'T'. -!!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. } class D6 extends B1 { @@ -116,8 +110,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'B1'. !!! error TS2416: Type 'T' is not assignable to type 'U'. !!! error TS2416: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. -!!! error TS2416: Type 'Foo' is not assignable to type 'U'. -!!! error TS2416: 'U' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. } class D8 extends B1 { diff --git a/tests/baselines/reference/templateLiteralTypes1.errors.txt b/tests/baselines/reference/templateLiteralTypes1.errors.txt index eef69e25156..dae7b7009fd 100644 --- a/tests/baselines/reference/templateLiteralTypes1.errors.txt +++ b/tests/baselines/reference/templateLiteralTypes1.errors.txt @@ -2,8 +2,6 @@ tests/cases/conformance/types/literal/templateLiteralTypes1.ts(40,5): error TS23 tests/cases/conformance/types/literal/templateLiteralTypes1.ts(45,5): error TS2322: Type '{ [P in B as `p_${P}`]: T; }' is not assignable to type '{ [Q in A as `p_${Q}`]: U; }'. Type 'A' is not assignable to type 'B'. 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'string'. - Type 'string' is not assignable to type 'B'. - 'string' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'string'. tests/cases/conformance/types/literal/templateLiteralTypes1.ts(165,15): error TS1338: 'infer' declarations are only permitted in the 'extends' clause of a conditional type. tests/cases/conformance/types/literal/templateLiteralTypes1.ts(197,16): error TS2590: Expression produces a union type that is too complex to represent. tests/cases/conformance/types/literal/templateLiteralTypes1.ts(201,16): error TS2590: Expression produces a union type that is too complex to represent. @@ -62,8 +60,6 @@ tests/cases/conformance/types/literal/templateLiteralTypes1.ts(205,16): error TS !!! error TS2322: Type '{ [P in B as `p_${P}`]: T; }' is not assignable to type '{ [Q in A as `p_${Q}`]: U; }'. !!! error TS2322: Type 'A' is not assignable to type 'B'. !!! error TS2322: 'A' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'string'. -!!! error TS2322: Type 'string' is not assignable to type 'B'. -!!! error TS2322: 'string' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'string'. } // String transformations using recursive conditional types diff --git a/tests/baselines/reference/typeParameterAssignability2.errors.txt b/tests/baselines/reference/typeParameterAssignability2.errors.txt index 8e20983e7b5..e95c4b94f4e 100644 --- a/tests/baselines/reference/typeParameterAssignability2.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability2.errors.txt @@ -10,36 +10,24 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(25,5): error TS2322: Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. - Type 'V' is not assignable to type 'T'. - 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. - Type 'Date' is not assignable to 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/assignmentCompatibility/typeParameterAssignability2.ts(26,5): error TS2322: Type 'V' is not assignable to type 'T'. 'V' 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/assignmentCompatibility/typeParameterAssignability2.ts(27,5): error TS2322: Type 'Date' is not assignable to 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/assignmentCompatibility/typeParameterAssignability2.ts(30,5): error TS2322: Type 'V' is not assignable to type 'U'. 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. - Type 'Date' is not assignable to type 'U'. - 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(31,5): error TS2322: Type 'Date' is not assignable to type 'U'. 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(35,5): error TS2322: Type 'Date' is not assignable to type 'V'. 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(45,5): error TS2322: Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. - Type 'V' is not assignable to type 'T'. - 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. - Type 'Date' is not assignable to 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/assignmentCompatibility/typeParameterAssignability2.ts(46,5): error TS2322: Type 'V' is not assignable to type 'T'. 'V' 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/assignmentCompatibility/typeParameterAssignability2.ts(47,5): error TS2322: Type 'Date' is not assignable to 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/assignmentCompatibility/typeParameterAssignability2.ts(50,5): error TS2322: Type 'V' is not assignable to type 'U'. 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. - Type 'Date' is not assignable to type 'U'. - 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(51,5): error TS2322: Type 'Date' is not assignable to type 'U'. 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(55,5): error TS2322: Type 'Date' is not assignable to type 'V'. @@ -100,10 +88,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. !!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2322: Type 'V' is not assignable to type 'T'. -!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. -!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. @@ -118,8 +102,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. !!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2322: Type 'Date' is not assignable to type 'U'. -!!! error TS2322: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. u = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'U'. @@ -144,10 +126,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. !!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2322: Type 'V' is not assignable to type 'T'. -!!! error TS2322: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. -!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. t = v; // error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. @@ -162,8 +140,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. !!! error TS2322: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2322: Type 'Date' is not assignable to type 'U'. -!!! error TS2322: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'. u = new Date(); // error ~ !!! error TS2322: Type 'Date' is not assignable to type 'U'. diff --git a/tests/baselines/reference/typeParameterAssignability3.errors.txt b/tests/baselines/reference/typeParameterAssignability3.errors.txt index 0757d49d590..6e71584f91d 100644 --- a/tests/baselines/reference/typeParameterAssignability3.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability3.errors.txt @@ -1,19 +1,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(14,5): error TS2322: Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. - Type 'Foo' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(15,5): error TS2322: Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. - Type 'Foo' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(22,9): error TS2322: Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. - Type 'Foo' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts(23,9): error TS2322: Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. - Type 'Foo' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability3.ts (4 errors) ==== @@ -34,14 +26,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. !!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. -!!! error TS2322: Type 'Foo' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. u = t; // error ~ !!! error TS2322: Type 'T' is not assignable to type 'U'. !!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. -!!! error TS2322: Type 'Foo' is not assignable to type 'U'. -!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. } class C { @@ -52,13 +40,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara ~~~~~~ !!! error TS2322: Type 'U' is not assignable to type 'T'. !!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'. -!!! error TS2322: Type 'Foo' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. this.u = this.t; // error ~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. !!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'. -!!! error TS2322: Type 'Foo' is not assignable to type 'U'. -!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt index 0f169ca1ee7..8016f5209a6 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt @@ -1,7 +1,5 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. - Type 'Date' is not assignable to 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/compiler/typeParametersShouldNotBeEqual2.ts(5,5): error TS2322: Type 'V' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(6,5): error TS2322: Type 'T' is not assignable to type 'V'. @@ -22,8 +20,6 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. !!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. -!!! error TS2322: Type 'Date' is not assignable to type 'T'. -!!! error TS2322: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'. x = z; // Error ~ !!! error TS2322: Type 'V' is not assignable to type 'T'. diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt index fcc9c0d3c87..d1fbc783aa9 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual3.errors.txt @@ -1,8 +1,5 @@ tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. - Type 'Object' is not assignable to type 'T'. - 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(5,5): error TS2322: Type 'Object' is not assignable to type 'T'. 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? @@ -16,9 +13,6 @@ tests/cases/compiler/typeParametersShouldNotBeEqual3.ts(5,5): error TS2322: Type ~ !!! error TS2322: Type 'U' is not assignable to type 'T'. !!! error TS2322: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. -!!! error TS2322: Type 'Object' is not assignable to type 'T'. -!!! error TS2322: 'Object' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Object'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? x = z; // Ok ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. diff --git a/tests/baselines/reference/variadicTuples1.errors.txt b/tests/baselines/reference/variadicTuples1.errors.txt index c7cd43a4c71..956bd6a922b 100644 --- a/tests/baselines/reference/variadicTuples1.errors.txt +++ b/tests/baselines/reference/variadicTuples1.errors.txt @@ -11,8 +11,6 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(151,5): error TS2322: Typ tests/cases/conformance/types/tuple/variadicTuples1.ts(152,5): error TS2322: Type '[string, ...T]' is not assignable to type '[string, ...U]'. Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string[]'. - Type 'string[]' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'string[]'. tests/cases/conformance/types/tuple/variadicTuples1.ts(160,5): error TS2322: Type 'readonly [...T]' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'readonly [...T]'. tests/cases/conformance/types/tuple/variadicTuples1.ts(162,5): error TS4104: The type 'readonly [...T]' is 'readonly' and cannot be assigned to the mutable type '[...T]'. @@ -27,8 +25,6 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(181,5): error TS2322: Typ tests/cases/conformance/types/tuple/variadicTuples1.ts(182,5): error TS2322: Type '[...T]' is not assignable to type '[...U]'. Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string[]'. - Type 'string[]' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'string[]'. tests/cases/conformance/types/tuple/variadicTuples1.ts(188,5): error TS2322: Type 'T' is not assignable to type '[...T]'. The type 'readonly string[]' is 'readonly' and cannot be assigned to the mutable type '[...T]'. tests/cases/conformance/types/tuple/variadicTuples1.ts(190,5): error TS2322: Type 'T' is not assignable to type '[...U]'. @@ -36,8 +32,6 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(190,5): error TS2322: Typ tests/cases/conformance/types/tuple/variadicTuples1.ts(191,5): error TS2322: Type '[...T]' is not assignable to type '[...U]'. Type 'T' is not assignable to type 'U'. 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'readonly string[]'. - Type 'readonly string[]' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'readonly string[]'. tests/cases/conformance/types/tuple/variadicTuples1.ts(203,5): error TS2322: Type 'string' is not assignable to type 'keyof [1, 2, ...T]'. Type '"2"' is not assignable to type 'number | "0" | keyof T[] | "1"'. tests/cases/conformance/types/tuple/variadicTuples1.ts(357,26): error TS2322: Type 'string' is not assignable to type 'number | undefined'. @@ -220,8 +214,6 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(397,7): error TS2322: Typ !!! error TS2322: Type '[string, ...T]' is not assignable to type '[string, ...U]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. !!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string[]'. -!!! error TS2322: Type 'string[]' is not assignable to type 'U'. -!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'string[]'. } // For a generic type T, [...T] is assignable to T, T is assignable to readonly [...T], and T is assignable @@ -273,8 +265,6 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(397,7): error TS2322: Typ !!! error TS2322: Type '[...T]' is not assignable to type '[...U]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. !!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string[]'. -!!! error TS2322: Type 'string[]' is not assignable to type 'U'. -!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'string[]'. } function f14(t0: T, t1: [...T], t2: [...U]) { @@ -294,8 +284,6 @@ tests/cases/conformance/types/tuple/variadicTuples1.ts(397,7): error TS2322: Typ !!! error TS2322: Type '[...T]' is not assignable to type '[...U]'. !!! error TS2322: Type 'T' is not assignable to type 'U'. !!! error TS2322: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'readonly string[]'. -!!! error TS2322: Type 'readonly string[]' is not assignable to type 'U'. -!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'readonly string[]'. } function f15(k0: keyof T, k1: keyof [...T], k2: keyof [...U], k3: keyof [1, 2, ...T]) { diff --git a/tests/cases/compiler/errorInfoForRelatedIndexTypesNoConstraintElaboration.ts b/tests/cases/compiler/errorInfoForRelatedIndexTypesNoConstraintElaboration.ts new file mode 100644 index 00000000000..df23af01f30 --- /dev/null +++ b/tests/cases/compiler/errorInfoForRelatedIndexTypesNoConstraintElaboration.ts @@ -0,0 +1,8 @@ +/// + +class I { + M() { + let c1: JSX.IntrinsicElements[T1] = {}; + const c2: JSX.IntrinsicElements[T2] = c1; + } +} \ No newline at end of file