Skip to content

Commit 243440a

Browse files
committed
Merge pull request #7372 from Microsoft/port-7328
Ports #7328 into release-1.8
2 parents a264cea + 9052603 commit 243440a

File tree

44 files changed

+269
-283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+269
-283
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5242,7 +5242,7 @@ namespace ts {
52425242
for (let i = 0; i < checkCount; i++) {
52435243
const s = i < sourceMax ? getTypeOfSymbol(sourceParams[i]) : getRestTypeOfSignature(source);
52445244
const t = i < targetMax ? getTypeOfSymbol(targetParams[i]) : getRestTypeOfSignature(target);
5245-
const related = compareTypes(t, s, /*reportErrors*/ false) || compareTypes(s, t, reportErrors);
5245+
const related = compareTypes(s, t, /*reportErrors*/ false) || compareTypes(t, s, reportErrors);
52465246
if (!related) {
52475247
if (reportErrors) {
52485248
errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible,

tests/baselines/reference/arrayLiterals3.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error
1616
Types of property 'push' are incompatible.
1717
Type '(...items: (number | string)[]) => number' is not assignable to type '(...items: Number[]) => number'.
1818
Types of parameters 'items' and 'items' are incompatible.
19-
Type 'number | string' is not assignable to type 'Number'.
20-
Type 'string' is not assignable to type 'Number'.
19+
Type 'Number' is not assignable to type 'number | string'.
20+
Type 'Number' is not assignable to type 'string'.
2121

2222

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

tests/baselines/reference/assignmentCompatBug5.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(5,6): error TS2345: Argument of typ
44
Type 'string' is not assignable to type 'number'.
55
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'.
66
Types of parameters 's' and 'n' are incompatible.
7-
Type 'string' is not assignable to type 'number'.
7+
Type 'number' is not assignable to type 'string'.
88
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'.
99
Type 'void' is not assignable to type 'number'.
1010

@@ -27,7 +27,7 @@ tests/cases/compiler/assignmentCompatBug5.ts(9,6): error TS2345: Argument of typ
2727
~~~~~~~~~~~~~~~~~
2828
!!! error TS2345: Argument of type '(s: string) => void' is not assignable to parameter of type '(n: number) => number'.
2929
!!! error TS2345: Types of parameters 's' and 'n' are incompatible.
30-
!!! error TS2345: Type 'string' is not assignable to type 'number'.
30+
!!! error TS2345: Type 'number' is not assignable to type 'string'.
3131
foo3((n) => { return; });
3232
~~~~~~~~~~~~~~~~~~
3333
!!! error TS2345: Argument of type '(n: number) => void' is not assignable to parameter of type '(n: number) => number'.

tests/baselines/reference/assignmentCompatWithCallSignatures.errors.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(35,1): error TS2322: Type 'S2' is not assignable to type 'T'.
22
Types of parameters 'x' and 'x' are incompatible.
3-
Type 'string' is not assignable to type 'number'.
3+
Type 'number' is not assignable to type 'string'.
44
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(36,1): error TS2322: Type '(x: string) => void' is not assignable to type 'T'.
55
Types of parameters 'x' and 'x' are incompatible.
6-
Type 'string' is not assignable to type 'number'.
6+
Type 'number' is not assignable to type 'string'.
77
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(37,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
88
Types of parameters 'x' and 'x' are incompatible.
9-
Type 'string' is not assignable to type 'number'.
9+
Type 'number' is not assignable to type 'string'.
1010
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(38,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
1111
Types of parameters 'x' and 'x' are incompatible.
12-
Type 'string' is not assignable to type 'number'.
12+
Type 'number' is not assignable to type 'string'.
1313
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(39,1): error TS2322: Type 'S2' is not assignable to type '(x: number) => void'.
1414
Types of parameters 'x' and 'x' are incompatible.
15-
Type 'string' is not assignable to type 'number'.
15+
Type 'number' is not assignable to type 'string'.
1616
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(40,1): error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
1717
Types of parameters 'x' and 'x' are incompatible.
18-
Type 'string' is not assignable to type 'number'.
18+
Type 'number' is not assignable to type 'string'.
1919
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(41,1): error TS2322: Type '(x: string) => number' is not assignable to type '(x: number) => void'.
2020
Types of parameters 'x' and 'x' are incompatible.
21-
Type 'string' is not assignable to type 'number'.
21+
Type 'number' is not assignable to type 'string'.
2222
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(42,1): error TS2322: Type '(x: string) => string' is not assignable to type '(x: number) => void'.
2323
Types of parameters 'x' and 'x' are incompatible.
24-
Type 'string' is not assignable to type 'number'.
24+
Type 'number' is not assignable to type 'string'.
2525

2626

2727
==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts (8 errors) ====
@@ -63,40 +63,40 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
6363
~
6464
!!! error TS2322: Type 'S2' is not assignable to type 'T'.
6565
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
66-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
66+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
6767
t = a3;
6868
~
6969
!!! error TS2322: Type '(x: string) => void' is not assignable to type 'T'.
7070
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
71-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
71+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
7272
t = (x: string) => 1;
7373
~
7474
!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
7575
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
76-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
76+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
7777
t = function (x: string) { return ''; }
7878
~
7979
!!! error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
8080
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
81-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
81+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
8282
a = s2;
8383
~
8484
!!! error TS2322: Type 'S2' is not assignable to type '(x: number) => void'.
8585
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
86-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
86+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
8787
a = a3;
8888
~
8989
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
9090
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
91-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
91+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
9292
a = (x: string) => 1;
9393
~
9494
!!! error TS2322: Type '(x: string) => number' is not assignable to type '(x: number) => void'.
9595
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
96-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
96+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
9797
a = function (x: string) { return ''; }
9898
~
9999
!!! error TS2322: Type '(x: string) => string' is not assignable to type '(x: number) => void'.
100100
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
101-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
101+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
102102

tests/baselines/reference/assignmentCompatWithCallSignatures2.errors.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
1010
Types of property 'f' are incompatible.
1111
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
1212
Types of parameters 'x' and 'x' are incompatible.
13-
Type 'string' is not assignable to type 'number'.
13+
Type 'number' is not assignable to type 'string'.
1414
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(43,1): error TS2322: Type '{ f(x: string): void; }' is not assignable to type 'T'.
1515
Types of property 'f' are incompatible.
1616
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
1717
Types of parameters 'x' and 'x' are incompatible.
18-
Type 'string' is not assignable to type 'number'.
18+
Type 'number' is not assignable to type 'string'.
1919
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(44,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
2020
Property 'f' is missing in type '(x: string) => number'.
2121
tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts(45,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'.
@@ -24,12 +24,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
2424
Types of property 'f' are incompatible.
2525
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
2626
Types of parameters 'x' and 'x' are incompatible.
27-
Type 'string' is not assignable to type 'number'.
27+
Type 'number' is not assignable to type 'string'.
2828
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; }'.
2929
Types of property 'f' are incompatible.
3030
Type '(x: string) => void' is not assignable to type '(x: number) => void'.
3131
Types of parameters 'x' and 'x' are incompatible.
32-
Type 'string' is not assignable to type 'number'.
32+
Type 'number' is not assignable to type 'string'.
3333
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; }'.
3434
Property 'f' is missing in type '(x: string) => number'.
3535
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; }'.
@@ -96,14 +96,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
9696
!!! error TS2322: Types of property 'f' are incompatible.
9797
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
9898
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
99-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
99+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
100100
t = a3;
101101
~
102102
!!! error TS2322: Type '{ f(x: string): void; }' is not assignable to type 'T'.
103103
!!! error TS2322: Types of property 'f' are incompatible.
104104
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
105105
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
106-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
106+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
107107
t = (x: string) => 1;
108108
~
109109
!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'.
@@ -118,14 +118,14 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
118118
!!! error TS2322: Types of property 'f' are incompatible.
119119
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
120120
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
121-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
121+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
122122
a = a3;
123123
~
124124
!!! error TS2322: Type '{ f(x: string): void; }' is not assignable to type '{ f(x: number): void; }'.
125125
!!! error TS2322: Types of property 'f' are incompatible.
126126
!!! error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'.
127127
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
128-
!!! error TS2322: Type 'string' is not assignable to type 'number'.
128+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
129129
a = (x: string) => 1;
130130
~
131131
!!! error TS2322: Type '(x: string) => number' is not assignable to type '{ f(x: number): void; }'.

tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
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'.
22
Types of parameters 'y' and 'y' are incompatible.
3-
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
3+
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
44
Types of parameters 'arg2' and 'arg2' are incompatible.
55
Type '{ foo: number; }' is not assignable to type 'Base'.
66
Types of property 'foo' are incompatible.
77
Type 'number' is not assignable to type 'string'.
88
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'.
99
Types of parameters 'y' and 'y' are incompatible.
10-
Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
10+
Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
1111
Types of parameters 'arg2' and 'arg2' are incompatible.
1212
Type 'Base' is not assignable to type '{ foo: number; }'.
1313
Types of property 'foo' are incompatible.
@@ -70,7 +70,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
7070
~~
7171
!!! 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'.
7272
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
73-
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
73+
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
7474
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
7575
!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'.
7676
!!! error TS2322: Types of property 'foo' are incompatible.
@@ -79,7 +79,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme
7979
~~
8080
!!! 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'.
8181
!!! error TS2322: Types of parameters 'y' and 'y' are incompatible.
82-
!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'.
82+
!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'.
8383
!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible.
8484
!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'.
8585
!!! error TS2322: Types of property 'foo' are incompatible.

0 commit comments

Comments
 (0)