diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b7d1a13c943b1..9bcdecdd5addf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17154,6 +17154,7 @@ namespace ts { ); } else { + errorInfo = undefined; reportError( Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt index 580529f6afa26..38e69a84cb80b 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance6.errors.txt @@ -45,8 +45,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Types of property 'a' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'. - Type 'Base' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance6.ts (7 errors) ==== @@ -152,7 +150,5 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. !!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'. -!!! error TS2430: Type 'Base' is not assignable to type 'T'. -!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. a16: (x: { a: T; b: T }) => T[]; } \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt index e6e558f9dbd65..fb07520a3d4d5 100644 --- a/tests/baselines/reference/conditionalTypes1.errors.txt +++ b/tests/baselines/reference/conditionalTypes1.errors.txt @@ -53,12 +53,6 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(159,5): error TS2 'ZeroOf' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to '0 | (T extends string ? "" : false)'. - Type 'number' is not assignable to type 'T'. - 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. - Type 'string | number' is not assignable to type 'T'. - 'string | number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. - Type 'string' is not assignable to type 'T'. - 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(160,5): error TS2322: Type 'T' is not assignable to type 'ZeroOf'. Type 'string | number' is not assignable to type 'ZeroOf'. Type 'string' is not assignable to type 'ZeroOf'. @@ -303,12 +297,6 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS !!! error TS2322: 'ZeroOf' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. !!! error TS2322: Type '0 | (T extends string ? "" : false)' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to '0 | (T extends string ? "" : false)'. -!!! error TS2322: Type 'number' is not assignable to type 'T'. -!!! error TS2322: 'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'T'. -!!! error TS2322: 'string | number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. -!!! error TS2322: Type 'string' is not assignable to type 'T'. -!!! error TS2322: 'string' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string | number'. y = x; // Error ~ !!! error TS2322: Type 'T' is not assignable to type 'ZeroOf'. diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt index 65c4b3963fb07..62a3cacb898d5 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance6.errors.txt @@ -45,8 +45,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Types of property 'a' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'. - Type 'Base' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance6.ts (7 errors) ==== @@ -152,7 +150,5 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. !!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'. -!!! error TS2430: Type 'Base' is not assignable to type 'T'. -!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. a16: new (x: { a: T; b: T }) => T[]; } \ No newline at end of file diff --git a/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.errors.txt b/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.errors.txt new file mode 100644 index 0000000000000..e01b5d483c9a5 --- /dev/null +++ b/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/doNotElaborateAssignabilityToTypeParameters.ts(3,3): error TS2322: Type 'T | Yadda' is not assignable to type 'T'. + 'T' could be instantiated with an arbitrary type which could be unrelated to 'T | Yadda'. + + +==== tests/cases/compiler/doNotElaborateAssignabilityToTypeParameters.ts (1 errors) ==== + async function foo(x: T): Promise { + let yaddable = await getXOrYadda(x); + return yaddable; + ~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'T | Yadda' is not assignable to type 'T'. +!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T | Yadda'. + } + + interface Yadda { + stuff: string, + things: string, + } + + declare function getXOrYadda(x: T): T | Yadda; + \ No newline at end of file diff --git a/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.js b/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.js new file mode 100644 index 0000000000000..8bb622be4f578 --- /dev/null +++ b/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.js @@ -0,0 +1,64 @@ +//// [doNotElaborateAssignabilityToTypeParameters.ts] +async function foo(x: T): Promise { + let yaddable = await getXOrYadda(x); + return yaddable; +} + +interface Yadda { + stuff: string, + things: string, +} + +declare function getXOrYadda(x: T): T | Yadda; + + +//// [doNotElaborateAssignabilityToTypeParameters.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +function foo(x) { + return __awaiter(this, void 0, void 0, function () { + var yaddable; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, getXOrYadda(x)]; + case 1: + yaddable = _a.sent(); + return [2 /*return*/, yaddable]; + } + }); + }); +} diff --git a/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.symbols b/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.symbols new file mode 100644 index 0000000000000..c44f1ac792b5c --- /dev/null +++ b/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/doNotElaborateAssignabilityToTypeParameters.ts === +async function foo(x: T): Promise { +>foo : Symbol(foo, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 0, 0)) +>T : Symbol(T, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 0, 19)) +>x : Symbol(x, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 0, 22)) +>T : Symbol(T, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 0, 19)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>T : Symbol(T, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 0, 19)) + + let yaddable = await getXOrYadda(x); +>yaddable : Symbol(yaddable, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 1, 5)) +>getXOrYadda : Symbol(getXOrYadda, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 8, 1)) +>x : Symbol(x, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 0, 22)) + + return yaddable; +>yaddable : Symbol(yaddable, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 1, 5)) +} + +interface Yadda { +>Yadda : Symbol(Yadda, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 3, 1)) + + stuff: string, +>stuff : Symbol(Yadda.stuff, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 5, 17)) + + things: string, +>things : Symbol(Yadda.things, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 6, 16)) +} + +declare function getXOrYadda(x: T): T | Yadda; +>getXOrYadda : Symbol(getXOrYadda, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 8, 1)) +>T : Symbol(T, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 10, 29)) +>x : Symbol(x, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 10, 32)) +>T : Symbol(T, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 10, 29)) +>T : Symbol(T, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 10, 29)) +>Yadda : Symbol(Yadda, Decl(doNotElaborateAssignabilityToTypeParameters.ts, 3, 1)) + diff --git a/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.types b/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.types new file mode 100644 index 0000000000000..52de160da5d7a --- /dev/null +++ b/tests/baselines/reference/doNotElaborateAssignabilityToTypeParameters.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/doNotElaborateAssignabilityToTypeParameters.ts === +async function foo(x: T): Promise { +>foo : (x: T) => Promise +>x : T + + let yaddable = await getXOrYadda(x); +>yaddable : T | Yadda +>await getXOrYadda(x) : T | Yadda +>getXOrYadda(x) : T | Yadda +>getXOrYadda : (x: T) => T | Yadda +>x : T + + return yaddable; +>yaddable : T | Yadda +} + +interface Yadda { + stuff: string, +>stuff : string + + things: string, +>things : string +} + +declare function getXOrYadda(x: T): T | Yadda; +>getXOrYadda : (x: T) => T | Yadda +>x : T + diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt index 545a8b47a7981..67733f98f4e93 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt @@ -4,8 +4,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericC 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(8,56): error TS2322: Type 'U' is not assignable to type 'V'. 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'. - Type 'T' is not assignable to type 'V'. - 'V' could be instantiated with an arbitrary type which could be unrelated to 'T'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts (3 errors) ==== @@ -26,6 +24,4 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericC ~~~~~~~~ !!! error TS2322: Type 'U' is not assignable to type 'V'. !!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'. -!!! error TS2322: Type 'T' is not assignable to type 'V'. -!!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'T'. function foo7(x: V, y: U = x) { } // should be ok \ No newline at end of file diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index efc1f20aec332..b37c9b83cfc15 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -20,9 +20,6 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2 Type 'T[string]' is not assignable to type 'U[keyof T]'. Type 'T' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. - Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. - Type 'T' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(45,5): error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. Type 'undefined' is not assignable to type 'T[K]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. @@ -32,12 +29,6 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2 Type 'T[string]' is not assignable to type 'U[K]'. Type 'T' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. - Type 'T[keyof T]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. - Type 'T[K]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(51,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(56,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(61,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. @@ -162,9 +153,6 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. !!! 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: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. -!!! 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'. } function f13(x: T, y: Partial, k: K) { @@ -181,12 +169,6 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. !!! 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: Type 'T[keyof T]' is not assignable to type 'U[K]'. -!!! 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: Type 'T[K]' is not assignable to type 'U[K]'. -!!! 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'. } function f20(x: T, y: Readonly, k: keyof T) { diff --git a/tests/baselines/reference/recursiveConditionalTypes.errors.txt b/tests/baselines/reference/recursiveConditionalTypes.errors.txt index b6b3425f01ead..c1ea1ab3338ee 100644 --- a/tests/baselines/reference/recursiveConditionalTypes.errors.txt +++ b/tests/baselines/reference/recursiveConditionalTypes.errors.txt @@ -5,12 +5,6 @@ tests/cases/compiler/recursiveConditionalTypes.ts(20,5): error TS2322: Type 'Awa tests/cases/compiler/recursiveConditionalTypes.ts(21,5): error TS2322: Type 'T' is not assignable to type 'Awaited'. tests/cases/compiler/recursiveConditionalTypes.ts(22,5): error TS2322: Type 'Awaited' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'Awaited'. - Type 'T | (T extends PromiseLike ? Awaited : T)' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'T | (T extends PromiseLike ? Awaited : T)'. - Type 'T extends PromiseLike ? Awaited : T' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'T extends PromiseLike ? Awaited : T'. - Type 'unknown' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'unknown'. tests/cases/compiler/recursiveConditionalTypes.ts(35,11): error TS2589: Type instantiation is excessively deep and possibly infinite. tests/cases/compiler/recursiveConditionalTypes.ts(46,12): error TS2589: Type instantiation is excessively deep and possibly infinite. tests/cases/compiler/recursiveConditionalTypes.ts(49,5): error TS2322: Type 'TupleOf' is not assignable to type 'TupleOf'. @@ -65,12 +59,6 @@ tests/cases/compiler/recursiveConditionalTypes.ts(116,9): error TS2345: Argument ~~ !!! error TS2322: Type 'Awaited' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Awaited'. -!!! error TS2322: Type 'T | (T extends PromiseLike ? Awaited : T)' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T | (T extends PromiseLike ? Awaited : T)'. -!!! error TS2322: Type 'T extends PromiseLike ? Awaited : T' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T extends PromiseLike ? Awaited : T'. -!!! error TS2322: Type 'unknown' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'unknown'. } // Flattening arrays diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt index 83de948f4b277..8365be247883e 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints.errors.txt @@ -6,8 +6,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'C3'. Type 'U' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. - Type 'V' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2416: Property 'foo' in type 'D11' is not assignable to the same property in base type 'C3'. Type 'V' is not assignable to type 'T'. @@ -113,8 +111,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'C3'. !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. -!!! error TS2416: Type 'V' is not assignable to type 'T'. -!!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'. } class D9 extends C3 { diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt index 4a4369d7c7bdf..f7b626f3ae73f 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt +++ b/tests/baselines/reference/subtypesOfTypeParameterWithRecursiveConstraints.errors.txt @@ -2,45 +2,31 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(68,9): error TS2416: Property 'foo' in type 'D2' is not assignable to the same property in base type 'Base'. Type 'U' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. - 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/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Base'. Type 'V' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'. - 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/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2416: Property 'foo' in type 'D4' is not assignable to the same property in base type 'Base'. Type 'T' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. - 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/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Base'. Type 'V' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'. - 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/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Base'. Type 'T' is not assignable to type 'V'. 'V' could be instantiated with an arbitrary type which could be unrelated to 'T'. - Type 'Foo' is not assignable to type 'V'. - 'V' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'Base'. Type 'U' is not assignable to type 'V'. 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'. - Type 'Foo' is not assignable to type 'V'. - 'V' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(115,9): error TS2416: Property 'foo' in type 'D1' is not assignable to the same property in base type 'Base2'. Type 'T' is not assignable to type 'Foo'. Type 'Foo' is not assignable to type 'Foo'. Type 'U' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. - 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/subtypesOfTypeParameterWithRecursiveConstraints.ts(120,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Base2'. @@ -48,40 +34,30 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf Type 'Foo' is not assignable to type 'Foo'. Type 'V' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'. - 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/subtypesOfTypeParameterWithRecursiveConstraints.ts(130,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(135,9): error TS2416: Property 'foo' in type 'D5' is not assignable to the same property in base type 'Base2'. Type 'U' is not assignable to type 'Foo'. Type 'Foo' is not assignable to type 'Foo'. Type 'T' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. - 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/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Base2'. Type 'V' is not assignable to type 'Foo'. Type 'Foo' is not assignable to type 'Foo'. Type 'V' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'. - 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/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2416: Property 'foo' in type 'D7' is not assignable to the same property in base type 'Base2'. Type 'T' is not assignable to type 'Foo'. Type 'Foo' is not assignable to type 'Foo'. Type 'U' is not assignable to type 'V'. 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'. - Type 'Foo' is not assignable to type 'V'. - 'V' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'Base2'. Type 'U' is not assignable to type 'Foo'. Type 'Foo' is not assignable to type 'Foo'. Type 'T' is not assignable to type 'V'. 'V' could be instantiated with an arbitrary type which could be unrelated to 'T'. - Type 'Foo' is not assignable to type 'V'. - 'V' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (24 errors) ==== @@ -159,8 +135,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D2' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. -!!! 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 D3, U extends Foo, V extends Foo> extends Base { @@ -172,8 +146,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D3' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'V' is not assignable to type 'T'. !!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'. -!!! 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 D4, U extends Foo, V extends Foo> extends Base { @@ -185,8 +157,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D4' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'T' is not assignable to type 'U'. !!! error TS2416: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. -!!! 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 D5, U extends Foo, V extends Foo> extends Base { @@ -203,8 +173,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D6' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'V' is not assignable to type 'U'. !!! error TS2416: 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'. -!!! 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 D7, U extends Foo, V extends Foo> extends Base { @@ -216,8 +184,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 'Base'. !!! error TS2416: Type 'T' is not assignable to type 'V'. !!! error TS2416: 'V' could be instantiated with an arbitrary type which could be unrelated to 'T'. -!!! error TS2416: Type 'Foo' is not assignable to type 'V'. -!!! error TS2416: 'V' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. } class D8, U extends Foo, V extends Foo> extends Base { @@ -229,8 +195,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Property 'foo' in type 'D8' is not assignable to the same property in base type 'Base'. !!! error TS2416: Type 'U' is not assignable to type 'V'. !!! error TS2416: 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'. -!!! error TS2416: Type 'Foo' is not assignable to type 'V'. -!!! error TS2416: 'V' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. } class D9, U extends Foo, V extends Foo> extends Base { @@ -254,8 +218,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2416: Type 'U' is not assignable to type 'T'. !!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. -!!! 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 D2, U extends Foo, V extends Foo> extends Base2 { @@ -276,8 +238,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2416: Type 'V' is not assignable to type 'T'. !!! error TS2416: 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'. -!!! 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 D4, U extends Foo, V extends Foo> extends Base2 { @@ -296,8 +256,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2416: Type 'T' is not assignable to type 'U'. !!! error TS2416: 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. -!!! 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 D6, U extends Foo, V extends Foo> extends Base2 { @@ -311,8 +269,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2416: Type 'V' is not assignable to type 'U'. !!! error TS2416: 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'. -!!! 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 D7, U extends Foo, V extends Foo> extends Base2 { @@ -326,8 +282,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2416: Type 'U' is not assignable to type 'V'. !!! error TS2416: 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'. -!!! error TS2416: Type 'Foo' is not assignable to type 'V'. -!!! error TS2416: 'V' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. } class D8, U extends Foo, V extends Foo> extends Base2 { @@ -341,8 +295,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf !!! error TS2416: Type 'Foo' is not assignable to type 'Foo'. !!! error TS2416: Type 'T' is not assignable to type 'V'. !!! error TS2416: 'V' could be instantiated with an arbitrary type which could be unrelated to 'T'. -!!! error TS2416: Type 'Foo' is not assignable to type 'V'. -!!! error TS2416: 'V' could be instantiated with an arbitrary type which could be unrelated to 'Foo'. } class D9, U extends Foo, V extends Foo> extends Base2 { diff --git a/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt b/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt index 7c91b4133fa9b..adb6a36c18b29 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt +++ b/tests/baselines/reference/subtypingWithConstructSignatures6.errors.txt @@ -45,8 +45,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW Types of property 'a' are incompatible. Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'. - Type 'Base' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures6.ts (7 errors) ==== @@ -152,7 +150,5 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW !!! error TS2430: Types of property 'a' are incompatible. !!! error TS2430: Type 'T' is not assignable to type 'T'. Two different types with this name exist, but they are unrelated. !!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'T'. -!!! error TS2430: Type 'Base' is not assignable to type 'T'. -!!! error TS2430: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Base'. a16: new (x: { a: T; b: T }) => T[]; } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAssignability2.errors.txt b/tests/baselines/reference/typeParameterAssignability2.errors.txt index 298be51f85c91..8e20983e7b578 100644 --- a/tests/baselines/reference/typeParameterAssignability2.errors.txt +++ b/tests/baselines/reference/typeParameterAssignability2.errors.txt @@ -4,8 +4,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(14,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'. - Type 'V' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(17,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/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(20,5): error TS2322: Type 'V' is not assignable to type 'U'. @@ -54,8 +52,6 @@ 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(70,5): error TS2322: Type 'T' is not assignable to type 'V'. 'V' could be instantiated with an arbitrary type which could be unrelated to 'T'. - Type 'U' is not assignable to type 'V'. - 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typeParameterAssignability2.ts(71,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'. @@ -84,8 +80,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara ~ !!! 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: Type 'V' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'V'. u = t; t = v; // error @@ -208,8 +202,6 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/typePara ~ !!! error TS2322: Type 'T' is not assignable to type 'V'. !!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'T'. -!!! error TS2322: Type 'U' is not assignable to type 'V'. -!!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'. v = u; // error ~ !!! error TS2322: Type 'U' is not assignable to type 'V'. diff --git a/tests/baselines/reference/typeParameterDiamond2.errors.txt b/tests/baselines/reference/typeParameterDiamond2.errors.txt index e5b97dd0cd4a4..e408519b06e86 100644 --- a/tests/baselines/reference/typeParameterDiamond2.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond2.errors.txt @@ -1,13 +1,7 @@ tests/cases/compiler/typeParameterDiamond2.ts(8,13): error TS2322: Type 'T | U' is not assignable to type 'Top'. 'Top' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. - Type 'U' is not assignable to type 'Top'. - 'Top' could be instantiated with an arbitrary type which could be unrelated to 'U'. tests/cases/compiler/typeParameterDiamond2.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'. - Type 'T | U' is not assignable to type 'Top'. - 'Top' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. - Type 'U' is not assignable to type 'Top'. - 'Top' could be instantiated with an arbitrary type which could be unrelated to 'U'. ==== tests/cases/compiler/typeParameterDiamond2.ts (2 errors) ==== @@ -22,17 +16,11 @@ tests/cases/compiler/typeParameterDiamond2.ts(10,13): error TS2322: Type 'Bottom ~~~ !!! error TS2322: Type 'T | U' is not assignable to type 'Top'. !!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. -!!! error TS2322: Type 'U' is not assignable to type 'Top'. -!!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'U'. middle = bottom; top = bottom; ~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'Top'. !!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'Bottom'. -!!! error TS2322: Type 'T | U' is not assignable to type 'Top'. -!!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. -!!! error TS2322: Type 'U' is not assignable to type 'Top'. -!!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'U'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterDiamond3.errors.txt b/tests/baselines/reference/typeParameterDiamond3.errors.txt index d60b2d6934630..01740e7c072c9 100644 --- a/tests/baselines/reference/typeParameterDiamond3.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond3.errors.txt @@ -1,24 +1,12 @@ tests/cases/compiler/typeParameterDiamond3.ts(8,13): error TS2322: Type 'T | U' is not assignable to type 'Top'. 'Top' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. - Type 'T' is not assignable to type 'Top'. - 'Top' could be instantiated with an arbitrary type which could be unrelated to 'T'. tests/cases/compiler/typeParameterDiamond3.ts(9,13): error TS2322: Type 'Bottom' is not assignable to type 'T | U'. Type 'Top | T | U' is not assignable to type 'T | U'. Type 'Top' is not assignable to type 'T | U'. Type 'Top' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'Top'. - Type 'Bottom' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'Bottom'. - Type 'Top | T | U' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'Top | T | U'. - Type 'Top' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'Top'. tests/cases/compiler/typeParameterDiamond3.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'. - Type 'Top | T | U' is not assignable to type 'Top'. - 'Top' could be instantiated with an arbitrary type which could be unrelated to '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'. ==== tests/cases/compiler/typeParameterDiamond3.ts (3 errors) ==== @@ -33,8 +21,6 @@ tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom ~~~ !!! error TS2322: Type 'T | U' is not assignable to type 'Top'. !!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to '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'. middle = bottom; ~~~~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'T | U'. @@ -42,20 +28,10 @@ tests/cases/compiler/typeParameterDiamond3.ts(10,13): error TS2322: Type 'Bottom !!! error TS2322: Type 'Top' is not assignable to type 'T | U'. !!! error TS2322: Type 'Top' is not assignable to type 'U'. !!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'Top'. -!!! error TS2322: Type 'Bottom' is not assignable to type 'U'. -!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'Bottom'. -!!! error TS2322: Type 'Top | T | U' is not assignable to type 'U'. -!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'Top | T | U'. -!!! error TS2322: Type 'Top' is not assignable to type 'U'. -!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'Top'. top = bottom; ~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'Top'. !!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'Bottom'. -!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. -!!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to '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'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterDiamond4.errors.txt b/tests/baselines/reference/typeParameterDiamond4.errors.txt index 6b24b69e41a96..147b3f1a183cd 100644 --- a/tests/baselines/reference/typeParameterDiamond4.errors.txt +++ b/tests/baselines/reference/typeParameterDiamond4.errors.txt @@ -1,13 +1,7 @@ tests/cases/compiler/typeParameterDiamond4.ts(8,13): error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. 'Top' could be instantiated with an arbitrary type which could be unrelated to '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'. tests/cases/compiler/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'. - Type 'Top | T | U' is not assignable to type 'Top'. - 'Top' could be instantiated with an arbitrary type which could be unrelated to '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'. ==== tests/cases/compiler/typeParameterDiamond4.ts (2 errors) ==== @@ -22,17 +16,11 @@ tests/cases/compiler/typeParameterDiamond4.ts(10,13): error TS2322: Type 'Bottom ~~~ !!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. !!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to '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'. middle = bottom; top = bottom; ~~~ !!! error TS2322: Type 'Bottom' is not assignable to type 'Top'. !!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to 'Bottom'. -!!! error TS2322: Type 'Top | T | U' is not assignable to type 'Top'. -!!! error TS2322: 'Top' could be instantiated with an arbitrary type which could be unrelated to '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'. } } } \ No newline at end of file diff --git a/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt b/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt index c8e48a06898e5..b2a497ab682b5 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual.errors.txt @@ -2,7 +2,6 @@ tests/cases/compiler/typeParametersShouldNotBeEqual.ts(4,5): error TS2322: Type 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. tests/cases/compiler/typeParametersShouldNotBeEqual.ts(5,5): error TS2322: Type 'Object' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'Object'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? ==== tests/cases/compiler/typeParametersShouldNotBeEqual.ts (2 errors) ==== @@ -17,7 +16,6 @@ tests/cases/compiler/typeParametersShouldNotBeEqual.ts(5,5): error TS2322: Type ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Object'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? 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 3aafc6c37142f..0f169ca1ee774 100644 --- a/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt +++ b/tests/baselines/reference/typeParametersShouldNotBeEqual2.errors.txt @@ -6,17 +6,12 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(5,5): error TS2322: Type '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'. 'V' could be instantiated with an arbitrary type which could be unrelated to 'T'. - Type 'Date' is not assignable to type 'V'. - 'V' could be instantiated with an arbitrary type which could be unrelated to 'Date'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(7,5): error TS2322: Type 'V' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'V'. tests/cases/compiler/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'. - Type 'Date' is not assignable to type 'V'. - 'V' could be instantiated with an arbitrary type which could be unrelated to 'Date'. tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type 'Object' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'Object'. - The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? ==== tests/cases/compiler/typeParametersShouldNotBeEqual2.ts (6 errors) ==== @@ -37,8 +32,6 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type ~ !!! error TS2322: Type 'T' is not assignable to type 'V'. !!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'T'. -!!! error TS2322: Type 'Date' is not assignable to type 'V'. -!!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'Date'. y = z; // Error ~ !!! error TS2322: Type 'V' is not assignable to type 'U'. @@ -47,13 +40,10 @@ tests/cases/compiler/typeParametersShouldNotBeEqual2.ts(9,5): error TS2322: Type ~ !!! error TS2322: Type 'U' is not assignable to type 'V'. !!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'U'. -!!! error TS2322: Type 'Date' is not assignable to type 'V'. -!!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'Date'. x = zz; // Error ~ !!! error TS2322: Type 'Object' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'Object'. -!!! error TS2322: The 'Object' type is assignable to very few other types. Did you mean to use the 'any' type instead? 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 aad3842661244..fc5ca87725566 100644 --- a/tests/baselines/reference/unionTypesAssignability.errors.txt +++ b/tests/baselines/reference/unionTypesAssignability.errors.txt @@ -24,12 +24,8 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTyp 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(70,5): error TS2322: Type 'T | U' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. - Type 'U' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts(71,5): error TS2322: Type 'T | U' is not assignable to type 'U'. 'U' could be instantiated with an arbitrary type which could be unrelated to 'T | U'. - Type 'T' is not assignable to type 'U'. - 'U' could be instantiated with an arbitrary type which could be unrelated to 'T'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTypesAssignability.ts (19 errors) ==== @@ -151,13 +147,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/unionTyp ~ !!! error TS2322: Type 'T | U' is not assignable to type 'T'. !!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to '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'. u = x; // error T not assignable to U ~ !!! error TS2322: Type 'T | U' is not assignable to type 'U'. !!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to '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'. } \ No newline at end of file diff --git a/tests/cases/compiler/doNotElaborateAssignabilityToTypeParameters.ts b/tests/cases/compiler/doNotElaborateAssignabilityToTypeParameters.ts new file mode 100644 index 0000000000000..58845a01fc174 --- /dev/null +++ b/tests/cases/compiler/doNotElaborateAssignabilityToTypeParameters.ts @@ -0,0 +1,13 @@ +// @lib: es2015 +// @target: ES5 +async function foo(x: T): Promise { + let yaddable = await getXOrYadda(x); + return yaddable; +} + +interface Yadda { + stuff: string, + things: string, +} + +declare function getXOrYadda(x: T): T | Yadda;