Skip to content

Commit 6d38c6b

Browse files
allow extracting rest parameters' passed types into generics
1 parent bab287d commit 6d38c6b

23 files changed

+377
-128
lines changed

src/compiler/checker.ts

+76-28
Large diffs are not rendered by default.

tests/baselines/reference/FunctionDeclaration10_es6.errors.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
2+
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,20): error TS2523: 'yield' expressions cannot be used in a parameter initializer.
23
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,26): error TS1005: ',' expected.
34
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS1138: Parameter declaration expected.
45
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,29): error TS2304: Cannot find name 'yield'.
56
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts(1,34): error TS1005: ';' expected.
67

78

8-
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (5 errors) ====
9+
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts (6 errors) ====
910
function * foo(a = yield => yield) {
1011
~~~~~~~~~
1112
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
13+
~~~~~
14+
!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer.
1215
~~
1316
!!! error TS1005: ',' expected.
1417
~~~~~

tests/baselines/reference/asyncFunctionDeclaration10_es2017.errors.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
2+
tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer.
23
tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,30): error TS1109: Expression expected.
34
tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS1138: Parameter declaration expected.
45
tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,33): error TS2304: Cannot find name 'await'.
@@ -8,10 +9,12 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati
89
tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts(1,53): error TS1109: Expression expected.
910

1011

11-
==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (8 errors) ====
12+
==== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts (9 errors) ====
1213
async function foo(a = await => await): Promise<void> {
1314
~~~~~~~~~
1415
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
16+
~~~~~
17+
!!! error TS2524: 'await' expressions cannot be used in a parameter initializer.
1518
~~
1619
!!! error TS1109: Expression expected.
1720
~~~~~

tests/baselines/reference/asyncFunctionDeclaration10_es5.errors.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
2+
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer.
23
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,30): error TS1109: Expression expected.
34
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,33): error TS1138: Parameter declaration expected.
45
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,33): error TS2304: Cannot find name 'await'.
@@ -8,10 +9,12 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1
89
tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts(1,53): error TS1109: Expression expected.
910

1011

11-
==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts (8 errors) ====
12+
==== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts (9 errors) ====
1213
async function foo(a = await => await): Promise<void> {
1314
~~~~~~~~~
1415
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
16+
~~~~~
17+
!!! error TS2524: 'await' expressions cannot be used in a parameter initializer.
1518
~~
1619
!!! error TS1109: Expression expected.
1720
~~~~~

tests/baselines/reference/asyncFunctionDeclaration10_es6.errors.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,20): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
2+
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,24): error TS2524: 'await' expressions cannot be used in a parameter initializer.
23
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,30): error TS1109: Expression expected.
34
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS1138: Parameter declaration expected.
45
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,33): error TS2304: Cannot find name 'await'.
@@ -8,10 +9,12 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1
89
tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts(1,53): error TS1109: Expression expected.
910

1011

11-
==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (8 errors) ====
12+
==== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts (9 errors) ====
1213
async function foo(a = await => await): Promise<void> {
1314
~~~~~~~~~
1415
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
16+
~~~~~
17+
!!! error TS2524: 'await' expressions cannot be used in a parameter initializer.
1518
~~
1619
!!! error TS1109: Expression expected.
1720
~~~~~
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//// [destructureGenerics.ts]
2+
declare function f<T extends any[]>(...args: T): T;
3+
var x = f(1,2);
4+
var x: [1, 2];
5+
declare function g<T extends [number, number]>(...args: T): T;
6+
var z = g(1,2);
7+
var z: [1,2];
8+
declare function h<T>(...args: T[]): T;
9+
var b = h(1,2,3);
10+
var b: number;
11+
12+
13+
//// [destructureGenerics.js]
14+
var x = f(1, 2);
15+
var x;
16+
var z = g(1, 2);
17+
var z;
18+
var b = h(1, 2, 3);
19+
var b;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
=== tests/cases/compiler/destructureGenerics.ts ===
2+
declare function f<T extends any[]>(...args: T): T;
3+
>f : Symbol(f, Decl(destructureGenerics.ts, 0, 0))
4+
>T : Symbol(T, Decl(destructureGenerics.ts, 0, 19))
5+
>args : Symbol(args, Decl(destructureGenerics.ts, 0, 36))
6+
>T : Symbol(T, Decl(destructureGenerics.ts, 0, 19))
7+
>T : Symbol(T, Decl(destructureGenerics.ts, 0, 19))
8+
9+
var x = f(1,2);
10+
>x : Symbol(x, Decl(destructureGenerics.ts, 1, 3), Decl(destructureGenerics.ts, 2, 3))
11+
>f : Symbol(f, Decl(destructureGenerics.ts, 0, 0))
12+
13+
var x: [1, 2];
14+
>x : Symbol(x, Decl(destructureGenerics.ts, 1, 3), Decl(destructureGenerics.ts, 2, 3))
15+
16+
declare function g<T extends [number, number]>(...args: T): T;
17+
>g : Symbol(g, Decl(destructureGenerics.ts, 2, 14))
18+
>T : Symbol(T, Decl(destructureGenerics.ts, 3, 19))
19+
>args : Symbol(args, Decl(destructureGenerics.ts, 3, 47))
20+
>T : Symbol(T, Decl(destructureGenerics.ts, 3, 19))
21+
>T : Symbol(T, Decl(destructureGenerics.ts, 3, 19))
22+
23+
var z = g(1,2);
24+
>z : Symbol(z, Decl(destructureGenerics.ts, 4, 3), Decl(destructureGenerics.ts, 5, 3))
25+
>g : Symbol(g, Decl(destructureGenerics.ts, 2, 14))
26+
27+
var z: [1,2];
28+
>z : Symbol(z, Decl(destructureGenerics.ts, 4, 3), Decl(destructureGenerics.ts, 5, 3))
29+
30+
declare function h<T>(...args: T[]): T;
31+
>h : Symbol(h, Decl(destructureGenerics.ts, 5, 13))
32+
>T : Symbol(T, Decl(destructureGenerics.ts, 6, 19))
33+
>args : Symbol(args, Decl(destructureGenerics.ts, 6, 22))
34+
>T : Symbol(T, Decl(destructureGenerics.ts, 6, 19))
35+
>T : Symbol(T, Decl(destructureGenerics.ts, 6, 19))
36+
37+
var b = h(1,2,3);
38+
>b : Symbol(b, Decl(destructureGenerics.ts, 7, 3), Decl(destructureGenerics.ts, 8, 3))
39+
>h : Symbol(h, Decl(destructureGenerics.ts, 5, 13))
40+
41+
var b: number;
42+
>b : Symbol(b, Decl(destructureGenerics.ts, 7, 3), Decl(destructureGenerics.ts, 8, 3))
43+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
=== tests/cases/compiler/destructureGenerics.ts ===
2+
declare function f<T extends any[]>(...args: T): T;
3+
>f : <T extends any[]>(...args: T) => T
4+
>T : T
5+
>args : T
6+
>T : T
7+
>T : T
8+
9+
var x = f(1,2);
10+
>x : [1, 2]
11+
>f(1,2) : [1, 2]
12+
>f : <T extends any[]>(...args: T) => T
13+
>1 : 1
14+
>2 : 2
15+
16+
var x: [1, 2];
17+
>x : [1, 2]
18+
19+
declare function g<T extends [number, number]>(...args: T): T;
20+
>g : <T extends [number, number]>(...args: T) => T
21+
>T : T
22+
>args : T
23+
>T : T
24+
>T : T
25+
26+
var z = g(1,2);
27+
>z : [1, 2]
28+
>g(1,2) : [1, 2]
29+
>g : <T extends [number, number]>(...args: T) => T
30+
>1 : 1
31+
>2 : 2
32+
33+
var z: [1,2];
34+
>z : [1, 2]
35+
36+
declare function h<T>(...args: T[]): T;
37+
>h : <T>(...args: T[]) => T
38+
>T : T
39+
>args : T[]
40+
>T : T
41+
>T : T
42+
43+
var b = h(1,2,3);
44+
>b : number
45+
>h(1,2,3) : 1 | 2 | 3
46+
>h : <T>(...args: T[]) => T
47+
>1 : 1
48+
>2 : 2
49+
>3 : 3
50+
51+
var b: number;
52+
>b : number
53+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
tests/cases/compiler/destructureGenericsErrors.ts(2,9): error TS2554: Expected 2 arguments, but got 1.
2+
tests/cases/compiler/destructureGenericsErrors.ts(4,9): error TS2554: Expected 2 arguments, but got 3.
3+
4+
5+
==== tests/cases/compiler/destructureGenericsErrors.ts (2 errors) ====
6+
declare function g<T extends [number, number]>(...args: T): T;
7+
var y = g(1); // error
8+
~~~~
9+
!!! error TS2554: Expected 2 arguments, but got 1.
10+
var y: [1];
11+
var a = g(1,2,3); // error
12+
~~~~~~~~
13+
!!! error TS2554: Expected 2 arguments, but got 3.
14+
var a: [1,2,3];
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//// [destructureGenericsErrors.ts]
2+
declare function g<T extends [number, number]>(...args: T): T;
3+
var y = g(1); // error
4+
var y: [1];
5+
var a = g(1,2,3); // error
6+
var a: [1,2,3];
7+
8+
9+
//// [destructureGenericsErrors.js]
10+
var y = g(1); // error
11+
var y;
12+
var a = g(1, 2, 3); // error
13+
var a;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
=== tests/cases/compiler/destructureGenericsErrors.ts ===
2+
declare function g<T extends [number, number]>(...args: T): T;
3+
>g : Symbol(g, Decl(destructureGenericsErrors.ts, 0, 0))
4+
>T : Symbol(T, Decl(destructureGenericsErrors.ts, 0, 19))
5+
>args : Symbol(args, Decl(destructureGenericsErrors.ts, 0, 47))
6+
>T : Symbol(T, Decl(destructureGenericsErrors.ts, 0, 19))
7+
>T : Symbol(T, Decl(destructureGenericsErrors.ts, 0, 19))
8+
9+
// var y = g(1); // error
10+
// var y: [1];
11+
var a = g(1,2,3); // error
12+
>a : Symbol(a, Decl(destructureGenericsErrors.ts, 3, 3), Decl(destructureGenericsErrors.ts, 4, 3))
13+
>g : Symbol(g, Decl(destructureGenericsErrors.ts, 0, 0))
14+
15+
var a: [1,2,3];
16+
>a : Symbol(a, Decl(destructureGenericsErrors.ts, 3, 3), Decl(destructureGenericsErrors.ts, 4, 3))
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=== tests/cases/compiler/destructureGenericsErrors.ts ===
2+
declare function g<T extends [number, number]>(...args: T): T;
3+
>g : <T extends [number, number]>(...args: T) => T
4+
>T : T
5+
>args : T
6+
>T : T
7+
>T : T
8+
9+
// var y = g(1); // error
10+
// var y: [1];
11+
var a = g(1,2,3); // error
12+
>a : [1, 2, 3]
13+
>g(1,2,3) : [1, 2, 3]
14+
>g : <T extends [number, number]>(...args: T) => T
15+
>1 : 1
16+
>2 : 2
17+
>3 : 3
18+
19+
var a: [1,2,3];
20+
>a : [1, 2, 3]
21+

tests/baselines/reference/destructuringParameterDeclaration4.errors.txt

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(11,13): error TS2370: A rest parameter must be of an array type.
2-
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(13,13): error TS2370: A rest parameter must be of an array type.
31
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(14,17): error TS1047: A rest parameter cannot be optional.
42
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(15,16): error TS1048: A rest parameter cannot have an initializer.
53
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'.
@@ -17,7 +15,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
1715
tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(34,28): error TS2304: Cannot find name 'E'.
1816

1917

20-
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts (12 errors) ====
18+
==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts (10 errors) ====
2119
// If the parameter is a rest parameter, the parameter type is any[]
2220
// A type annotation for a rest parameter must denote an array type.
2321

@@ -29,12 +27,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(
2927
type stringOrNumArray = Array<String|Number>;
3028

3129
function a0(...x: [number, number, string]) { } // Error, rest parameter must be array type
32-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33-
!!! error TS2370: A rest parameter must be of an array type.
3430
function a1(...x: (number|string)[]) { }
3531
function a2(...a: someArray) { } // Error, rest parameter must be array type
36-
~~~~~~~~~~~~~~~
37-
!!! error TS2370: A rest parameter must be of an array type.
3832
function a3(...b?) { } // Error, can't be optional
3933
~
4034
!!! error TS1047: A rest parameter cannot be optional.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts(1,33): error TS2501: A rest element cannot contain a binding pattern.
2+
tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts(2,1): error TS2554: Expected 2 arguments, but got 1.
23

34

4-
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts (1 errors) ====
5+
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts (2 errors) ====
56
function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) { }
67
~~~~~~~~~~~~~~~~~~~~
78
!!! error TS2501: A rest element cannot contain a binding pattern.
8-
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
9+
takeFirstTwoEntries(new Map([["", 0], ["hello", 1]]));
10+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11+
!!! error TS2554: Expected 2 arguments, but got 1.

tests/baselines/reference/noImplicitAnyDestructuringParameterDeclaration.errors.txt

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@ tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(1,14): er
22
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(1,19): error TS7031: Binding element 'b' implicitly has an 'any' type.
33
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(1,23): error TS7006: Parameter 'c' implicitly has an 'any' type.
44
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(1,26): error TS7006: Parameter 'd' implicitly has an 'any' type.
5+
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(3,13): error TS7006: Parameter '[a = undefined]' implicitly has an '[any]' type.
56
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(3,14): error TS7031: Binding element 'a' implicitly has an 'any' type.
67
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(3,31): error TS7031: Binding element 'b' implicitly has an 'any' type.
78
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(3,42): error TS7006: Parameter 'c' implicitly has an 'any' type.
89
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(3,57): error TS7006: Parameter 'd' implicitly has an 'any' type.
910
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(7,20): error TS7008: Member 'b' implicitly has an 'any' type.
1011
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(7,30): error TS7008: Member 'b' implicitly has an 'any' type.
12+
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,13): error TS7006: Parameter '[a1]' implicitly has an '[any]' type.
1113
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,14): error TS7031: Binding element 'a1' implicitly has an 'any' type.
1214
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,34): error TS7031: Binding element 'b1' implicitly has an 'any' type.
15+
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,42): error TS7018: Object literal's property 'b1' implicitly has an 'any' type.
1316
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,54): error TS7006: Parameter 'c1' implicitly has an 'any' type.
1417
tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,70): error TS7006: Parameter 'd1' implicitly has an 'any' type.
1518

