bun-types-no-globals 1.2.23-canary.20250919T140710 → 1.2.23-canary.20250920T140621

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/bun.d.ts +12 -0
  2. package/lib/test.d.ts +70 -106
  3. package/package.json +1 -1
package/lib/bun.d.ts CHANGED
@@ -1899,6 +1899,18 @@ declare module "bun" {
1899
1899
  */
1900
1900
  tsconfig?: string;
1901
1901
 
1902
+ /**
1903
+ * JSX configuration options
1904
+ */
1905
+ jsx?: {
1906
+ runtime?: "automatic" | "classic";
1907
+ importSource?: string;
1908
+ factory?: string;
1909
+ fragment?: string;
1910
+ sideEffects?: boolean;
1911
+ development?: boolean;
1912
+ };
1913
+
1902
1914
  outdir?: string;
1903
1915
  }
1904
1916
 
package/lib/test.d.ts CHANGED
@@ -206,31 +206,26 @@ declare module "bun:test" {
206
206
  *
207
207
  * @category Testing
208
208
  */
209
- export interface Describe {
209
+ export interface Describe<T extends Readonly<any[]>> {
210
210
  (fn: () => void): void;
211
211
 
212
- (label: DescribeLabel, fn: () => void): void;
212
+ (label: DescribeLabel, fn: (...args: T) => void): void;
213
213
  /**
214
214
  * Skips all other tests, except this group of tests.
215
- *
216
- * @param label the label for the tests
217
- * @param fn the function that defines the tests
218
215
  */
219
- only(label: DescribeLabel, fn: () => void): void;
216
+ only: Describe<T>;
220
217
  /**
221
218
  * Skips this group of tests.
222
- *
223
- * @param label the label for the tests
224
- * @param fn the function that defines the tests
225
219
  */
226
- skip(label: DescribeLabel, fn: () => void): void;
220
+ skip: Describe<T>;
227
221
  /**
228
222
  * Marks this group of tests as to be written or to be fixed.
229
- *
230
- * @param label the label for the tests
231
- * @param fn the function that defines the tests
232
223
  */
233
- todo(label: DescribeLabel, fn?: () => void): void;
224
+ todo: Describe<T>;
225
+ /**
226
+ * Marks this group of tests to be executed concurrently.
227
+ */
228
+ concurrent: Describe<T>;
234
229
  /**
235
230
  * Runs this group of tests, only if `condition` is true.
236
231
  *
@@ -238,37 +233,27 @@ declare module "bun:test" {
238
233
  *
239
234
  * @param condition if these tests should run
240
235
  */
241
- if(condition: boolean): (label: DescribeLabel, fn: () => void) => void;
236
+ if(condition: boolean): Describe<T>;
242
237
  /**
243
238
  * Skips this group of tests, if `condition` is true.
244
239
  *
245
240
  * @param condition if these tests should be skipped
246
241
  */
247
- skipIf(condition: boolean): (label: DescribeLabel, fn: () => void) => void;
242
+ skipIf(condition: boolean): Describe<T>;
248
243
  /**
249
244
  * Marks this group of tests as to be written or to be fixed, if `condition` is true.
250
245
  *
251
246
  * @param condition if these tests should be skipped
252
247
  */
253
- todoIf(condition: boolean): (label: DescribeLabel, fn: () => void) => void;
248
+ todoIf(condition: boolean): Describe<T>;
254
249
  /**
255
250
  * Returns a function that runs for each item in `table`.
256
251
  *
257
252
  * @param table Array of Arrays with the arguments that are passed into the test fn for each row.
258
253
  */
259
- each<T extends Readonly<[any, ...any[]]>>(
260
- table: readonly T[],
261
- ): (label: DescribeLabel, fn: (...args: [...T]) => void | Promise<unknown>, options?: number | TestOptions) => void;
262
- each<T extends any[]>(
263
- table: readonly T[],
264
- ): (
265
- label: DescribeLabel,
266
- fn: (...args: Readonly<T>) => void | Promise<unknown>,
267
- options?: number | TestOptions,
268
- ) => void;
269
- each<T>(
270
- table: T[],
271
- ): (label: DescribeLabel, fn: (...args: T[]) => void | Promise<unknown>, options?: number | TestOptions) => void;
254
+ each<T extends Readonly<[any, ...any[]]>>(table: readonly T[]): Describe<[...T]>;
255
+ each<T extends any[]>(table: readonly T[]): Describe<[...T]>;
256
+ each<T>(table: T[]): Describe<[T]>;
272
257
  }
273
258
  /**
274
259
  * Describes a group of related tests.
@@ -286,7 +271,7 @@ declare module "bun:test" {
286
271
  * @param label the label for the tests
287
272
  * @param fn the function that defines the tests
288
273
  */
289
- export const describe: Describe;
274
+ export const describe: Describe<[]>;
290
275
  /**
291
276
  * Skips a group of related tests.
292
277
  *
@@ -295,7 +280,9 @@ declare module "bun:test" {
295
280
  * @param label the label for the tests
296
281
  * @param fn the function that defines the tests
297
282
  */
298
- export const xdescribe: Describe;
283
+ export const xdescribe: Describe<[]>;
284
+
285
+ type HookOptions = number | { timeout?: number };
299
286
  /**
300
287
  * Runs a function, once, before all the tests.
301
288
  *
@@ -312,7 +299,10 @@ declare module "bun:test" {
312
299
  *
313
300
  * @param fn the function to run
314
301
  */
315
- export function beforeAll(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
302
+ export function beforeAll(
303
+ fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
304
+ options?: HookOptions,
305
+ ): void;
316
306
  /**
317
307
  * Runs a function before each test.
318
308
  *
@@ -323,7 +313,10 @@ declare module "bun:test" {
323
313
  *
324
314
  * @param fn the function to run
325
315
  */
326
- export function beforeEach(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
316
+ export function beforeEach(
317
+ fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
318
+ options?: HookOptions,
319
+ ): void;
327
320
  /**
328
321
  * Runs a function, once, after all the tests.
329
322
  *
@@ -340,7 +333,10 @@ declare module "bun:test" {
340
333
  *
341
334
  * @param fn the function to run
342
335
  */
343
- export function afterAll(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
336
+ export function afterAll(
337
+ fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
338
+ options?: HookOptions,
339
+ ): void;
344
340
  /**
345
341
  * Runs a function after each test.
346
342
  *
@@ -349,7 +345,10 @@ declare module "bun:test" {
349
345
  *
350
346
  * @param fn the function to run
351
347
  */
352
- export function afterEach(fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void)): void;
348
+ export function afterEach(
349
+ fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
350
+ options?: HookOptions,
351
+ ): void;
353
352
  /**
354
353
  * Sets the default timeout for all tests in the current file. If a test specifies a timeout, it will
355
354
  * override this value. The default timeout is 5000ms (5 seconds).
@@ -382,6 +381,11 @@ declare module "bun:test" {
382
381
  */
383
382
  repeats?: number;
384
383
  }
384
+ type IsTuple<T> = T extends readonly unknown[]
385
+ ? number extends T["length"]
386
+ ? false // It's an array with unknown length, not a tuple
387
+ : true // It's an array with a fixed length (a tuple)
388
+ : false; // Not an array at all
385
389
  /**
386
390
  * Runs a test.
387
391
  *
@@ -405,10 +409,10 @@ declare module "bun:test" {
405
409
  *
406
410
  * @category Testing
407
411
  */
408
- export interface Test {
412
+ export interface Test<T extends Readonly<any[]>> {
409
413
  (
410
414
  label: string,
411
- fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
415
+ fn: (...args: IsTuple<T> extends true ? [...T, (err?: unknown) => void] : T) => void | Promise<unknown>,
412
416
  /**
413
417
  * - If a `number`, sets the timeout for the test in milliseconds.
414
418
  * - If an `object`, sets the options for the test.
@@ -420,28 +424,12 @@ declare module "bun:test" {
420
424
  ): void;
421
425
  /**
422
426
  * Skips all other tests, except this test when run with the `--only` option.
423
- *
424
- * @param label the label for the test
425
- * @param fn the test function
426
- * @param options the test timeout or options
427
427
  */
428
- only(
429
- label: string,
430
- fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
431
- options?: number | TestOptions,
432
- ): void;
428
+ only: Test<T>;
433
429
  /**
434
430
  * Skips this test.
435
- *
436
- * @param label the label for the test
437
- * @param fn the test function
438
- * @param options the test timeout or options
439
431
  */
440
- skip(
441
- label: string,
442
- fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
443
- options?: number | TestOptions,
444
- ): void;
432
+ skip: Test<T>;
445
433
  /**
446
434
  * Marks this test as to be written or to be fixed.
447
435
  *
@@ -449,16 +437,8 @@ declare module "bun:test" {
449
437
  * if the test passes, the test will be marked as `fail` in the results; you will have to
450
438
  * remove the `.todo` or check that your test
451
439
  * is implemented correctly.
452
- *
453
- * @param label the label for the test
454
- * @param fn the test function
455
- * @param options the test timeout or options
456
440
  */
457
- todo(
458
- label: string,
459
- fn?: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
460
- options?: number | TestOptions,
461
- ): void;
441
+ todo: Test<T>;
462
442
  /**
463
443
  * Marks this test as failing.
464
444
  *
@@ -469,16 +449,12 @@ declare module "bun:test" {
469
449
  *
470
450
  * `test.failing` is very similar to {@link test.todo} except that it always
471
451
  * runs, regardless of the `--todo` flag.
472
- *
473
- * @param label the label for the test
474
- * @param fn the test function
475
- * @param options the test timeout or options
476
452
  */
477
- failing(
478
- label: string,
479
- fn?: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
480
- options?: number | TestOptions,
481
- ): void;
453
+ failing: Test<T>;
454
+ /**
455
+ * Runs the test concurrently with other concurrent tests.
456
+ */
457
+ concurrent: Test<T>;
482
458
  /**
483
459
  * Runs this test, if `condition` is true.
484
460
  *
@@ -486,51 +462,39 @@ declare module "bun:test" {
486
462
  *
487
463
  * @param condition if the test should run
488
464
  */
489
- if(
490
- condition: boolean,
491
- ): (
492
- label: string,
493
- fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
494
- options?: number | TestOptions,
495
- ) => void;
465
+ if(condition: boolean): Test<T>;
496
466
  /**
497
467
  * Skips this test, if `condition` is true.
498
468
  *
499
469
  * @param condition if the test should be skipped
500
470
  */
501
- skipIf(
502
- condition: boolean,
503
- ): (
504
- label: string,
505
- fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
506
- options?: number | TestOptions,
507
- ) => void;
471
+ skipIf(condition: boolean): Test<T>;
508
472
  /**
509
473
  * Marks this test as to be written or to be fixed, if `condition` is true.
510
474
  *
511
475
  * @param condition if the test should be marked TODO
512
476
  */
513
- todoIf(
514
- condition: boolean,
515
- ): (
516
- label: string,
517
- fn: (() => void | Promise<unknown>) | ((done: (err?: unknown) => void) => void),
518
- options?: number | TestOptions,
519
- ) => void;
477
+ todoIf(condition: boolean): Test<T>;
478
+ /**
479
+ * Marks this test as failing, if `condition` is true.
480
+ *
481
+ * @param condition if the test should be marked as failing
482
+ */
483
+ failingIf(condition: boolean): Test<T>;
484
+ /**
485
+ * Runs the test concurrently with other concurrent tests, if `condition` is true.
486
+ *
487
+ * @param condition if the test should run concurrently
488
+ */
489
+ concurrentIf(condition: boolean): Test<T>;
520
490
  /**
521
491
  * Returns a function that runs for each item in `table`.
522
492
  *
523
493
  * @param table Array of Arrays with the arguments that are passed into the test fn for each row.
524
494
  */
525
- each<T extends Readonly<[any, ...any[]]>>(
526
- table: readonly T[],
527
- ): (label: string, fn: (...args: [...T]) => void | Promise<unknown>, options?: number | TestOptions) => void;
528
- each<T extends any[]>(
529
- table: readonly T[],
530
- ): (label: string, fn: (...args: Readonly<T>) => void | Promise<unknown>, options?: number | TestOptions) => void;
531
- each<T>(
532
- table: T[],
533
- ): (label: string, fn: (...args: T[]) => void | Promise<unknown>, options?: number | TestOptions) => void;
495
+ each<T extends Readonly<[any, ...any[]]>>(table: readonly T[]): Test<[...T]>;
496
+ each<T extends any[]>(table: readonly T[]): Test<[...T]>;
497
+ each<T>(table: T[]): Test<[T]>;
534
498
  }
535
499
  /**
536
500
  * Runs a test.
@@ -548,7 +512,7 @@ declare module "bun:test" {
548
512
  * @param label the label for the test
549
513
  * @param fn the test function
550
514
  */
551
- export const test: Test;
515
+ export const test: Test<[]>;
552
516
  export { test as it, xtest as xit };
553
517
 
554
518
  /**
@@ -559,7 +523,7 @@ declare module "bun:test" {
559
523
  * @param label the label for the test
560
524
  * @param fn the test function
561
525
  */
562
- export const xtest: Test;
526
+ export const xtest: Test<[]>;
563
527
 
564
528
  /**
565
529
  * Asserts that a value matches some criteria.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bun-types-no-globals",
3
- "version": "1.2.23-canary.20250919T140710",
3
+ "version": "1.2.23-canary.20250920T140621",
4
4
  "main": "./generator/index.ts",
5
5
  "types": "./lib/index.d.ts",
6
6
  "description": "TypeScript type definitions for Bun without global types pollution",