Skip to content

Ports #7328 into release-1.8 #7372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5242,7 +5242,7 @@ namespace ts {
for (let i = 0; i < checkCount; i++) {
const s = i < sourceMax ? getTypeOfSymbol(sourceParams[i]) : getRestTypeOfSignature(source);
const t = i < targetMax ? getTypeOfSymbol(targetParams[i]) : getRestTypeOfSignature(target);
const related = compareTypes(t, s, /*reportErrors*/ false) || compareTypes(s, t, reportErrors);
const related = compareTypes(s, t, /*reportErrors*/ false) || compareTypes(t, s, reportErrors);
if (!related) {
if (reportErrors) {
errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible,
Expand Down
8 changes: 4 additions & 4 deletions tests/baselines/reference/arrayLiterals3.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
Types of property 'push' are incompatible.
Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'.
Types of parameters 'items' and 'items' are incompatible.
Type 'number | string' is not assignable to type 'Number'.
Type 'string' is not assignable to type 'Number'.
Type 'Number' is not assignable to type 'number | string'.
Type 'Number' is not assignable to type 'string'.


==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (6 errors) ====
Expand Down Expand Up @@ -79,6 +79,6 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
!!! error TS2322: Types of property 'push' are incompatible.
!!! error TS2322: Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'.
!!! error TS2322: Types of parameters 'items' and 'items' are incompatible.
!!! error TS2322: Type 'number | string' is not assignable to type 'Number'.
!!! error TS2322: Type 'string' is not assignable to type 'Number'.
!!! error TS2322: Type 'Number' is not assignable to type 'number | string'.
!!! error TS2322: Type 'Number' is not assignable to type 'string'.

4 changes: 2 additions & 2 deletions tests/baselines/reference/assignmentCompatBug5.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of typ
Type 'string' is not assignable to type 'number'.
tests/cases/compiler/assignmentCompatBug5.ts(8,6): error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
Types of parameters 's' and 'n' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of type '(n: number) => void' is not assignable to parameter of type '(n: number) => number'.
Type 'void' is not assignable to type 'number'.

Expand All @@ -27,7 +27,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
!!! error TS2345: Types of parameters 's' and 'n' are incompatible.
!!! error TS2345: Type 'string' is not assignable to type 'number'.
!!! error TS2345: Type 'number' is not assignable to type 'string'.
foo3((n) => { return; });
~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(n: number) => void' is not assignable to parameter of type '(n: number) => number'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(35,1): error TS2322: Type 'S2' is not assignable to type 'T'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(36,1): error TS2322: Type '(x: string) => void' is not assignable to type 'T'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(37,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(38,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(39,1): error TS2322: Type 'S2' is not assignable to type '(x: number) => void'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(40,1): error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(41,1): error TS2322: Type '(x: string) => number' is not assignable to type '(x: number) => void'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(42,1): error TS2322: Type '(x: string) => string' is not assignable to type '(x: number) => void'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.


==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts (8 errors) ====
Expand Down Expand Up @@ -63,40 +63,40 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
~
!!! error TS2322: Type 'S2' is not assignable to type 'T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
t = a3;
~
!!! error TS2322: Type '(x: string) => void' is not assignable to type 'T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
t = (x: string) => 1;
~
!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
t = function (x: string) { return ''; }
~
!!! error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a = s2;
~
!!! error TS2322: Type 'S2' is not assignable to type '(x: number) => void'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a = a3;
~
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a = (x: string) => 1;
~
!!! error TS2322: Type '(x: string) => number' is not assignable to type '(x: number) => void'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a = function (x: string) { return ''; }
~
!!! error TS2322: Type '(x: string) => string' is not assignable to type '(x: number) => void'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.

Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
Types of property 'f' are incompatible.
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(43,1): error TS2322: Type '{ f(x: string): void; }' is not assignable to type 'T'.
Types of property 'f' are incompatible.
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(44,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
Property 'f' is missing in type '(x: string) => number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(45,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
Expand All @@ -24,12 +24,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
Types of property 'f' are incompatible.
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(47,1): error TS2322: Type '{ f(x: string): void; }' is not assignable to type '{ f(x: number): void; }'.
Types of property 'f' are incompatible.
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(48,1): error TS2322: Type '(x: string) => number' is not assignable to type '{ f(x: number): void; }'.
Property 'f' is missing in type '(x: string) => number'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(49,1): error TS2322: Type '(x: string) => string' is not assignable to type '{ f(x: number): void; }'.
Expand Down Expand Up @@ -96,14 +96,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Types of property 'f' are incompatible.
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
t = a3;
~
!!! error TS2322: Type '{ f(x: string): void; }' is not assignable to type 'T'.
!!! error TS2322: Types of property 'f' are incompatible.
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
t = (x: string) => 1;
~
!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
Expand All @@ -118,14 +118,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
!!! error TS2322: Types of property 'f' are incompatible.
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a = a3;
~
!!! error TS2322: Type '{ f(x: string): void; }' is not assignable to type '{ f(x: number): void; }'.
!!! error TS2322: Types of property 'f' are incompatible.
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
a = (x: string) => 1;
~
!!! error TS2322: Type '(x: string) => number' is not assignable to type '{ f(x: number): void; }'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(52,9): error TS2322: Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type '{ foo: number; }' is not assignable to type 'Base'.
Types of property 'foo' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(53,9): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
Types of parameters 'y' and 'y' are incompatible.
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
Types of parameters 'arg2' and 'arg2' are incompatible.
Type 'Base' is not assignable to type '{ foo: number; }'.
Types of property 'foo' are incompatible.
Expand Down Expand Up @@ -70,7 +70,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
~~
!!! error TS2322: Type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'.
!!! error TS2322: Types of property 'foo' are incompatible.
Expand All @@ -79,7 +79,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
~~
!!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '<T extends Base, U extends Derived>(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'.
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
!!! error TS2322: Types of property 'foo' are incompatible.
Expand Down
Loading