1619

17-
==== tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts (14 errors) ====
20+
==== tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts (17 errors) ====
1821
function f1([a], {b}, c, d) { // error
1922
~
2023
!!! error TS7031: Binding element 'a' implicitly has an 'any' type.
@@ -26,6 +29,8 @@ tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,70): er
2629
!!! error TS7006: Parameter 'd' implicitly has an 'any' type.
2730
}
2831
function f2([a = undefined], {b = null}, c = undefined, d = null) { // error
32+
~~~~~~~~~~~~~~~
33+
!!! error TS7006: Parameter '[a = undefined]' implicitly has an '[any]' type.
2934
~
3035
!!! error TS7031: Binding element 'a' implicitly has an 'any' type.
3136
~
@@ -44,10 +49,14 @@ tests/cases/compiler/noImplicitAnyDestructuringParameterDeclaration.ts(9,70): er
4449
!!! error TS7008: Member 'b' implicitly has an 'any' type.
4550
}
4651
function f5([a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null) { // error
52+
~~~~~~~~~~~~~~~~~~
53+
!!! error TS7006: Parameter '[a1]' implicitly has an '[any]' type.
4754
~~
4855
!!! error TS7031: Binding element 'a1' implicitly has an 'any' type.
4956
~~
5057
!!! error TS7031: Binding element 'b1' implicitly has an 'any' type.
58+
~~~~~~~~
59+
!!! error TS7018: Object literal's property 'b1' implicitly has an 'any' type.
5160
~~~~~~~~~~~~~~
5261
!!! error TS7006: Parameter 'c1' implicitly has an 'any' type.
5362
~~~~~~~~~

tests/baselines/reference/partiallyAnnotatedFunctionInferenceWithTypeParameter.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ testRest((t1, t2: D, t3) => {})
119119
>t3 : D
120120

121121
testRest((t2: D, ...t3) => {})
122-
>testRest((t2: D, ...t3) => {}) : any
122+
>testRest((t2: D, ...t3) => {}) : D
123123
>testRest : <T extends C>(a: (t: T, t1: T, ...ts: T[]) => void) => T
124124
>(t2: D, ...t3) => {} : (t2: D, ...t3: any[]) => void
125125
>t2 : D
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//// [promiseSpread.ts]
2+
interface Promise<T> {
3+
spread<U>(fulfilledHandler: (...values: T & any[]) => U | Promise<U>): Promise<U>;
4+
spread<U>(fulfilledHandler: (...values: [T]) => U | Promise<U>): Promise<U>;
5+
}
6+
7+
8+
//// [promiseSpread.js]

0 commit comments

Comments
 (0)