Skip to content

Commit 71ad90d

Browse files
committed
More test tweaks
1 parent 414c5e4 commit 71ad90d

4 files changed

+221
-145
lines changed

tests/baselines/reference/declarationEmitGlobalThisPreserved.js

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,49 @@
1010

1111
export const a1 = (isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN => isNaN;
1212
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;
1414
export const a4 = (isNaN: number): typeof globalThis.isNaN => globalThis.isNaN;
1515

1616
export const aObj = {
1717
a1: (isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN => isNaN,
1818
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,
2020
a4: (isNaN: number): typeof globalThis.isNaN => globalThis.isNaN,
2121
}
2222

23+
export type a4Return = ReturnType<ReturnType<typeof a4>>;
24+
export type a4oReturn = ReturnType<ReturnType<typeof aObj['a4']>>;
25+
2326
export const b1 = (isNaN: typeof globalThis.isNaN) => isNaN;
2427
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;
2629
export const b4 = (isNaN: number) => globalThis.isNaN;
2730

28-
// Should succeed, as b4 returns the global isNaN, not the number parameter.
29-
export type b4Return = ReturnType<ReturnType<typeof b4>>;
30-
3131
export const bObj = {
3232
b1: (isNaN: typeof globalThis.isNaN) => isNaN,
3333
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,
3535
b4: (isNaN: number) => globalThis.isNaN,
3636
}
3737

38+
export type b4Return = ReturnType<ReturnType<typeof b4>>;
39+
export type b4oReturn = ReturnType<ReturnType<typeof bObj['b4']>>;
40+
3841
export function c1(isNaN: typeof globalThis.isNaN) { return isNaN }
3942
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 }
4144
export function c4(isNaN: number) { return globalThis.isNaN; }
4245

4346
export const cObj = {
4447
c1(isNaN: typeof globalThis.isNaN) { return isNaN },
4548
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 },
4750
c4(isNaN: number) { return globalThis.isNaN; },
4851
}
4952

53+
export type c4Return = ReturnType<ReturnType<typeof c4>>;
54+
export type c4oReturn = ReturnType<ReturnType<typeof cObj['c4']>>;
55+
5056
// Non-inference cases.
5157

5258
export const explicitlyTypedVariable: (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN = (isNaN) => isNaN;
@@ -139,35 +145,40 @@ exports.AsClassProperty = AsClassProperty;
139145
//// [declarationEmitGlobalThisPreserved.d.ts]
140146
export declare const a1: (isNaN: typeof isNaN) => typeof isNaN;
141147
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;
143149
export declare const a4: (isNaN: number) => typeof isNaN;
144150
export declare const aObj: {
145151
a1: (isNaN: typeof isNaN) => typeof isNaN;
146152
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;
148154
a4: (isNaN: number) => typeof isNaN;
149155
};
156+
export declare type a4Return = ReturnType<ReturnType<typeof a4>>;
157+
export declare type a4oReturn = ReturnType<ReturnType<typeof aObj['a4']>>;
150158
export declare const b1: (isNaN: typeof isNaN) => typeof isNaN;
151159
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;
153161
export declare const b4: (isNaN: number) => typeof isNaN;
154-
export declare type b4Return = ReturnType<ReturnType<typeof b4>>;
155162
export declare const bObj: {
156163
b1: (isNaN: typeof isNaN) => typeof isNaN;
157164
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;
159166
b4: (isNaN: number) => typeof isNaN;
160167
};
168+
export declare type b4Return = ReturnType<ReturnType<typeof b4>>;
169+
export declare type b4oReturn = ReturnType<ReturnType<typeof bObj['b4']>>;
161170
export declare function c1(isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN;
162171
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;
164173
export declare function c4(isNaN: number): typeof globalThis.isNaN;
165174
export declare const cObj: {
166175
c1(isNaN: typeof isNaN): typeof isNaN;
167176
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;
169178
c4(isNaN: number): typeof isNaN;
170179
};
180+
export declare type c4Return = ReturnType<ReturnType<typeof c4>>;
181+
export declare type c4oReturn = ReturnType<ReturnType<typeof cObj['c4']>>;
171182
export declare const explicitlyTypedVariable: (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN;
172183
export declare function explicitlyTypedFunction(isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN;
173184
export declare type AsObjectProperty = {
@@ -186,23 +197,27 @@ tests/cases/compiler/declarationEmitGlobalThisPreserved.d.ts(1,27): error TS2502
186197
tests/cases/compiler/declarationEmitGlobalThisPreserved.d.ts(2,27): error TS2502: 'isNaN' is referenced directly or indirectly in its own type annotation.
187198
tests/cases/compiler/declarationEmitGlobalThisPreserved.d.ts(6,10): error TS2502: 'isNaN' is referenced directly or indirectly in its own type annotation.
188199
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.
193204
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'.
196211

197212

198-
==== tests/cases/compiler/declarationEmitGlobalThisPreserved.d.ts (11 errors) ====
213+
==== tests/cases/compiler/declarationEmitGlobalThisPreserved.d.ts (15 errors) ====
199214
export declare const a1: (isNaN: typeof isNaN) => typeof isNaN;
200215
~~~~~~~~~~~~~~~~~~~
201216
!!! error TS2502: 'isNaN' is referenced directly or indirectly in its own type annotation.
202217
export declare const a2: (isNaN: typeof isNaN, bar?: typeof isNaN) => typeof isNaN;
203218
~~~~~~~~~~~~~~~~~~~
204219
!!! 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;
206221
export declare const a4: (isNaN: number) => typeof isNaN;
207222
export declare const aObj: {
208223
a1: (isNaN: typeof isNaN) => typeof isNaN;
@@ -211,33 +226,42 @@ tests/cases/compiler/declarationEmitGlobalThisPreserved.d.ts(28,8): error TS2502
211226
a2: (isNaN: typeof isNaN, bar?: typeof isNaN) => typeof isNaN;
212227
~~~~~~~~~~~~~~~~~~~
213228
!!! 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;
215230
a4: (isNaN: number) => typeof isNaN;
216231
};
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'.
217238
export declare const b1: (isNaN: typeof isNaN) => typeof isNaN;
218239
~~~~~~~~~~~~~~~~~~~
219240
!!! error TS2502: 'isNaN' is referenced directly or indirectly in its own type annotation.
220241
export declare const b2: (isNaN: typeof isNaN, bar?: typeof isNaN) => typeof isNaN;
221242
~~~~~~~~~~~~~~~~~~~
222243
!!! 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;
224245
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'.
228246
export declare const bObj: {
229247
b1: (isNaN: typeof isNaN) => typeof isNaN;
230248
~~~~~~~~~~~~~~~~~~~
231249
!!! error TS2502: 'isNaN' is referenced directly or indirectly in its own type annotation.
232250
b2: (isNaN: typeof isNaN, bar?: typeof isNaN) => typeof isNaN;
233251
~~~~~~~~~~~~~~~~~~~
234252
!!! 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;
236254
b4: (isNaN: number) => typeof isNaN;
237255
};
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'.
238262
export declare function c1(isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN;
239263
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;
241265
export declare function c4(isNaN: number): typeof globalThis.isNaN;
242266
export declare const cObj: {
243267
c1(isNaN: typeof isNaN): typeof isNaN;
@@ -246,9 +270,13 @@ tests/cases/compiler/declarationEmitGlobalThisPreserved.d.ts(28,8): error TS2502
246270
c2(isNaN: typeof isNaN, bar?: typeof isNaN): typeof isNaN;
247271
~~~~~~~~~~~~~~~~~~~
248272
!!! 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;
250274
c4(isNaN: number): typeof isNaN;
251275
};
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'.
252280
export declare const explicitlyTypedVariable: (isNaN: typeof globalThis.isNaN) => typeof globalThis.isNaN;
253281
export declare function explicitlyTypedFunction(isNaN: typeof globalThis.isNaN): typeof globalThis.isNaN;
254282
export declare type AsObjectProperty = {

0 commit comments

Comments
 (0)