10
10
11
11
export const a1 = ( isNaN : typeof globalThis . isNaN ) : typeof globalThis . isNaN => isNaN ;
12
12
export const a2 = ( isNaN : typeof globalThis . isNaN , bar ? : typeof globalThis . isNaN ) : typeof globalThis . isNaN => bar ?? isNaN ;
13
- export const a3 = ( isNaN : number , bar ? : typeof globalThis . isNaN ) : typeof globalThis . isNaN => bar ! ;
13
+ export const a3 = ( isNaN : number , bar : typeof globalThis . isNaN ) : typeof globalThis . isNaN => bar ;
14
14
export const a4 = ( isNaN : number ) : typeof globalThis . isNaN => globalThis . isNaN ;
15
15
16
16
export const aObj = {
17
17
a1 : ( isNaN : typeof globalThis . isNaN ) : typeof globalThis . isNaN => isNaN ,
18
18
a2 : ( isNaN : typeof globalThis . isNaN , bar ? : typeof globalThis . isNaN ) : typeof globalThis . isNaN => bar ?? isNaN ,
19
- a3 : ( isNaN : number , bar ? : typeof globalThis . isNaN ) : typeof globalThis . isNaN => bar ! ,
19
+ a3 : ( isNaN : number , bar : typeof globalThis . isNaN ) : typeof globalThis . isNaN => bar ,
20
20
a4 : ( isNaN : number ) : typeof globalThis . isNaN => globalThis . isNaN ,
21
21
}
22
22
23
+ export type a4Return = ReturnType < ReturnType < typeof a4 >> ;
24
+ export type a4oReturn = ReturnType < ReturnType < typeof aObj [ 'a4' ] >> ;
25
+
23
26
export const b1 = ( isNaN : typeof globalThis . isNaN ) => isNaN ;
24
27
export const b2 = ( isNaN : typeof globalThis . isNaN , bar ? : typeof globalThis . isNaN ) => bar ?? isNaN ;
25
- export const b3 = ( isNaN : number , bar ? : typeof globalThis . isNaN ) => bar ! ;
28
+ export const b3 = ( isNaN : number , bar : typeof globalThis . isNaN ) => bar ;
26
29
export const b4 = ( isNaN : number ) => globalThis . isNaN ;
27
30
28
- // Should succeed, as b4 returns the global isNaN, not the number parameter.
29
- export type b4Return = ReturnType < ReturnType < typeof b4 >> ;
30
-
31
31
export const bObj = {
32
32
b1 : ( isNaN : typeof globalThis . isNaN ) => isNaN ,
33
33
b2 : ( isNaN : typeof globalThis . isNaN , bar ? : typeof globalThis . isNaN ) => bar ?? isNaN ,
34
- b3 : ( isNaN : number , bar ? : typeof globalThis . isNaN ) => bar ! ,
34
+ b3 : ( isNaN : number , bar : typeof globalThis . isNaN ) => bar ,
35
35
b4 : ( isNaN : number ) => globalThis . isNaN ,
36
36
}
37
37
38
+ export type b4Return = ReturnType < ReturnType < typeof b4 >> ;
39
+ export type b4oReturn = ReturnType < ReturnType < typeof bObj [ 'b4' ] >> ;
40
+
38
41
export function c1 ( isNaN : typeof globalThis . isNaN ) { return isNaN }
39
42
export function c2 ( isNaN : typeof globalThis . isNaN , bar ?: typeof globalThis . isNaN ) { return bar ?? isNaN }
40
- export function c3 ( isNaN : number , bar ? : typeof globalThis . isNaN ) { return bar ! }
43
+ export function c3 ( isNaN : number , bar : typeof globalThis . isNaN ) { return bar }
41
44
export function c4 ( isNaN : number ) { return globalThis . isNaN ; }
42
45
43
46
export const cObj = {
44
47
c1 ( isNaN : typeof globalThis . isNaN ) { return isNaN } ,
45
48
c2 ( isNaN : typeof globalThis . isNaN , bar ?: typeof globalThis . isNaN ) { return bar ?? isNaN } ,
46
- c3 ( isNaN : number , bar ? : typeof globalThis . isNaN ) { return bar ! } ,
49
+ c3 ( isNaN : number , bar : typeof globalThis . isNaN ) { return bar } ,
47
50
c4 ( isNaN : number ) { return globalThis . isNaN ; } ,
48
51
}
49
52
53
+ export type c4Return = ReturnType < ReturnType < typeof c4 >> ;
54
+ export type c4oReturn = ReturnType < ReturnType < typeof cObj [ 'c4' ] >> ;
55
+
50
56
// Non-inference cases.
51
57
52
58
export const explicitlyTypedVariable : ( isNaN : typeof globalThis . isNaN ) => typeof globalThis . isNaN = ( isNaN ) => isNaN ;
@@ -139,35 +145,40 @@ exports.AsClassProperty = AsClassProperty;
139
145
//// [declarationEmitGlobalThisPreserved.d.ts]
140
146
export declare const a1 : ( isNaN : typeof isNaN ) = > typeof isNaN ;
141
147
export declare const a2 : ( isNaN : typeof isNaN , bar ? : typeof isNaN ) = > typeof isNaN ;
142
- export declare const a3 : ( isNaN : number , bar ? : typeof isNaN ) = > typeof isNaN ;
148
+ export declare const a3 : ( isNaN : number , bar : typeof isNaN ) = > typeof isNaN ;
143
149
export declare const a4 : ( isNaN : number ) = > typeof isNaN ;
144
150
export declare const aObj : {
145
151
a1 : ( isNaN : typeof isNaN ) = > typeof isNaN ;
146
152
a2 : ( isNaN : typeof isNaN , bar ? : typeof isNaN ) = > typeof isNaN ;
147
- a3 : ( isNaN : number , bar ? : typeof isNaN ) = > typeof isNaN ;
153
+ a3 : ( isNaN : number , bar : typeof isNaN ) = > typeof isNaN ;
148
154
a4 : ( isNaN : number ) = > typeof isNaN ;
149
155
} ;
156
+ export declare type a4Return = ReturnType < ReturnType < typeof a4 >> ;
157
+ export declare type a4oReturn = ReturnType < ReturnType < typeof aObj [ 'a4' ] >> ;
150
158
export declare const b1 : ( isNaN : typeof isNaN ) = > typeof isNaN ;
151
159
export declare const b2 : ( isNaN : typeof isNaN , bar ? : typeof isNaN ) = > typeof isNaN ;
152
- export declare const b3 : ( isNaN : number , bar ? : typeof isNaN ) = > typeof isNaN ;
160
+ export declare const b3 : ( isNaN : number , bar : typeof isNaN ) = > typeof isNaN ;
153
161
export declare const b4 : ( isNaN : number ) = > typeof isNaN ;
154
- export declare type b4Return = ReturnType < ReturnType < typeof b4 >> ;
155
162
export declare const bObj : {
156
163
b1 : ( isNaN : typeof isNaN ) = > typeof isNaN ;
157
164
b2 : ( isNaN : typeof isNaN , bar ? : typeof isNaN ) = > typeof isNaN ;
158
- b3 : ( isNaN : number , bar ? : typeof isNaN ) = > typeof isNaN ;
165
+ b3 : ( isNaN : number , bar : typeof isNaN ) = > typeof isNaN ;
159
166
b4 : ( isNaN : number ) = > typeof isNaN ;
160
167
} ;
168
+ export declare type b4Return = ReturnType < ReturnType < typeof b4 >> ;
169
+ export declare type b4oReturn = ReturnType < ReturnType < typeof bObj [ 'b4' ] >> ;
161
170
export declare function c1 ( isNaN : typeof globalThis . isNaN ) : typeof globalThis . isNaN ;
162
171
export declare function c2 ( isNaN : typeof globalThis . isNaN , bar ?: typeof globalThis . isNaN ) : typeof globalThis . isNaN ;
163
- export declare function c3 ( isNaN : number , bar ? : typeof globalThis . isNaN ) : typeof globalThis . isNaN ;
172
+ export declare function c3 ( isNaN : number , bar : typeof globalThis . isNaN ) : typeof globalThis . isNaN ;
164
173
export declare function c4 ( isNaN : number ) : typeof globalThis . isNaN ;
165
174
export declare const cObj : {
166
175
c1 ( isNaN : typeof isNaN ) : typeof isNaN ;
167
176
c2 ( isNaN : typeof isNaN , bar ? : typeof isNaN ) : typeof isNaN ;
168
- c3 ( isNaN : number , bar ? : typeof isNaN ) : typeof isNaN ;
177
+ c3 ( isNaN : number , bar : typeof isNaN ) : typeof isNaN ;
169
178
c4 ( isNaN : number ) : typeof isNaN ;
170
179
} ;
180
+ export declare type c4Return = ReturnType < ReturnType < typeof c4 >> ;
181
+ export declare type c4oReturn = ReturnType < ReturnType < typeof cObj [ 'c4' ] >> ;
171
182
export declare const explicitlyTypedVariable : ( isNaN : typeof globalThis . isNaN ) = > typeof globalThis . isNaN ;
172
183
export declare function explicitlyTypedFunction ( isNaN : typeof globalThis . isNaN ) : typeof globalThis . isNaN ;
173
184
export declare type AsObjectProperty = {
@@ -186,23 +197,27 @@ tests/cases/compiler/declarationEmitGlobalThisPreserved.d.ts(1,27): error TS2502
186
197
tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 2 , 27 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
187
198
tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 6 , 10 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
188
199
tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 7 , 10 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
189
- tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 11 , 27 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
190
- tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 12 , 27 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
191
- tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 15 , 43 ) : error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
192
- tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 17 , 10 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
200
+ tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 11 , 43 ) : error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
201
+ tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 12 , 44 ) : error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
202
+ tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 13 , 27 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
203
+ tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 14 , 27 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
193
204
tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 18 , 10 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
194
- tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 27 , 8 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
195
- tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 28 , 8 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
205
+ tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 19 , 10 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
206
+ tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 23 , 43 ) : error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
207
+ tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 24 , 44 ) : error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
208
+ tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 30 , 8 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
209
+ tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 31 , 8 ) : error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
210
+ tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 36 , 44 ) : error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
196
211
197
212
198
- = === tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 11 errors ) === =
213
+ = === tests / cases / compiler / declarationEmitGlobalThisPreserved . d . ts ( 15 errors ) === =
199
214
export declare const a1 : ( isNaN : typeof isNaN ) = > typeof isNaN ;
200
215
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
201
216
! ! ! error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
202
217
export declare const a2 : ( isNaN : typeof isNaN , bar ? : typeof isNaN ) = > typeof isNaN ;
203
218
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
204
219
! ! ! error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
205
- export declare const a3 : ( isNaN : number , bar ? : typeof isNaN ) = > typeof isNaN ;
220
+ export declare const a3 : ( isNaN : number , bar : typeof isNaN ) = > typeof isNaN ;
206
221
export declare const a4 : ( isNaN : number ) = > typeof isNaN ;
207
222
export declare const aObj : {
208
223
a1 : ( isNaN : typeof isNaN ) = > typeof isNaN ;
@@ -211,33 +226,42 @@ tests/cases/compiler/declarationEmitGlobalThisPreserved.d.ts(28,8): error TS2502
211
226
a2 : ( isNaN : typeof isNaN , bar ? : typeof isNaN ) = > typeof isNaN ;
212
227
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
213
228
! ! ! error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
214
- a3 : ( isNaN : number , bar ? : typeof isNaN ) = > typeof isNaN ;
229
+ a3 : ( isNaN : number , bar : typeof isNaN ) = > typeof isNaN ;
215
230
a4 : ( isNaN : number ) = > typeof isNaN ;
216
231
} ;
232
+ export declare type a4Return = ReturnType < ReturnType < typeof a4 >> ;
233
+ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
234
+ ! ! ! error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
235
+ export declare type a4oReturn = ReturnType < ReturnType < typeof aObj [ 'a4' ] >> ;
236
+ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
237
+ ! ! ! error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
217
238
export declare const b1 : ( isNaN : typeof isNaN ) = > typeof isNaN ;
218
239
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
219
240
! ! ! error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
220
241
export declare const b2 : ( isNaN : typeof isNaN , bar ? : typeof isNaN ) = > typeof isNaN ;
221
242
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
222
243
! ! ! error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
223
- export declare const b3 : ( isNaN : number , bar ? : typeof isNaN ) = > typeof isNaN ;
244
+ export declare const b3 : ( isNaN : number , bar : typeof isNaN ) = > typeof isNaN ;
224
245
export declare const b4 : ( isNaN : number ) = > typeof isNaN ;
225
- export declare type b4Return = ReturnType < ReturnType < typeof b4 >> ;
226
- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
227
- ! ! ! error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
228
246
export declare const bObj : {
229
247
b1 : ( isNaN : typeof isNaN ) = > typeof isNaN ;
230
248
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
231
249
! ! ! error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
232
250
b2 : ( isNaN : typeof isNaN , bar ? : typeof isNaN ) = > typeof isNaN ;
233
251
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
234
252
! ! ! error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
235
- b3 : ( isNaN : number , bar ? : typeof isNaN ) = > typeof isNaN ;
253
+ b3 : ( isNaN : number , bar : typeof isNaN ) = > typeof isNaN ;
236
254
b4 : ( isNaN : number ) = > typeof isNaN ;
237
255
} ;
256
+ export declare type b4Return = ReturnType < ReturnType < typeof b4 >> ;
257
+ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
258
+ ! ! ! error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
259
+ export declare type b4oReturn = ReturnType < ReturnType < typeof bObj [ 'b4' ] >> ;
260
+ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
261
+ ! ! ! error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
238
262
export declare function c1 ( isNaN : typeof globalThis . isNaN ) : typeof globalThis . isNaN ;
239
263
export declare function c2 ( isNaN : typeof globalThis . isNaN , bar ?: typeof globalThis . isNaN ) : typeof globalThis . isNaN ;
240
- export declare function c3 ( isNaN : number , bar ? : typeof globalThis . isNaN ) : typeof globalThis . isNaN ;
264
+ export declare function c3 ( isNaN : number , bar : typeof globalThis . isNaN ) : typeof globalThis . isNaN ;
241
265
export declare function c4 ( isNaN : number ) : typeof globalThis . isNaN ;
242
266
export declare const cObj : {
243
267
c1 ( isNaN : typeof isNaN ) : typeof isNaN ;
@@ -246,9 +270,13 @@ tests/cases/compiler/declarationEmitGlobalThisPreserved.d.ts(28,8): error TS2502
246
270
c2 ( isNaN : typeof isNaN , bar ? : typeof isNaN ) : typeof isNaN ;
247
271
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
248
272
! ! ! error TS2502 : 'isNaN' is referenced directly or indirectly in its own type annotation .
249
- c3 ( isNaN : number , bar ? : typeof isNaN ) : typeof isNaN ;
273
+ c3 ( isNaN : number , bar : typeof isNaN ) : typeof isNaN ;
250
274
c4 ( isNaN : number ) : typeof isNaN ;
251
275
} ;
276
+ export declare type c4Return = ReturnType < ReturnType < typeof c4 >> ;
277
+ export declare type c4oReturn = ReturnType < ReturnType < typeof cObj [ 'c4' ] >> ;
278
+ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
279
+ ! ! ! error TS2344 : Type 'number' does not satisfy the constraint '(...args: any) => any' .
252
280
export declare const explicitlyTypedVariable : ( isNaN : typeof globalThis . isNaN ) = > typeof globalThis . isNaN ;
253
281
export declare function explicitlyTypedFunction ( isNaN : typeof globalThis . isNaN ) : typeof globalThis . isNaN ;
254
282
export declare type AsObjectProperty = {
0 commit comments