From 4db251b09906eebf26befddee643e60484601d6d Mon Sep 17 00:00:00 2001 From: NamHaiBui Date: Fri, 14 Feb 2025 15:33:29 -0500 Subject: [PATCH] new approach and all changed tests reviewed --- src/compiler/checker.ts | 4 ++-- ...gnmentCompatWithCallSignatures4.errors.txt | 12 +++++------ ...tCompatWithConstructSignatures4.errors.txt | 12 +++++------ .../reference/awaitedTypeNoLib.errors.txt | 4 ++-- .../reference/conditionalTypes1.errors.txt | 8 ++++---- .../deeplyNestedMappedTypes.errors.txt | 4 ++-- ...signmentOfIdenticallyNamedTypes.errors.txt | 4 ++-- .../indexedAccessRelation.errors.txt | 12 ++--------- .../mappedTypeRelationships.errors.txt | 20 ++++++------------- .../reference/mappedTypes6.errors.txt | 8 ++++---- ...tiveConstraintOfIndexAccessType.errors.txt | 6 ++---- .../recursiveConditionalTypes.errors.txt | 16 ++------------- .../subtypingWithNumericIndexer2.errors.txt | 4 ++-- .../subtypingWithNumericIndexer3.errors.txt | 4 ++-- .../subtypingWithNumericIndexer5.errors.txt | 4 ++-- .../subtypingWithStringIndexer2.errors.txt | 4 ++-- .../subtypingWithStringIndexer3.errors.txt | 4 ++-- .../typeParameterDiamond4.errors.txt | 8 ++------ .../typeParametersShouldNotBeEqual.errors.txt | 6 ++---- ...typeParametersShouldNotBeEqual2.errors.txt | 6 ++---- .../unionTypesAssignability.errors.txt | 16 ++++----------- .../reference/variadicTuples1.errors.txt | 4 ++-- 22 files changed, 62 insertions(+), 108 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d340fc2dd2c03..e42d288e48f19 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21965,8 +21965,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { typeToString(constraint), ); } - // check if target is a descendant of the source - else if ((isGenericType(target) && isGenericType(source)) &&( isTypeAssignableTo(target, getBaseConstraintOrType(generalizedSource)) || (needsOriginalSource = isTypeAssignableTo(target, getBaseConstraintOrType(source))))) { + + else if ((source.flags & TypeFlags.TypeParameter) && (isTypeAssignableTo(target, getBaseConstraintOrType(generalizedSource)) || (needsOriginalSource = isTypeAssignableTo(target, getBaseConstraintOrType(source))))) { reportError( Diagnostics._1_is_constrained_to_be_a_subtype_of_0, needsOriginalSource ? sourceType : generalizedSourceType, diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt index 0988bb2e9d751..c91ddb00897e1 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt @@ -19,13 +19,13 @@ assignmentCompatWithCallSignatures4.ts(53,9): error TS2322: Type '(x: (arg: Base 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. assignmentCompatWithCallSignatures4.ts(58,9): error TS2322: Type '(...x: Base[]) => Base' is not assignable to type '(...x: T[]) => T'. Type 'Base' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Base'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. assignmentCompatWithCallSignatures4.ts(62,9): error TS2322: Type '(x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type '(x: T, y: T) => T'. Type 'Base' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Base'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. assignmentCompatWithCallSignatures4.ts(66,9): error TS2322: Type '(x: Base[], y: Derived2[]) => Derived[]' is not assignable to type '>(x: Base[], y: Base[]) => T'. Type 'Derived[]' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Derived[]'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Derived[]'. assignmentCompatWithCallSignatures4.ts(69,9): error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. @@ -149,7 +149,7 @@ assignmentCompatWithCallSignatures4.ts(96,9): error TS2322: Type '(x: T) => s ~~~ !!! error TS2322: Type '(...x: Base[]) => Base' is not assignable to type '(...x: T[]) => T'. !!! error TS2322: Type 'Base' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Base'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. var b11: (x: T, y: T) => T; a11 = b11; @@ -157,7 +157,7 @@ assignmentCompatWithCallSignatures4.ts(96,9): error TS2322: Type '(x: T) => s ~~~ !!! error TS2322: Type '(x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type '(x: T, y: T) => T'. !!! error TS2322: Type 'Base' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Base'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. var b12: >(x: Array, y: Array) => T; a12 = b12; @@ -165,7 +165,7 @@ assignmentCompatWithCallSignatures4.ts(96,9): error TS2322: Type '(x: T) => s ~~~ !!! error TS2322: Type '(x: Base[], y: Derived2[]) => Derived[]' is not assignable to type '>(x: Base[], y: Base[]) => T'. !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Derived[]'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Derived[]'. var b15: (x: { a: T; b: T }) => T; a15 = b15; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 67dc0ee76c6fe..9c654f2e09c20 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -19,13 +19,13 @@ assignmentCompatWithConstructSignatures4.ts(53,9): error TS2322: Type 'new (x: ( 'Base' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Base'. assignmentCompatWithConstructSignatures4.ts(58,9): error TS2322: Type 'new (...x: Base[]) => Base' is not assignable to type 'new (...x: T[]) => T'. Type 'Base' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Base'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. assignmentCompatWithConstructSignatures4.ts(62,9): error TS2322: Type 'new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type 'new (x: T, y: T) => T'. Type 'Base' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Base'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. assignmentCompatWithConstructSignatures4.ts(66,9): error TS2322: Type 'new (x: Base[], y: Derived2[]) => Derived[]' is not assignable to type 'new >(x: Base[], y: Base[]) => T'. Type 'Derived[]' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Derived[]'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Derived[]'. assignmentCompatWithConstructSignatures4.ts(69,9): error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. @@ -165,7 +165,7 @@ assignmentCompatWithConstructSignatures4.ts(96,9): error TS2322: Type 'new (x ~~~ !!! error TS2322: Type 'new (...x: Base[]) => Base' is not assignable to type 'new (...x: T[]) => T'. !!! error TS2322: Type 'Base' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Base'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. var b11: new (x: T, y: T) => T; a11 = b11; // ok @@ -173,7 +173,7 @@ assignmentCompatWithConstructSignatures4.ts(96,9): error TS2322: Type 'new (x ~~~ !!! error TS2322: Type 'new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base' is not assignable to type 'new (x: T, y: T) => T'. !!! error TS2322: Type 'Base' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Base'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. var b12: new >(x: Array, y: Array) => T; a12 = b12; // ok @@ -181,7 +181,7 @@ assignmentCompatWithConstructSignatures4.ts(96,9): error TS2322: Type 'new (x ~~~ !!! error TS2322: Type 'new (x: Base[], y: Derived2[]) => Derived[]' is not assignable to type 'new >(x: Base[], y: Base[]) => T'. !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Derived[]'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Derived[]'. var b15: new (x: { a: T; b: T }) => T; a15 = b15; // ok diff --git a/tests/baselines/reference/awaitedTypeNoLib.errors.txt b/tests/baselines/reference/awaitedTypeNoLib.errors.txt index 59929afadb39d..f19971eed35b7 100644 --- a/tests/baselines/reference/awaitedTypeNoLib.errors.txt +++ b/tests/baselines/reference/awaitedTypeNoLib.errors.txt @@ -13,7 +13,7 @@ awaitedTypeNoLib.ts(18,27): error TS2345: Argument of type 'NotPromise Type 'TResult | (TResult extends PromiseLike ? never : TResult)' is not assignable to type 'Thenable'. Type 'Thenable & TResult' is not assignable to type 'Thenable'. Type 'unknown' is not assignable to type 'TResult'. - 'TResult' is constrained to be a subtype of 'unknown'. + 'TResult' could be instantiated with an arbitrary type which could be unrelated to 'unknown'. !!! error TS2318: Cannot find global type 'Array'. @@ -52,7 +52,7 @@ awaitedTypeNoLib.ts(18,27): error TS2345: Argument of type 'NotPromise !!! error TS2345: Type 'TResult | (TResult extends PromiseLike ? never : TResult)' is not assignable to type 'Thenable'. !!! error TS2345: Type 'Thenable & TResult' is not assignable to type 'Thenable'. !!! error TS2345: Type 'unknown' is not assignable to type 'TResult'. -!!! error TS2345: 'TResult' is constrained to be a subtype of 'unknown'. +!!! error TS2345: 'TResult' could be instantiated with an arbitrary type which could be unrelated to 'unknown'. } } diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt index 2505a1e4f6e74..aa2ae24033b16 100644 --- a/tests/baselines/reference/conditionalTypes1.errors.txt +++ b/tests/baselines/reference/conditionalTypes1.errors.txt @@ -20,9 +20,9 @@ conditionalTypes1.ts(29,5): error TS2322: Type 'T["x"]' is not assignable to typ Type 'string | undefined' is not assignable to type '{}'. Type 'undefined' is not assignable to type '{}'. conditionalTypes1.ts(103,5): error TS2322: Type 'FunctionProperties' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'FunctionProperties'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'FunctionProperties'. conditionalTypes1.ts(104,5): error TS2322: Type 'NonFunctionProperties' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'NonFunctionProperties'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'NonFunctionProperties'. conditionalTypes1.ts(106,5): error TS2322: Type 'NonFunctionProperties' is not assignable to type 'FunctionProperties'. Type 'FunctionPropertyNames' is not assignable to type 'NonFunctionPropertyNames'. Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. @@ -212,11 +212,11 @@ conditionalTypes1.ts(288,43): error TS2322: Type 'T95' is not assignable to t x = y; // Error ~ !!! error TS2322: Type 'FunctionProperties' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'FunctionProperties'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'FunctionProperties'. x = z; // Error ~ !!! error TS2322: Type 'NonFunctionProperties' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'NonFunctionProperties'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'NonFunctionProperties'. y = x; y = z; // Error ~ diff --git a/tests/baselines/reference/deeplyNestedMappedTypes.errors.txt b/tests/baselines/reference/deeplyNestedMappedTypes.errors.txt index a123a2c2dc807..d9cd2e20c31d8 100644 --- a/tests/baselines/reference/deeplyNestedMappedTypes.errors.txt +++ b/tests/baselines/reference/deeplyNestedMappedTypes.errors.txt @@ -9,7 +9,7 @@ deeplyNestedMappedTypes.ts(69,5): error TS2322: Type '{ level1: { level2: { foo: The types of 'level1.level2' are incompatible between these types. Property 'bar' is missing in type '{ foo: string; }' but required in type '{ foo: string; bar: string; }'. deeplyNestedMappedTypes.ts(73,5): error TS2322: Type '{ level1: { level2: { foo: string; }; }; }[]' is not assignable to type 'T'. - 'T' is constrained to be a subtype of '{ level1: { level2: { foo: string; }; }; }[]'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '{ level1: { level2: { foo: string; }; }; }[]'. deeplyNestedMappedTypes.ts(77,5): error TS2322: Type '{ level1: { level2: { foo: string; }; }; }[]' is not assignable to type '{ level1: { level2: { foo: string; bar: string; }; }; }[]'. Type '{ level1: { level2: { foo: string; }; }; }' is not assignable to type '{ level1: { level2: { foo: string; bar: string; }; }; }'. The types of 'level1.level2' are incompatible between these types. @@ -106,7 +106,7 @@ deeplyNestedMappedTypes.ts(77,5): error TS2322: Type '{ level1: { level2: { foo: return ors; // Error ~~~~~~ !!! error TS2322: Type '{ level1: { level2: { foo: string; }; }; }[]' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of '{ level1: { level2: { foo: string; }; }; }[]'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to '{ level1: { level2: { foo: string; }; }; }[]'. } function problematicFunction3(ors: (typeof Input.static)[]): Output[] { diff --git a/tests/baselines/reference/incompatibleAssignmentOfIdenticallyNamedTypes.errors.txt b/tests/baselines/reference/incompatibleAssignmentOfIdenticallyNamedTypes.errors.txt index 652beaac03c89..777a3d0da2633 100644 --- a/tests/baselines/reference/incompatibleAssignmentOfIdenticallyNamedTypes.errors.txt +++ b/tests/baselines/reference/incompatibleAssignmentOfIdenticallyNamedTypes.errors.txt @@ -1,5 +1,5 @@ incompatibleAssignmentOfIdenticallyNamedTypes.ts(6,9): error TS2719: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. - 'T' is constrained to be a subtype of 'T'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'. ==== incompatibleAssignmentOfIdenticallyNamedTypes.ts (1 errors) ==== @@ -11,7 +11,7 @@ incompatibleAssignmentOfIdenticallyNamedTypes.ts(6,9): error TS2719: Type 'T' is this.x = a; ~~~~~~ !!! error TS2719: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. -!!! error TS2719: 'T' is constrained to be a subtype of 'T'. +!!! error TS2719: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'. } } \ No newline at end of file diff --git a/tests/baselines/reference/indexedAccessRelation.errors.txt b/tests/baselines/reference/indexedAccessRelation.errors.txt index 59da7c7c25b81..b0b76c56ecf45 100644 --- a/tests/baselines/reference/indexedAccessRelation.errors.txt +++ b/tests/baselines/reference/indexedAccessRelation.errors.txt @@ -3,11 +3,7 @@ indexedAccessRelation.ts(16,23): error TS2345: Argument of type '{ a: T; }' is n Type 'T' is not assignable to type 'S["a"] & T'. Type 'Foo' is not assignable to type 'S["a"] & T'. Type 'Foo' is not assignable to type 'S["a"]'. - 'S["a"]' is constrained to be a subtype of 'Foo'. - Type 'T' is not assignable to type 'S["a"]'. - 'S["a"]' is constrained to be a subtype of 'T'. - Type 'Foo' is not assignable to type 'S["a"]'. - 'S["a"]' is constrained to be a subtype of 'Foo'. + 'S["a"]' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. ==== indexedAccessRelation.ts (1 errors) ==== @@ -33,11 +29,7 @@ indexedAccessRelation.ts(16,23): error TS2345: Argument of type '{ a: T; }' is n !!! error TS2345: Type 'T' is not assignable to type 'S["a"] & T'. !!! error TS2345: Type 'Foo' is not assignable to type 'S["a"] & T'. !!! error TS2345: Type 'Foo' is not assignable to type 'S["a"]'. -!!! error TS2345: 'S["a"]' is constrained to be a subtype of 'Foo'. -!!! error TS2345: Type 'T' is not assignable to type 'S["a"]'. -!!! error TS2345: 'S["a"]' is constrained to be a subtype of 'T'. -!!! error TS2345: Type 'Foo' is not assignable to type 'S["a"]'. -!!! error TS2345: 'S["a"]' is constrained to be a subtype of 'Foo'. +!!! error TS2345: 'S["a"]' 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/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index 64107e3a2fda6..66a109121f439 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -9,13 +9,9 @@ mappedTypeRelationships.ts(21,12): error TS2536: Type 'keyof U' cannot be used t mappedTypeRelationships.ts(25,5): error TS2536: Type 'K' cannot be used to index type 'T'. mappedTypeRelationships.ts(26,12): error TS2536: Type 'K' cannot be used to index type 'T'. mappedTypeRelationships.ts(30,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. - 'T[keyof T]' is constrained to be a subtype of 'T[keyof T] | undefined'. - Type 'undefined' is not assignable to type 'T[keyof T]'. - 'T[keyof T]' could be instantiated with an arbitrary type which could be unrelated to 'undefined'. + 'T[keyof T]' could be instantiated with an arbitrary type which could be unrelated to 'T[keyof T] | undefined'. mappedTypeRelationships.ts(35,5): error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. - 'T[K]' is constrained to be a subtype of 'T[K] | undefined'. - Type 'undefined' is not assignable to type 'T[K]'. - 'T[K]' could be instantiated with an arbitrary type which could be unrelated to 'undefined'. + 'T[K]' could be instantiated with an arbitrary type which could be unrelated to 'T[K] | undefined'. mappedTypeRelationships.ts(40,5): error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. 'T[keyof T]' could be instantiated with an arbitrary type which could be unrelated to 'U[keyof T] | undefined'. mappedTypeRelationships.ts(41,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. @@ -38,7 +34,7 @@ mappedTypeRelationships.ts(66,5): error TS2322: Type 'T[K]' is not assignable to 'U' is constrained to be a subtype of 'T'. mappedTypeRelationships.ts(66,5): error TS2542: Index signature in type 'Readonly' only permits reading. mappedTypeRelationships.ts(72,5): error TS2322: Type 'Partial' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Partial'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Partial'. mappedTypeRelationships.ts(78,5): error TS2322: Type 'Partial' is not assignable to type 'Partial'. mappedTypeRelationships.ts(88,5): error TS2322: Type 'Readonly' is not assignable to type 'Readonly'. mappedTypeRelationships.ts(127,5): error TS2322: Type 'Partial' is not assignable to type 'Identity'. @@ -128,9 +124,7 @@ mappedTypeRelationships.ts(168,5): error TS2322: Type '{ [P in K]: T[P]; }' is n x[k] = y[k]; // Error ~~~~ !!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. -!!! error TS2322: 'T[keyof T]' is constrained to be a subtype of 'T[keyof T] | undefined'. -!!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. -!!! error TS2322: 'T[keyof T]' could be instantiated with an arbitrary type which could be unrelated to 'undefined'. +!!! error TS2322: 'T[keyof T]' could be instantiated with an arbitrary type which could be unrelated to 'T[keyof T] | undefined'. y[k] = x[k]; } @@ -138,9 +132,7 @@ mappedTypeRelationships.ts(168,5): error TS2322: Type '{ [P in K]: T[P]; }' is n x[k] = y[k]; // Error ~~~~ !!! error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. -!!! error TS2322: 'T[K]' is constrained to be a subtype of 'T[K] | undefined'. -!!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. -!!! error TS2322: 'T[K]' could be instantiated with an arbitrary type which could be unrelated to 'undefined'. +!!! error TS2322: 'T[K]' could be instantiated with an arbitrary type which could be unrelated to 'T[K] | undefined'. y[k] = x[k]; } @@ -213,7 +205,7 @@ mappedTypeRelationships.ts(168,5): error TS2322: Type '{ [P in K]: T[P]; }' is n x = y; // Error ~ !!! error TS2322: Type 'Partial' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Partial'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Partial'. y = x; } diff --git a/tests/baselines/reference/mappedTypes6.errors.txt b/tests/baselines/reference/mappedTypes6.errors.txt index 14257ed419b0e..5138f66afc493 100644 --- a/tests/baselines/reference/mappedTypes6.errors.txt +++ b/tests/baselines/reference/mappedTypes6.errors.txt @@ -1,7 +1,7 @@ mappedTypes6.ts(23,5): error TS2322: Type 'T' is not assignable to type 'Required'. mappedTypes6.ts(24,5): error TS2322: Type 'Partial' is not assignable to type 'Required'. mappedTypes6.ts(27,5): error TS2322: Type 'Partial' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Partial'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Partial'. mappedTypes6.ts(37,5): error TS2322: Type 'Required' is not assignable to type 'Denullified'. Type 'T[P]' is not assignable to type 'NonNullable'. Type 'T[keyof T]' is not assignable to type 'NonNullable'. @@ -26,7 +26,7 @@ mappedTypes6.ts(39,5): error TS2322: Type 'Partial' is not assignable to type mappedTypes6.ts(42,5): error TS2322: Type 'T' is not assignable to type 'Required'. mappedTypes6.ts(43,5): error TS2322: Type 'Partial' is not assignable to type 'Required'. mappedTypes6.ts(47,5): error TS2322: Type 'Partial' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Partial'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Partial'. mappedTypes6.ts(56,5): error TS2322: Type '{}' is not assignable to type 'Denullified'. mappedTypes6.ts(57,5): error TS2322: Type '{}' is not assignable to type 'Required'. mappedTypes6.ts(58,5): error TS2322: Type '{}' is not assignable to type 'T'. @@ -75,7 +75,7 @@ mappedTypes6.ts(120,4): error TS2540: Cannot assign to 'b' because it is a read- y = z; // Error ~ !!! error TS2322: Type 'Partial' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Partial'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Partial'. z = x; z = y; z = z; @@ -128,7 +128,7 @@ mappedTypes6.ts(120,4): error TS2540: Cannot assign to 'b' because it is a read- y = z; // Error ~ !!! error TS2322: Type 'Partial' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Partial'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Partial'. z = w; z = x; z = y; diff --git a/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt b/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt index 925cc5708088c..c8b98bc4f1b05 100644 --- a/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt +++ b/tests/baselines/reference/nonPrimitiveConstraintOfIndexAccessType.errors.txt @@ -7,8 +7,7 @@ nonPrimitiveConstraintOfIndexAccessType.ts(9,5): error TS2322: Type 'string' is nonPrimitiveConstraintOfIndexAccessType.ts(12,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'. nonPrimitiveConstraintOfIndexAccessType.ts(15,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. - 'T[P]' is constrained to be a subtype of 'string'. - Type 'string' is not assignable to type 'never'. + 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'. nonPrimitiveConstraintOfIndexAccessType.ts(18,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'. nonPrimitiveConstraintOfIndexAccessType.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T[P]'. @@ -51,8 +50,7 @@ nonPrimitiveConstraintOfIndexAccessType.ts(30,5): error TS2322: Type 'string' is tp = s; ~~ !!! error TS2322: Type 'string' is not assignable to type 'T[P]'. -!!! error TS2322: 'T[P]' is constrained to be a subtype of 'string'. -!!! error TS2322: Type 'string' is not assignable to type 'never'. +!!! error TS2322: 'T[P]' could be instantiated with an arbitrary type which could be unrelated to 'string'. } function k(s: string, tp: T[P]): void { tp = s; diff --git a/tests/baselines/reference/recursiveConditionalTypes.errors.txt b/tests/baselines/reference/recursiveConditionalTypes.errors.txt index f8557cc07622a..56c443de21637 100644 --- a/tests/baselines/reference/recursiveConditionalTypes.errors.txt +++ b/tests/baselines/reference/recursiveConditionalTypes.errors.txt @@ -4,13 +4,7 @@ recursiveConditionalTypes.ts(20,5): error TS2322: Type '__Awaited' is not ass 'U' is constrained to be a subtype of 'T'. recursiveConditionalTypes.ts(21,5): error TS2322: Type 'T' is not assignable to type '__Awaited'. recursiveConditionalTypes.ts(22,5): error TS2322: Type '__Awaited' is not assignable to type 'T'. - 'T' is constrained to be a subtype of '__Awaited'. - Type 'T | (T extends PromiseLike ? __Awaited : T)' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'T | (T extends PromiseLike ? __Awaited : T)'. - Type 'T extends PromiseLike ? __Awaited : T' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'T extends PromiseLike ? __Awaited : T'. - Type 'unknown' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'unknown'. + 'T' could be instantiated with an arbitrary type which could be unrelated to '__Awaited'. recursiveConditionalTypes.ts(35,11): error TS2589: Type instantiation is excessively deep and possibly infinite. recursiveConditionalTypes.ts(47,12): error TS2589: Type instantiation is excessively deep and possibly infinite. recursiveConditionalTypes.ts(50,5): error TS2322: Type 'TupleOf' is not assignable to type 'TupleOf'. @@ -66,13 +60,7 @@ recursiveConditionalTypes.ts(169,5): error TS2322: Type 'number' is not assignab tx = ta; // Error ~~ !!! error TS2322: Type '__Awaited' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of '__Awaited'. -!!! error TS2322: Type 'T | (T extends PromiseLike ? __Awaited : T)' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'T | (T extends PromiseLike ? __Awaited : T)'. -!!! error TS2322: Type 'T extends PromiseLike ? __Awaited : T' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'T extends PromiseLike ? __Awaited : T'. -!!! error TS2322: Type 'unknown' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'unknown'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to '__Awaited'. } // Flattening arrays diff --git a/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt index b9b97d124b55f..4ffb55f7afd11 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer2.errors.txt @@ -6,7 +6,7 @@ subtypingWithNumericIndexer2.ts(24,27): error TS2344: Type 'Base' does not satis subtypingWithNumericIndexer2.ts(32,15): error TS2430: Interface 'B3' incorrectly extends interface 'A'. 'number' index signatures are incompatible. Type 'Base' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Base'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. subtypingWithNumericIndexer2.ts(36,15): error TS2430: Interface 'B4' incorrectly extends interface 'A'. 'number' index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. @@ -63,7 +63,7 @@ subtypingWithNumericIndexer2.ts(40,15): error TS2430: Interface 'B5' incorrec !!! error TS2430: Interface 'B3' incorrectly extends interface 'A'. !!! error TS2430: 'number' index signatures are incompatible. !!! error TS2430: Type 'Base' is not assignable to type 'T'. -!!! error TS2430: 'T' is constrained to be a subtype of 'Base'. +!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. [x: number]: Base; // error } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt index b70c4eb09304a..f08112dbb97cd 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer3.errors.txt @@ -6,7 +6,7 @@ subtypingWithNumericIndexer3.ts(24,23): error TS2344: Type 'Base' does not satis subtypingWithNumericIndexer3.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. 'number' index signatures are incompatible. Type 'Base' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Base'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. subtypingWithNumericIndexer3.ts(36,11): error TS2415: Class 'B4' incorrectly extends base class 'A'. 'number' index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. @@ -63,7 +63,7 @@ subtypingWithNumericIndexer3.ts(40,11): error TS2415: Class 'B5' incorrectly !!! error TS2415: Class 'B3' incorrectly extends base class 'A'. !!! error TS2415: 'number' index signatures are incompatible. !!! error TS2415: Type 'Base' is not assignable to type 'T'. -!!! error TS2415: 'T' is constrained to be a subtype of 'Base'. +!!! error TS2415: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. [x: number]: Base; // error } diff --git a/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt b/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt index ad49860dad7b3..b8e96c0d40243 100644 --- a/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt +++ b/tests/baselines/reference/subtypingWithNumericIndexer5.errors.txt @@ -5,7 +5,7 @@ subtypingWithNumericIndexer5.ts(11,7): error TS2420: Class 'B' incorrectly imple subtypingWithNumericIndexer5.ts(32,11): error TS2420: Class 'B3' incorrectly implements interface 'A'. 'string' and 'number' index signatures are incompatible. Type 'Base' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Base'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. subtypingWithNumericIndexer5.ts(36,11): error TS2420: Class 'B4' incorrectly implements interface 'A'. 'string' and 'number' index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. @@ -59,7 +59,7 @@ subtypingWithNumericIndexer5.ts(40,11): error TS2420: Class 'B5' incorrectly !!! error TS2420: Class 'B3' incorrectly implements interface 'A'. !!! error TS2420: 'string' and 'number' index signatures are incompatible. !!! error TS2420: Type 'Base' is not assignable to type 'T'. -!!! error TS2420: 'T' is constrained to be a subtype of 'Base'. +!!! error TS2420: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. [x: string]: Base; // error } diff --git a/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt index d5f786dcd6395..8a43b708b1946 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer2.errors.txt @@ -6,7 +6,7 @@ subtypingWithStringIndexer2.ts(24,27): error TS2344: Type 'Base' does not satisf subtypingWithStringIndexer2.ts(32,15): error TS2430: Interface 'B3' incorrectly extends interface 'A'. 'string' index signatures are incompatible. Type 'Base' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Base'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. subtypingWithStringIndexer2.ts(36,15): error TS2430: Interface 'B4' incorrectly extends interface 'A'. 'string' index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. @@ -63,7 +63,7 @@ subtypingWithStringIndexer2.ts(40,15): error TS2430: Interface 'B5' incorrect !!! error TS2430: Interface 'B3' incorrectly extends interface 'A'. !!! error TS2430: 'string' index signatures are incompatible. !!! error TS2430: Type 'Base' is not assignable to type 'T'. -!!! error TS2430: 'T' is constrained to be a subtype of 'Base'. +!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. [x: string]: Base; // error } diff --git a/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt b/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt index 9b4d9e0d56ce6..2097ececc0589 100644 --- a/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt +++ b/tests/baselines/reference/subtypingWithStringIndexer3.errors.txt @@ -6,7 +6,7 @@ subtypingWithStringIndexer3.ts(24,23): error TS2344: Type 'Base' does not satisf subtypingWithStringIndexer3.ts(32,11): error TS2415: Class 'B3' incorrectly extends base class 'A'. 'string' index signatures are incompatible. Type 'Base' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Base'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. subtypingWithStringIndexer3.ts(36,11): error TS2415: Class 'B4' incorrectly extends base class 'A'. 'string' index signatures are incompatible. Type 'Derived' is not assignable to type 'T'. @@ -63,7 +63,7 @@ subtypingWithStringIndexer3.ts(40,11): error TS2415: Class 'B5' incorrectly e !!! error TS2415: Class 'B3' incorrectly extends base class 'A'. !!! error TS2415: 'string' index signatures are incompatible. !!! error TS2415: Type 'Base' is not assignable to type 'T'. -!!! error TS2415: 'T' is constrained to be a subtype of 'Base'. +!!! error TS2415: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. [x: string]: Base; // error } diff --git a/tests/baselines/reference/typeParameterDiamond4.errors.txt b/tests/baselines/reference/typeParameterDiamond4.errors.txt index 1b2b47aecea0b..0a55ce915a378 100644 --- a/tests/baselines/reference/typeParameterDiamond4.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond4.errors.txt @@ -1,7 +1,5 @@ typeParameterDiamond4.ts(8,13): error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. - 'Top' is constrained to be a subtype of 'Top | T | U'. - Type 'T' is not assignable to type 'Top'. - 'Top' could be instantiated with an arbitrary type which could be unrelated to 'T'. + 'Top' could be instantiated with an arbitrary type which could be unrelated to 'Top | T | U'. typeParameterDiamond4.ts(10,13): error TS2322: Type 'Bottom' is not assignable to type 'Top'. 'Top' could be instantiated with an arbitrary type which could be unrelated to 'Bottom'. @@ -17,9 +15,7 @@ typeParameterDiamond4.ts(10,13): error TS2322: Type 'Bottom' is not assignable t top = middle; ~~~ !!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. -!!! error TS2322: 'Top' is constrained to be a subtype of 'Top | T | U'. -!!! error TS2322: Type 'T' is not assignable to type 'Top'. -!!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'T'. +!!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'Top | T | U'. !!! related TS2208 typeParameterDiamond4.ts:2:28: This type parameter might need an `extends Top` constraint. middle = bottom; top = bottom; diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt index 918d169884232..3241095401ef9 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt @@ -1,8 +1,7 @@ typeParametersShouldNotBeEqual.ts(4,5): error TS2322: Type 'U' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. typeParametersShouldNotBeEqual.ts(5,5): error TS2322: Type 'Object' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Object'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Object'. ==== typeParametersShouldNotBeEqual.ts (2 errors) ==== @@ -17,8 +16,7 @@ typeParametersShouldNotBeEqual.ts(5,5): error TS2322: Type 'Object' is not assig x = z; // Error ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Object'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Object'. z = x; // Ok } \ No newline at end of file diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt index d068e02754cc8..6f45110e9877c 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt @@ -9,8 +9,7 @@ typeParametersShouldNotBeEqual2.ts(7,5): error TS2322: Type 'V' is not assignabl typeParametersShouldNotBeEqual2.ts(8,5): error TS2322: Type 'U' is not assignable to type 'V'. 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'. typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type 'Object' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'Object'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? + 'T' could be instantiated with an arbitrary type which could be unrelated to 'Object'. ==== typeParametersShouldNotBeEqual2.ts (6 errors) ==== @@ -42,8 +41,7 @@ typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type 'Object' is not assi x = zz; // Error ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'Object'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Object'. zz = x; // Ok } \ No newline at end of file diff --git a/tests/baselines/reference/unionTypesAssignability.errors.txt b/tests/baselines/reference/unionTypesAssignability.errors.txt index 189daa072464a..8ce86faf58178 100644 --- a/tests/baselines/reference/unionTypesAssignability.errors.txt +++ b/tests/baselines/reference/unionTypesAssignability.errors.txt @@ -22,13 +22,9 @@ unionTypesAssignability.ts(64,5): error TS2322: Type 'U' is not assignable to ty unionTypesAssignability.ts(65,5): error TS2322: Type 'T' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. unionTypesAssignability.ts(70,5): error TS2322: Type 'T | U' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'T | U'. - Type 'U' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. unionTypesAssignability.ts(71,5): error TS2322: Type 'T | U' is not assignable to type 'U'. - 'U' is constrained to be a subtype of 'T | U'. - Type 'T' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. + 'U' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. ==== unionTypesAssignability.ts (19 errors) ==== @@ -154,16 +150,12 @@ unionTypesAssignability.ts(71,5): error TS2322: Type 'T | U' is not assignable t t = x; // error U not assignable to T ~ !!! error TS2322: Type 'T | U' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'T | U'. -!!! error TS2322: Type 'U' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. !!! related TS2208 unionTypesAssignability.ts:63:17: This type parameter might need an `extends T` constraint. u = x; // error T not assignable to U ~ !!! error TS2322: Type 'T | U' is not assignable to type 'U'. -!!! error TS2322: 'U' is constrained to be a subtype of 'T | U'. -!!! 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'. +!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. !!! related TS2208 unionTypesAssignability.ts:63:14: This type parameter might need an `extends U` constraint. } \ No newline at end of file diff --git a/tests/baselines/reference/variadicTuples1.errors.txt b/tests/baselines/reference/variadicTuples1.errors.txt index 74899ea264d16..bc68ea7f4476e 100644 --- a/tests/baselines/reference/variadicTuples1.errors.txt +++ b/tests/baselines/reference/variadicTuples1.errors.txt @@ -13,7 +13,7 @@ variadicTuples1.ts(152,5): error TS2322: Type '[string, ...T]' is not assignable 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[]'. variadicTuples1.ts(160,5): error TS2322: Type 'readonly [...T]' is not assignable to type 'T'. - 'T' is constrained to be a subtype of 'readonly [...T]'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'readonly [...T]'. variadicTuples1.ts(162,5): error TS4104: The type 'readonly [...T]' is 'readonly' and cannot be assigned to the mutable type '[...T]'. variadicTuples1.ts(169,5): error TS2322: Type 'readonly [...T]' is not assignable to type 'T'. 'readonly [...T]' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'readonly unknown[]'. @@ -233,7 +233,7 @@ variadicTuples1.ts(411,7): error TS2322: Type '[boolean, false]' is not assignab t = r; // Error ~ !!! error TS2322: Type 'readonly [...T]' is not assignable to type 'T'. -!!! error TS2322: 'T' is constrained to be a subtype of 'readonly [...T]'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'readonly [...T]'. m = t; m = r; // Error ~