Skip to content

Commit 1bc4389

Browse files
committed
Add tests
1 parent 318678a commit 1bc4389

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @strict: true
2+
// @declaration: true
3+
4+
declare function id1<T>(input: T): T;
5+
declare function id2<T extends (x: any) => any>(input: T): T;
6+
declare function id3<T extends (x: { foo: any }) => any>(input: T): T;
7+
declare function id4<T extends (x: { foo?: number }) => any>(input: T): T;
8+
declare function id5<T extends (x?: number) => any>(input: T): T;
9+
10+
const f10 = function ({ foo = 42 }) { return foo };
11+
const f11 = id1(function ({ foo = 42 }) { return foo }); // Implicit any error
12+
const f12 = id2(function ({ foo = 42 }) { return foo });
13+
const f13 = id3(function ({ foo = 42 }) { return foo });
14+
const f14 = id4(function ({ foo = 42 }) { return foo });
15+
16+
const f20 = function (foo = 42) { return foo };
17+
const f21 = id1(function (foo = 42) { return foo }); // Implicit any error
18+
const f22 = id2(function (foo = 42) { return foo });
19+
const f25 = id5(function (foo = 42) { return foo });
20+
21+
// Repro from #28816
22+
23+
function id<T>(input: T): T { return input }
24+
25+
function getFoo ({ foo = 42 }) {
26+
return foo;
27+
}
28+
29+
const newGetFoo = id(getFoo);
30+
const newGetFoo2 = id(function getFoo ({ foo = 42 }) {
31+
return foo;
32+
});

0 commit comments

Comments
 (0)