diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt index 28fe7c738a6..441810033d2 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt @@ -45,6 +45,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Property 'baz' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(83,1): error TS2322: Type '(x: Base[], y: Derived[]) => Derived[]' is not assignable to type '(x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(85,1): error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => Object'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(86,1): error TS2322: Type '(x: { a: string; b: number; }) => Object' is not assignable to type '(x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -52,7 +57,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'string'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts (14 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts (15 errors) ==== // these are all permitted with the current rules, since we do not do contextual signature instantiation class Base { foo: string; } @@ -198,6 +203,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. var b14: (x: { a: T; b: T }) => T; a14 = b14; // ok + ~~~ +!!! error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => Object'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b14 = a14; // ok ~~~ !!! error TS2322: Type '(x: { a: string; b: number; }) => Object' is not assignable to type '(x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt index 39d3a2a3593..0a2ae478989 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt @@ -22,8 +22,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/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'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(69,9): error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(70,9): error TS2322: Type '(x: { a: string; b: number; }) => number' is not assignable to type '(x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -156,8 +158,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a15 = b15; ~~~ !!! error TS2322: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b15 = a15; ~~~ !!! error TS2322: Type '(x: { a: string; b: number; }) => number' is not assignable to type '(x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt index ba8f5304aa2..57944ae9863 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures5.errors.txt @@ -1,9 +1,15 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(40,1): error TS2322: Type '(x: T) => void' is not assignable to type '(x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(52,1): error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(55,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. - Type '(U | V)[]' is not assignable to type 'U[]'. - Type 'U | V' is not assignable to type 'U'. - Type 'V' is not assignable to type 'U'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. + Types of property 'b' are incompatible. + Type 'V' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts(58,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -11,7 +17,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'U' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts (3 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures5.ts (4 errors) ==== // checking assignment compat for function types. No errors in this file class Base { foo: string; } @@ -67,14 +73,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; a11 = b11; // ok b11 = a11; // ok + ~~~ +!!! error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b15: (x: { a: U; b: V; }) => U[]; a15 = b15; // ok, T = U, T = V b15 = a15; // ok ~~~ !!! error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: U; b: V; }) => U[]'. -!!! error TS2322: Type '(U | V)[]' is not assignable to type 'U[]'. -!!! error TS2322: Type 'U | V' is not assignable to type 'U'. -!!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'V' is not assignable to type 'U'. var b16: (x: { a: T; b: T }) => T[]; a15 = b16; // ok b15 = a16; // ok diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt index b8399a1855b..e3d7fda7ba3 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures6.errors.txt @@ -1,5 +1,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(30,1): error TS2322: Type '(x: T) => void' is not assignable to type '(x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(39,1): error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts(42,1): error TS2322: Type '(x: { a: T; b: T; }) => T[]' is not assignable to type '(x: { a: T; b: T; }) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -7,7 +12,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts (2 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures6.ts (3 errors) ==== // checking assignment compatibility relations for function types. All valid class Base { foo: string; } @@ -50,6 +55,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: (x: { foo: T }, y: { foo: U; bar: U }) => Base; x.a11 = b11; b11 = x.a11; + ~~~ +!!! error TS2322: Type '(x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type '(x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b16: (x: { a: T; b: T }) => T[]; x.a16 = b16; b16 = x.a16; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt index f9a5be732c9..3bce93635d0 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt @@ -45,6 +45,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Property 'baz' is missing in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(83,1): error TS2322: Type 'new (x: Base[], y: Derived[]) => Derived[]' is not assignable to type 'new (x: Base[], y: T) => T'. Type 'Derived[]' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(85,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => Object'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(86,1): error TS2322: Type 'new (x: { a: string; b: number; }) => Object' is not assignable to type 'new (x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -52,7 +57,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'string'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts (14 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts (15 errors) ==== // checking assignment compatibility relations for function types. All of these are valid. class Base { foo: string; } @@ -198,6 +203,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'Derived[]' is not assignable to type 'T'. var b14: new (x: { a: T; b: T }) => T; a14 = b14; // ok + ~~~ +!!! error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => Object'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b14 = a14; // ok ~~~ !!! error TS2322: Type 'new (x: { a: string; b: number; }) => Object' is not assignable to type 'new (x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 8679b1d85f1..620e83e1603 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -22,8 +22,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/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'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/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'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(70,9): error TS2322: Type 'new (x: { a: string; b: number; }) => number' is not assignable to type 'new (x: { a: T; b: T; }) => T'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: string; b: number; }'. @@ -172,8 +174,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a15 = b15; // ok ~~~ !!! error TS2322: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. -!!! error TS2322: Type 'string | number' is not assignable to type 'number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b15 = a15; // ok ~~~ !!! error TS2322: Type 'new (x: { a: string; b: number; }) => number' is not assignable to type 'new (x: { a: T; b: T; }) => T'. diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt index 23e0c682fdc..5445d9ee35a 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures5.errors.txt @@ -1,9 +1,15 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(40,1): error TS2322: Type 'new (x: T) => void' is not assignable to type 'new (x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(52,1): error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(55,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. - Type '(U | V)[]' is not assignable to type 'U[]'. - Type 'U | V' is not assignable to type 'U'. - Type 'V' is not assignable to type 'U'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. + Types of property 'b' are incompatible. + Type 'V' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts(58,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: U; b: V; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -11,7 +17,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'U' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts (3 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures5.ts (4 errors) ==== // checking assignment compat for function types. All valid class Base { foo: string; } @@ -67,14 +73,21 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; a11 = b11; // ok b11 = a11; // ok + ~~~ +!!! error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b15: new (x: { a: U; b: V; }) => U[]; a15 = b15; // ok b15 = a15; // ok ~~~ !!! error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: U; b: V; }) => U[]'. -!!! error TS2322: Type '(U | V)[]' is not assignable to type 'U[]'. -!!! error TS2322: Type 'U | V' is not assignable to type 'U'. -!!! error TS2322: Type 'V' is not assignable to type 'U'. +!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2322: Type '{ a: U; b: V; }' is not assignable to type '{ a: U; b: U; }'. +!!! error TS2322: Types of property 'b' are incompatible. +!!! error TS2322: Type 'V' is not assignable to type 'U'. var b16: new (x: { a: T; b: T }) => T[]; a15 = b16; // ok b15 = a16; // ok diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt index f89db500202..399a56e4136 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures6.errors.txt @@ -1,5 +1,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(30,1): error TS2322: Type 'new (x: T) => void' is not assignable to type 'new (x: T) => T'. Type 'void' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(39,1): error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. + Types of parameters 'y' and 'y' are incompatible. + Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. + Types of property 'foo' are incompatible. + Type 'U' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts(42,1): error TS2322: Type 'new (x: { a: T; b: T; }) => T[]' is not assignable to type 'new (x: { a: T; b: T; }) => T[]'. Types of parameters 'x' and 'x' are incompatible. Type '{ a: T; b: T; }' is not assignable to type '{ a: Base; b: Base; }'. @@ -7,7 +12,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme Type 'T' is not assignable to type 'Base'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts (2 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures6.ts (3 errors) ==== // checking assignment compatibility relations for function types. All valid. class Base { foo: string; } @@ -50,6 +55,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var b11: new (x: { foo: T }, y: { foo: U; bar: U }) => Base; x.a11 = b11; b11 = x.a11; + ~~~ +!!! error TS2322: Type 'new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base' is not assignable to type 'new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type '{ foo: U; bar: U; }' is not assignable to type '{ foo: T; bar: T; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'U' is not assignable to type 'T'. var b16: new (x: { a: T; b: T }) => T[]; x.a16 = b16; b16 = x.a16; diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt index 7e39c3305a3..38f03ca68c4 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.errors.txt @@ -1,9 +1,12 @@ +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts(15,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of parameters 'y' and 'y' are incompatible. + Type 'T[]' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts(16,1): error TS2322: Type 'A' is not assignable to type 'B'. Types of parameters 'y' and 'y' are incompatible. Type 'S' is not assignable to type 'S[]'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts (1 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts (2 errors) ==== // some complex cases of assignment compat of generic signatures. No contextual signature instantiation interface A { @@ -17,8 +20,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme var a: A; var b: B; - // Both ok + // Both errors a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2322: Type 'T[]' is not assignable to type 'T'. b = a; ~ !!! error TS2322: Type 'A' is not assignable to type 'B'. diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js index dd9b553791d..057cbebb382 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.js @@ -12,7 +12,7 @@ interface B { var a: A; var b: B; -// Both ok +// Both errors a = b; b = a; @@ -21,6 +21,6 @@ b = a; // some complex cases of assignment compat of generic signatures. No contextual signature instantiation var a; var b; -// Both ok +// Both errors a = b; b = a; diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols index 73991a789a2..9a37bebd6e2 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.symbols @@ -31,7 +31,7 @@ var b: B; >b : Symbol(b, Decl(assignmentCompatWithGenericCallSignatures2.ts, 11, 3)) >B : Symbol(B, Decl(assignmentCompatWithGenericCallSignatures2.ts, 4, 1)) -// Both ok +// Both errors a = b; >a : Symbol(a, Decl(assignmentCompatWithGenericCallSignatures2.ts, 10, 3)) >b : Symbol(b, Decl(assignmentCompatWithGenericCallSignatures2.ts, 11, 3)) diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types index 31b075d5bce..ab5bc2d49e8 100644 --- a/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignatures2.types @@ -19,7 +19,7 @@ var a: A; var b: B; >b : B -// Both ok +// Both errors a = b; >a = b : B >a : A diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js index 6913975d757..fe8f9330a5f 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.js @@ -62,7 +62,7 @@ interface I extends A { a11: (x: T, y: T) => T; // ok a12: >(x: Array, y: T) => Array; // ok, less specific parameter type a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok a15: (x: T) => T[]; // ok a16: (x: T) => number[]; // ok a17: (x: (a: T) => T) => T[]; // ok diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols index 849bcb1cf60..14e25b4e9d9 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.symbols @@ -354,18 +354,19 @@ interface I extends A { >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 10)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 10)) - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(callSignatureAssignabilityInInheritance2.ts, 62, 63)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) ->x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 13)) ->a : Symbol(a, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 17)) ->T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) ->b : Symbol(b, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 23)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 12)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 16)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 20)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) +>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 26)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 12)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 10)) a15: (x: T) => T[]; // ok ->a15 : Symbol(I.a15, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 37)) +>a15 : Symbol(I.a15, Decl(callSignatureAssignabilityInInheritance2.ts, 63, 40)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 64, 10)) >x : Symbol(x, Decl(callSignatureAssignabilityInInheritance2.ts, 64, 13)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance2.ts, 64, 10)) diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types index ab6daaf8b5b..065d0027ed3 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance2.types @@ -230,11 +230,11 @@ interface I extends A { >x : Base[] >y : T - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: (x: { a: T; b: U }) => T; // ok +>a14 : (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U a15: (x: T) => T[]; // ok >a15 : (x: T) => T[] diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt index 5bf725b06e3..33af0d9f4bf 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt @@ -14,8 +14,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(76,19): error TS2430: Interface 'I6' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts(80,19): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type '(x: { a: T; b: T; }) => number' is not assignable to type '(x: { a: string; b: number; }) => number'. @@ -131,8 +133,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Interface 'I6' incorrectly extends interface 'A'. !!! error TS2430: Types of property 'a15' are incompatible. !!! error TS2430: Type '(x: { a: T; b: T; }) => T' is not assignable to type '(x: { a: string; b: number; }) => number'. -!!! error TS2430: Type 'string | number' is not assignable to type 'number'. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2430: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2430: Types of property 'b' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. a15: (x: { a: T; b: T }) => T; // error, T is {} which isn't an acceptable return type } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js index c04d5bcb2ab..9d7dbc9eab6 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.js @@ -45,7 +45,7 @@ interface I extends B { a11: (x: T, y: T) => T; // ok a12: >(x: Array, y: T) => Array; // ok, less specific parameter type a13: >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok } //// [callSignatureAssignabilityInInheritance5.js] diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols index 4a9030e443b..de3bdf742d0 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.symbols @@ -302,13 +302,14 @@ interface I extends B { >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 10)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 10)) - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(callSignatureAssignabilityInInheritance5.ts, 45, 63)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) ->x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 13)) ->a : Symbol(a, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 17)) ->T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) ->b : Symbol(b, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 23)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 12)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 16)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 20)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) +>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 26)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 12)) >T : Symbol(T, Decl(callSignatureAssignabilityInInheritance5.ts, 46, 10)) } diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types index 2d133bc6d65..3f892ff0b17 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance5.types @@ -180,9 +180,9 @@ interface I extends B { >x : Base[] >y : T - a14: (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: (x: { a: T; b: U }) => T; // ok +>a14 : (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js index 0c4b5c62380..a85f64f95a1 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.js @@ -62,7 +62,7 @@ interface I extends A { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok a15: new (x: T) => T[]; // ok a16: new (x: T) => number[]; // ok a17: new (x: new (a: T) => T) => T[]; // ok diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols index 1ad1c3707c5..2aaa5eda84f 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.symbols @@ -354,18 +354,19 @@ interface I extends A { >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 62, 14)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 62, 14)) - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(constructSignatureAssignabilityInInheritance2.ts, 62, 67)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) ->x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 17)) ->a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 21)) ->T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) ->b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 27)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 16)) +>x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 20)) +>a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 24)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) +>b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 30)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 16)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 14)) a15: new (x: T) => T[]; // ok ->a15 : Symbol(I.a15, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 41)) +>a15 : Symbol(I.a15, Decl(constructSignatureAssignabilityInInheritance2.ts, 63, 44)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 64, 14)) >x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance2.ts, 64, 17)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance2.ts, 64, 14)) diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types index 01941d5219b..08a687d8867 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance2.types @@ -230,11 +230,11 @@ interface I extends A { >x : Base[] >y : T - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : new (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: new (x: { a: T; b: U }) => T; // ok +>a14 : new (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U a15: new (x: T) => T[]; // ok >a15 : new (x: T) => T[] diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt index 9646acd071f..1a9edc159af 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt @@ -14,8 +14,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(66,19): error TS2430: Interface 'I6' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. - Type 'string | number' is not assignable to type 'number'. - Type 'string' is not assignable to type 'number'. + Types of parameters 'x' and 'x' are incompatible. + Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. + Types of property 'b' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts(70,19): error TS2430: Interface 'I7' incorrectly extends interface 'A'. Types of property 'a15' are incompatible. Type 'new (x: { a: T; b: T; }) => number' is not assignable to type 'new (x: { a: string; b: number; }) => number'. @@ -121,8 +123,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Interface 'I6' incorrectly extends interface 'A'. !!! error TS2430: Types of property 'a15' are incompatible. !!! error TS2430: Type 'new (x: { a: T; b: T; }) => T' is not assignable to type 'new (x: { a: string; b: number; }) => number'. -!!! error TS2430: Type 'string | number' is not assignable to type 'number'. -!!! error TS2430: Type 'string' is not assignable to type 'number'. +!!! error TS2430: Types of parameters 'x' and 'x' are incompatible. +!!! error TS2430: Type '{ a: string; b: number; }' is not assignable to type '{ a: string; b: string; }'. +!!! error TS2430: Types of property 'b' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. a15: new (x: { a: T; b: T }) => T; // error, T is {} which isn't an acceptable return type } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js index d81722fc950..8431b225440 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.js @@ -45,7 +45,7 @@ interface I extends B { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok } //// [constructSignatureAssignabilityInInheritance5.js] diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols index e1991673f98..c08d7537f65 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.symbols @@ -302,13 +302,14 @@ interface I extends B { >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 45, 14)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 45, 14)) - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(constructSignatureAssignabilityInInheritance5.ts, 45, 67)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) ->x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 17)) ->a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 21)) ->T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) ->b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 27)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 16)) +>x : Symbol(x, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 20)) +>a : Symbol(a, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 24)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) +>b : Symbol(b, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 30)) +>U : Symbol(U, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 16)) >T : Symbol(T, Decl(constructSignatureAssignabilityInInheritance5.ts, 46, 14)) } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types index 0397a78f678..9296ce8295d 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance5.types @@ -180,9 +180,9 @@ interface I extends B { >x : Base[] >y : T - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : new (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: new (x: { a: T; b: U }) => T; // ok +>a14 : new (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U } diff --git a/tests/baselines/reference/contextualSignatureInstantiation.errors.txt b/tests/baselines/reference/contextualSignatureInstantiation.errors.txt new file mode 100644 index 00000000000..6c14ad3c150 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInstantiation.errors.txt @@ -0,0 +1,53 @@ +tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts(19,13): error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. + Types of parameters 'y' and 'y' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts(20,23): error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. + Types of parameters 'y' and 'y' are incompatible. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts(21,23): error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: string, y: number) => string'. + Types of parameters 'y' and 'y' are incompatible. + Type 'number' is not assignable to type 'string'. + + +==== tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts (3 errors) ==== + // TypeScript Spec, section 4.12.2: + // If e is an expression of a function type that contains exactly one generic call signature and no other members, + // and T is a function type with exactly one non - generic call signature and no other members, then any inferences + // made for type parameters referenced by the parameters of T's call signature are fixed, and e's type is changed + // to a function type with e's call signature instantiated in the context of T's call signature (section 3.8.5). + + declare function foo(cb: (x: number, y: string) => T): T; + declare function bar(x: T, y: U, cb: (x: T, y: U) => V): V; + declare function baz(x: T, y: T, cb: (x: T, y: T) => U): U; + + declare function g(x: T, y: T): T; + declare function h(x: T, y: U): T[] | U[]; + + var a: number; + var a = bar(1, 1, g); // Should be number + var a = baz(1, 1, g); // Should be number + + var b: number | string; + var b = foo(g); // Error, number and string are disjoint types + ~ +!!! error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. +!!! error TS2345: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + var b = bar(1, "one", g); // Error, number and string are disjoint types + ~ +!!! error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: number, y: string) => number'. +!!! error TS2345: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + var b = bar("one", 1, g); // Error, number and string are disjoint types + ~ +!!! error TS2345: Argument of type '(x: T, y: T) => T' is not assignable to parameter of type '(x: string, y: number) => string'. +!!! error TS2345: Types of parameters 'y' and 'y' are incompatible. +!!! error TS2345: Type 'number' is not assignable to type 'string'. + var b = baz(b, b, g); // Should be number | string + + var d: number[] | string[]; + var d = foo(h); // Should be number[] | string[] + var d = bar(1, "one", h); // Should be number[] | string[] + var d = bar("one", 1, h); // Should be number[] | string[] + var d = baz(d, d, g); // Should be number[] | string[] + \ No newline at end of file diff --git a/tests/baselines/reference/contextualSignatureInstantiation.js b/tests/baselines/reference/contextualSignatureInstantiation.js index 11e19b3262e..d945592bbda 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.js +++ b/tests/baselines/reference/contextualSignatureInstantiation.js @@ -17,9 +17,9 @@ var a = bar(1, 1, g); // Should be number var a = baz(1, 1, g); // Should be number var b: number | string; -var b = foo(g); // Should be number | string -var b = bar(1, "one", g); // Should be number | string -var b = bar("one", 1, g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types +var b = bar(1, "one", g); // Error, number and string are disjoint types +var b = bar("one", 1, g); // Error, number and string are disjoint types var b = baz(b, b, g); // Should be number | string var d: number[] | string[]; @@ -39,9 +39,9 @@ var a; var a = bar(1, 1, g); // Should be number var a = baz(1, 1, g); // Should be number var b; -var b = foo(g); // Should be number | string -var b = bar(1, "one", g); // Should be number | string -var b = bar("one", 1, g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types +var b = bar(1, "one", g); // Error, number and string are disjoint types +var b = bar("one", 1, g); // Error, number and string are disjoint types var b = baz(b, b, g); // Should be number | string var d; var d = foo(h); // Should be number[] | string[] diff --git a/tests/baselines/reference/contextualSignatureInstantiation.symbols b/tests/baselines/reference/contextualSignatureInstantiation.symbols index c16ffed84b7..742ae58905c 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.symbols +++ b/tests/baselines/reference/contextualSignatureInstantiation.symbols @@ -83,17 +83,17 @@ var a = baz(1, 1, g); // Should be number var b: number | string; >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) -var b = foo(g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) >foo : Symbol(foo, Decl(contextualSignatureInstantiation.ts, 0, 0)) >g : Symbol(g, Decl(contextualSignatureInstantiation.ts, 8, 65)) -var b = bar(1, "one", g); // Should be number | string +var b = bar(1, "one", g); // Error, number and string are disjoint types >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) >bar : Symbol(bar, Decl(contextualSignatureInstantiation.ts, 6, 60)) >g : Symbol(g, Decl(contextualSignatureInstantiation.ts, 8, 65)) -var b = bar("one", 1, g); // Should be number | string +var b = bar("one", 1, g); // Error, number and string are disjoint types >b : Symbol(b, Decl(contextualSignatureInstantiation.ts, 17, 3), Decl(contextualSignatureInstantiation.ts, 18, 3), Decl(contextualSignatureInstantiation.ts, 19, 3), Decl(contextualSignatureInstantiation.ts, 20, 3), Decl(contextualSignatureInstantiation.ts, 21, 3)) >bar : Symbol(bar, Decl(contextualSignatureInstantiation.ts, 6, 60)) >g : Symbol(g, Decl(contextualSignatureInstantiation.ts, 8, 65)) diff --git a/tests/baselines/reference/contextualSignatureInstantiation.types b/tests/baselines/reference/contextualSignatureInstantiation.types index 0f8c1ed49ba..ae5a4000537 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.types +++ b/tests/baselines/reference/contextualSignatureInstantiation.types @@ -59,23 +59,23 @@ var a = baz(1, 1, g); // Should be number var b: number | string; >b : string | number -var b = foo(g); // Should be number | string +var b = foo(g); // Error, number and string are disjoint types >b : string | number ->foo(g) : string | number +>foo(g) : any >foo : (cb: (x: number, y: string) => T) => T >g : (x: T, y: T) => T -var b = bar(1, "one", g); // Should be number | string +var b = bar(1, "one", g); // Error, number and string are disjoint types >b : string | number ->bar(1, "one", g) : string | number +>bar(1, "one", g) : any >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V >1 : 1 >"one" : "one" >g : (x: T, y: T) => T -var b = bar("one", 1, g); // Should be number | string +var b = bar("one", 1, g); // Error, number and string are disjoint types >b : string | number ->bar("one", 1, g) : string | number +>bar("one", 1, g) : any >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V >"one" : "one" >1 : 1 diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.errors.txt b/tests/baselines/reference/contextualSignatureInstatiationContravariance.errors.txt new file mode 100644 index 00000000000..fe9c6cf3f14 --- /dev/null +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/contextualSignatureInstatiationContravariance.ts(8,1): error TS2322: Type '(x: T, y: T) => void' is not assignable to type '(g: Giraffe, e: Elephant) => void'. + Types of parameters 'y' and 'e' are incompatible. + Type 'Elephant' is not assignable to type 'Giraffe'. + Property 'y' is missing in type 'Elephant'. + + +==== tests/cases/compiler/contextualSignatureInstatiationContravariance.ts (1 errors) ==== + interface Animal { x } + interface Giraffe extends Animal { y } + interface Elephant extends Animal { y2 } + + var f2: (x: T, y: T) => void; + + var g2: (g: Giraffe, e: Elephant) => void; + g2 = f2; // error because Giraffe and Elephant are disjoint types + ~~ +!!! error TS2322: Type '(x: T, y: T) => void' is not assignable to type '(g: Giraffe, e: Elephant) => void'. +!!! error TS2322: Types of parameters 'y' and 'e' are incompatible. +!!! error TS2322: Type 'Elephant' is not assignable to type 'Giraffe'. +!!! error TS2322: Property 'y' is missing in type 'Elephant'. + + var h2: (g1: Giraffe, g2: Giraffe) => void; + h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. \ No newline at end of file diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.js b/tests/baselines/reference/contextualSignatureInstatiationContravariance.js index 6e731d61713..6e2de5d2907 100644 --- a/tests/baselines/reference/contextualSignatureInstatiationContravariance.js +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.js @@ -6,7 +6,7 @@ interface Elephant extends Animal { y2 } var f2: (x: T, y: T) => void; var g2: (g: Giraffe, e: Elephant) => void; -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types var h2: (g1: Giraffe, g2: Giraffe) => void; h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. @@ -14,6 +14,6 @@ h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the tr //// [contextualSignatureInstatiationContravariance.js] var f2; var g2; -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types var h2; h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion. diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols b/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols index 37a0c4adb02..fc11cca8aa6 100644 --- a/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.symbols @@ -29,7 +29,7 @@ var g2: (g: Giraffe, e: Elephant) => void; >e : Symbol(e, Decl(contextualSignatureInstatiationContravariance.ts, 6, 20)) >Elephant : Symbol(Elephant, Decl(contextualSignatureInstatiationContravariance.ts, 1, 38)) -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types >g2 : Symbol(g2, Decl(contextualSignatureInstatiationContravariance.ts, 6, 3)) >f2 : Symbol(f2, Decl(contextualSignatureInstatiationContravariance.ts, 4, 3)) diff --git a/tests/baselines/reference/contextualSignatureInstatiationContravariance.types b/tests/baselines/reference/contextualSignatureInstatiationContravariance.types index d0d281b7d49..0ca89f7016c 100644 --- a/tests/baselines/reference/contextualSignatureInstatiationContravariance.types +++ b/tests/baselines/reference/contextualSignatureInstatiationContravariance.types @@ -18,7 +18,7 @@ var g2: (g: Giraffe, e: Elephant) => void; >g : Giraffe >e : Elephant -g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal +g2 = f2; // error because Giraffe and Elephant are disjoint types >g2 = f2 : (x: T, y: T) => void >g2 : (g: Giraffe, e: Elephant) => void >f2 : (x: T, y: T) => void diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index 52b763cdaff..c8ac07429f3 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -737,20 +737,20 @@ var r14arg2 = (x: { a: string; b: number }) => null; >null : null var r14 = foo14(r14arg1); // any ->r14 : (x: { a: string; b: number; }) => Object ->foo14(r14arg1) : (x: { a: string; b: number; }) => Object +>r14 : any +>foo14(r14arg1) : any >foo14 : { (a: (x: { a: string; b: number; }) => Object): (x: { a: string; b: number; }) => Object; (a: any): any; } >r14arg1 : (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : ((x: { a: string; b: number; }) => Object)[] ->[r14arg1, r14arg2] : ((x: { a: string; b: number; }) => Object)[] +>r14a : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>[r14arg1, r14arg2] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] >r14arg1 : (x: { a: T; b: T; }) => T >r14arg2 : (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : ((x: { a: string; b: number; }) => Object)[] ->[r14arg2, r14arg1] : ((x: { a: string; b: number; }) => Object)[] +>r14b : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] +>[r14arg2, r14arg1] : (((x: { a: T; b: T; }) => T) | ((x: { a: string; b: number; }) => Object))[] >r14arg2 : (x: { a: string; b: number; }) => Object >r14arg1 : (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index e169885b87f..4a0b3416e56 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -381,14 +381,14 @@ var r11 = foo11(r11arg); >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11a : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg, r11arg2] : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11b : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : ((x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : (x: { foo: T; }, y: { foo: U; bar: U; }) => Base diff --git a/tests/baselines/reference/subtypingWithConstructSignatures2.types b/tests/baselines/reference/subtypingWithConstructSignatures2.types index 8021e2105fb..0d2ff802911 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures2.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures2.types @@ -653,20 +653,20 @@ var r14arg2: new (x: { a: string; b: number }) => Object; >b : number var r14 = foo14(r14arg1); // any ->r14 : new (x: { a: string; b: number; }) => Object ->foo14(r14arg1) : new (x: { a: string; b: number; }) => Object +>r14 : any +>foo14(r14arg1) : any >foo14 : { (a: new (x: { a: string; b: number; }) => Object): new (x: { a: string; b: number; }) => Object; (a: any): any; } >r14arg1 : new (x: { a: T; b: T; }) => T var r14a = [r14arg1, r14arg2]; ->r14a : (new (x: { a: string; b: number; }) => Object)[] ->[r14arg1, r14arg2] : (new (x: { a: string; b: number; }) => Object)[] +>r14a : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>[r14arg1, r14arg2] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] >r14arg1 : new (x: { a: T; b: T; }) => T >r14arg2 : new (x: { a: string; b: number; }) => Object var r14b = [r14arg2, r14arg1]; ->r14b : (new (x: { a: string; b: number; }) => Object)[] ->[r14arg2, r14arg1] : (new (x: { a: string; b: number; }) => Object)[] +>r14b : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] +>[r14arg2, r14arg1] : ((new (x: { a: T; b: T; }) => T) | (new (x: { a: string; b: number; }) => Object))[] >r14arg2 : new (x: { a: string; b: number; }) => Object >r14arg1 : new (x: { a: T; b: T; }) => T diff --git a/tests/baselines/reference/subtypingWithConstructSignatures4.types b/tests/baselines/reference/subtypingWithConstructSignatures4.types index 412f7b2f73b..6c9881d1228 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures4.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures4.types @@ -343,14 +343,14 @@ var r11 = foo11(r11arg); >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base var r11a = [r11arg, r11arg2]; ->r11a : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11a : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg, r11arg2] : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base var r11b = [r11arg2, r11arg]; ->r11b : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] ->[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base)[] +>r11b : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] +>[r11arg2, r11arg] : (new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base)[] >r11arg2 : new (x: { foo: T; }, y: { foo: T; bar: T; }) => Base >r11arg : new (x: { foo: T; }, y: { foo: U; bar: U; }) => Base diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.js b/tests/baselines/reference/subtypingWithConstructSignatures5.js index d3f47955ffc..de10469def0 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.js +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.js @@ -45,7 +45,7 @@ interface I extends B { a11: new (x: T, y: T) => T; // ok a12: new >(x: Array, y: T) => Array; // ok, less specific parameter type a13: new >(x: Array, y: T) => T; // ok, T = Array, satisfies constraint, contextual signature instantiation succeeds - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok } //// [subtypingWithConstructSignatures5.js] diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.symbols b/tests/baselines/reference/subtypingWithConstructSignatures5.symbols index cbb55d20155..2daf0631a09 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.symbols +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.symbols @@ -302,13 +302,14 @@ interface I extends B { >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 45, 14)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 45, 14)) - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature + a14: new (x: { a: T; b: U }) => T; // ok >a14 : Symbol(I.a14, Decl(subtypingWithConstructSignatures5.ts, 45, 67)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) ->x : Symbol(x, Decl(subtypingWithConstructSignatures5.ts, 46, 17)) ->a : Symbol(a, Decl(subtypingWithConstructSignatures5.ts, 46, 21)) ->T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) ->b : Symbol(b, Decl(subtypingWithConstructSignatures5.ts, 46, 27)) +>U : Symbol(U, Decl(subtypingWithConstructSignatures5.ts, 46, 16)) +>x : Symbol(x, Decl(subtypingWithConstructSignatures5.ts, 46, 20)) +>a : Symbol(a, Decl(subtypingWithConstructSignatures5.ts, 46, 24)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) +>b : Symbol(b, Decl(subtypingWithConstructSignatures5.ts, 46, 30)) +>U : Symbol(U, Decl(subtypingWithConstructSignatures5.ts, 46, 16)) >T : Symbol(T, Decl(subtypingWithConstructSignatures5.ts, 46, 14)) } diff --git a/tests/baselines/reference/subtypingWithConstructSignatures5.types b/tests/baselines/reference/subtypingWithConstructSignatures5.types index a7adde7a480..d86cfe1c51d 100644 --- a/tests/baselines/reference/subtypingWithConstructSignatures5.types +++ b/tests/baselines/reference/subtypingWithConstructSignatures5.types @@ -180,9 +180,9 @@ interface I extends B { >x : Base[] >y : T - a14: new (x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature ->a14 : new (x: { a: T; b: T; }) => T ->x : { a: T; b: T; } + a14: new (x: { a: T; b: U }) => T; // ok +>a14 : new (x: { a: T; b: U; }) => T +>x : { a: T; b: U; } >a : T ->b : T +>b : U }