File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments