You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Leading and middle rest elements in tuple types (microsoft#41544)
* Support starting and middle rest elements in tuples
* Accept new baselines
* Include all rest arguments in error span
* Accept new baselines
* Fix tests
* Add new tests
* Fix lint errors
Copy file name to clipboardExpand all lines: tests/baselines/reference/for-of39.errors.txt
+2-2
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,11): error TS2769: No
7
7
Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult<readonly [string, boolean]>'.
8
8
Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'.
9
9
Type '[string, number]' is not assignable to type 'readonly [string, boolean]'.
10
-
Types of property '1' are incompatible.
10
+
Type at position 1 in source is not compatible with type at position 1 in target.
11
11
Type 'number' is not assignable to type 'boolean'.
12
12
Overload 2 of 3, '(entries?: readonly (readonly [string, boolean])[]): Map<string, boolean>', gave the following error.
13
13
Type 'number' is not assignable to type 'boolean'.
@@ -25,7 +25,7 @@ tests/cases/conformance/es6/for-ofStatements/for-of39.ts(1,11): error TS2769: No
25
25
!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, true]>' is not assignable to type 'IteratorYieldResult<readonly [string, boolean]>'.
26
26
!!! error TS2769: Type '[string, number] | [string, true]' is not assignable to type 'readonly [string, boolean]'.
27
27
!!! error TS2769: Type '[string, number]' is not assignable to type 'readonly [string, boolean]'.
28
-
!!! error TS2769: Types of property '1' are incompatible.
28
+
!!! error TS2769: Type at position 1 in source is not compatible with type at position 1 in target.
29
29
!!! error TS2769: Type 'number' is not assignable to type 'boolean'.
30
30
!!! error TS2769: Overload 2 of 3, '(entries?: readonly (readonly [string, boolean])[]): Map<string, boolean>', gave the following error.
31
31
!!! error TS2769: Type 'number' is not assignable to type 'boolean'.
!!! error TS2769: Type 'IteratorYieldResult<[string, number] | [string, boolean]>' is not assignable to type 'IteratorYieldResult<readonly [string, number]>'.
27
27
!!! error TS2769: Type '[string, number] | [string, boolean]' is not assignable to type 'readonly [string, number]'.
28
28
!!! error TS2769: Type '[string, boolean]' is not assignable to type 'readonly [string, number]'.
29
-
!!! error TS2769: Types of property '1' are incompatible.
29
+
!!! error TS2769: Type at position 1 in source is not compatible with type at position 1 in target.
30
30
!!! error TS2769: Type 'boolean' is not assignable to type 'number'.
31
31
!!! error TS2769: Overload 2 of 3, '(entries?: readonly (readonly [string, number])[]): Map<string, number>', gave the following error.
32
32
!!! error TS2769: Type 'boolean' is not assignable to type 'number'.
Copy file name to clipboardExpand all lines: tests/baselines/reference/optionalTupleElements1.errors.txt
+12-12
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(11,29): error TS1257: A required element cannot follow an optional element.
2
2
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(15,5): error TS2322: Type 'T2' is not assignable to type 'T1'.
3
-
Property '2' is optional in type '[number, string, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
3
+
Source provides no match for required element at position 2 in target.
4
4
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(16,5): error TS2322: Type 'T3' is not assignable to type 'T1'.
5
-
Property '1' is optional in type '[number, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
5
+
Source provides no match for required element at position 1 in target.
6
6
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(17,5): error TS2322: Type 'T4' is not assignable to type 'T1'.
7
-
Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
7
+
Source provides no match for required element at position 0 in target.
8
8
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(20,5): error TS2322: Type 'T3' is not assignable to type 'T2'.
9
-
Property '1' is optional in type '[number, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, (boolean | undefined)?]'.
9
+
Source provides no match for required element at position 1 in target.
10
10
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(21,5): error TS2322: Type 'T4' is not assignable to type 'T2'.
11
-
Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, (boolean | undefined)?]'.
11
+
Source provides no match for required element at position 0 in target.
12
12
tests/cases/conformance/types/tuple/optionalTupleElements1.ts(25,5): error TS2322: Type 'T4' is not assignable to type 'T3'.
13
-
Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, (string | undefined)?, (boolean | undefined)?]'.
13
+
Source provides no match for required element at position 0 in target.
!!! error TS2322: Type 'T2' is not assignable to type 'T1'.
36
-
!!! error TS2322: Property '2' is optional in type '[number, string, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
36
+
!!! error TS2322: Source provides no match for required element at position 2 in target.
37
37
t1 = t3; // Error
38
38
~~
39
39
!!! error TS2322: Type 'T3' is not assignable to type 'T1'.
40
-
!!! error TS2322: Property '1' is optional in type '[number, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
40
+
!!! error TS2322: Source provides no match for required element at position 1 in target.
41
41
t1 = t4; // Error
42
42
~~
43
43
!!! error TS2322: Type 'T4' is not assignable to type 'T1'.
44
-
!!! error TS2322: Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, boolean]'.
44
+
!!! error TS2322: Source provides no match for required element at position 0 in target.
45
45
t2 = t1;
46
46
t2 = t2;
47
47
t2 = t3; // Error
48
48
~~
49
49
!!! error TS2322: Type 'T3' is not assignable to type 'T2'.
50
-
!!! error TS2322: Property '1' is optional in type '[number, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, (boolean | undefined)?]'.
50
+
!!! error TS2322: Source provides no match for required element at position 1 in target.
51
51
t2 = t4; // Error
52
52
~~
53
53
!!! error TS2322: Type 'T4' is not assignable to type 'T2'.
54
-
!!! error TS2322: Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, string, (boolean | undefined)?]'.
54
+
!!! error TS2322: Source provides no match for required element at position 0 in target.
55
55
t3 = t1;
56
56
t3 = t2;
57
57
t3 = t3;
58
58
t3 = t4; // Error
59
59
~~
60
60
!!! error TS2322: Type 'T4' is not assignable to type 'T3'.
61
-
!!! error TS2322: Property '0' is optional in type '[(number | undefined)?, (string | undefined)?, (boolean | undefined)?]' but required in type '[number, (string | undefined)?, (boolean | undefined)?]'.
61
+
!!! error TS2322: Source provides no match for required element at position 0 in target.
Copy file name to clipboardExpand all lines: tests/baselines/reference/restTupleElements1.errors.txt
+15-14
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,9 @@
1
1
tests/cases/conformance/types/tuple/restTupleElements1.ts(3,22): error TS1257: A required element cannot follow an optional element.
2
-
tests/cases/conformance/types/tuple/restTupleElements1.ts(8,13): error TS1256: A rest element must be last in a tuple type.
3
2
tests/cases/conformance/types/tuple/restTupleElements1.ts(9,13): error TS2574: A rest element type must be an array type.
4
3
tests/cases/conformance/types/tuple/restTupleElements1.ts(10,13): error TS2574: A rest element type must be an array type.
5
4
tests/cases/conformance/types/tuple/restTupleElements1.ts(10,16): error TS8020: JSDoc types can only be used inside documentation comments.
6
5
tests/cases/conformance/types/tuple/restTupleElements1.ts(23,31): error TS2344: Type 'number[]' does not satisfy the constraint '[number, ...number[]]'.
7
-
Property '0' is optional in type 'number[]' but required in type '[number, ...number[]]'.
6
+
Source provides no match for required element at position 0 in target.
8
7
tests/cases/conformance/types/tuple/restTupleElements1.ts(24,31): error TS2344: Type '[]' does not satisfy the constraint '[number, ...number[]]'.
9
8
Source has 0 element(s) but target requires 1.
10
9
tests/cases/conformance/types/tuple/restTupleElements1.ts(29,18): error TS2344: Type 'number[]' does not satisfy the constraint '[number]'.
tests/cases/conformance/types/tuple/restTupleElements1.ts(33,31): error TS2344: Type '[string, ...number[]]' does not satisfy the constraint '[number, ...number[]]'.
17
16
Type 'string' is not assignable to type 'number'.
18
17
tests/cases/conformance/types/tuple/restTupleElements1.ts(34,31): error TS2344: Type '[number, number, string]' does not satisfy the constraint '[number, ...number[]]'.
19
-
Types of property '2' are incompatible.
20
-
Type 'string' is not assignable to type 'number'.
18
+
Type at positions 1 through 2 in source is not compatible with type at position 1 in target.
19
+
Type 'string | number' is not assignable to type 'number'.
20
+
Type 'string' is not assignable to type 'number'.
21
21
tests/cases/conformance/types/tuple/restTupleElements1.ts(35,31): error TS2344: Type '[number, number, number, string]' does not satisfy the constraint '[number, ...number[]]'.
22
-
Types of property '3' are incompatible.
23
-
Type 'string' is not assignable to type 'number'.
22
+
Type at positions 1 through 3 in source is not compatible with type at position 1 in target.
23
+
Type 'string | number' is not assignable to type 'number'.
24
+
Type 'string' is not assignable to type 'number'.
24
25
tests/cases/conformance/types/tuple/restTupleElements1.ts(59,4): error TS2345: Argument of type '[]' is not assignable to parameter of type '[unknown, ...unknown[]]'.
0 commit comments