@types/node 20.17.18 → 20.17.20

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.
node v20.17/test.d.ts CHANGED
@@ -455,6 +455,23 @@ declare module "node:test" {
455
455
  /**
456
456
  * An object containing assertion methods bound to the test context.
457
457
  * The top-level functions from the `node:assert` module are exposed here for the purpose of creating test plans.
458
+ *
459
+ * **Note:** Some of the functions from `node:assert` contain type assertions. If these are called via the
460
+ * TestContext `assert` object, then the context parameter in the test's function signature **must be explicitly typed**
461
+ * (ie. the parameter must have a type annotation), otherwise an error will be raised by the TypeScript compiler:
462
+ * ```ts
463
+ * import { test, type TestContext } from 'node:test';
464
+ *
465
+ * // The test function's context parameter must have a type annotation.
466
+ * test('example', (t: TestContext) => {
467
+ * t.assert.deepStrictEqual(actual, expected);
468
+ * });
469
+ *
470
+ * // Omitting the type annotation will result in a compilation error.
471
+ * test('example', t => {
472
+ * t.assert.deepStrictEqual(actual, expected); // Error: 't' needs an explicit type annotation.
473
+ * });
474
+ * ```
458
475
  * @since v20.15.0
459
476
  */
460
477
  readonly assert: TestContextAssert;
@@ -626,140 +643,28 @@ declare module "node:test" {
626
643
  */
627
644
  readonly mock: MockTracker;
628
645
  }
629
- interface TestContextAssert {
630
- /**
631
- * Identical to the `deepEqual` function from the `node:assert` module, but bound to the test context.
632
- */
633
- deepEqual: typeof import("node:assert").deepEqual;
634
- /**
635
- * Identical to the `deepStrictEqual` function from the `node:assert` module, but bound to the test context.
636
- *
637
- * **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
638
- * type annotation, otherwise an error will be raised by the TypeScript compiler:
639
- * ```ts
640
- * import { test, type TestContext } from 'node:test';
641
- *
642
- * // The test function's context parameter must have a type annotation.
643
- * test('example', (t: TestContext) => {
644
- * t.assert.deepStrictEqual(actual, expected);
645
- * });
646
- *
647
- * // Omitting the type annotation will result in a compilation error.
648
- * test('example', t => {
649
- * t.assert.deepStrictEqual(actual, expected); // Error: 't' needs an explicit type annotation.
650
- * });
651
- * ```
652
- */
653
- deepStrictEqual: typeof import("node:assert").deepStrictEqual;
654
- /**
655
- * Identical to the `doesNotMatch` function from the `node:assert` module, but bound to the test context.
656
- */
657
- doesNotMatch: typeof import("node:assert").doesNotMatch;
658
- /**
659
- * Identical to the `doesNotReject` function from the `node:assert` module, but bound to the test context.
660
- */
661
- doesNotReject: typeof import("node:assert").doesNotReject;
662
- /**
663
- * Identical to the `doesNotThrow` function from the `node:assert` module, but bound to the test context.
664
- */
665
- doesNotThrow: typeof import("node:assert").doesNotThrow;
666
- /**
667
- * Identical to the `equal` function from the `node:assert` module, but bound to the test context.
668
- */
669
- equal: typeof import("node:assert").equal;
670
- /**
671
- * Identical to the `fail` function from the `node:assert` module, but bound to the test context.
672
- */
673
- fail: typeof import("node:assert").fail;
674
- /**
675
- * Identical to the `ifError` function from the `node:assert` module, but bound to the test context.
676
- *
677
- * **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
678
- * type annotation, otherwise an error will be raised by the TypeScript compiler:
679
- * ```ts
680
- * import { test, type TestContext } from 'node:test';
681
- *
682
- * // The test function's context parameter must have a type annotation.
683
- * test('example', (t: TestContext) => {
684
- * t.assert.ifError(err);
685
- * });
686
- *
687
- * // Omitting the type annotation will result in a compilation error.
688
- * test('example', t => {
689
- * t.assert.ifError(err); // Error: 't' needs an explicit type annotation.
690
- * });
691
- * ```
692
- */
693
- ifError: typeof import("node:assert").ifError;
694
- /**
695
- * Identical to the `match` function from the `node:assert` module, but bound to the test context.
696
- */
697
- match: typeof import("node:assert").match;
698
- /**
699
- * Identical to the `notDeepEqual` function from the `node:assert` module, but bound to the test context.
700
- */
701
- notDeepEqual: typeof import("node:assert").notDeepEqual;
702
- /**
703
- * Identical to the `notDeepStrictEqual` function from the `node:assert` module, but bound to the test context.
704
- */
705
- notDeepStrictEqual: typeof import("node:assert").notDeepStrictEqual;
706
- /**
707
- * Identical to the `notEqual` function from the `node:assert` module, but bound to the test context.
708
- */
709
- notEqual: typeof import("node:assert").notEqual;
710
- /**
711
- * Identical to the `notStrictEqual` function from the `node:assert` module, but bound to the test context.
712
- */
713
- notStrictEqual: typeof import("node:assert").notStrictEqual;
714
- /**
715
- * Identical to the `ok` function from the `node:assert` module, but bound to the test context.
716
- *
717
- * **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
718
- * type annotation, otherwise an error will be raised by the TypeScript compiler:
719
- * ```ts
720
- * import { test, type TestContext } from 'node:test';
721
- *
722
- * // The test function's context parameter must have a type annotation.
723
- * test('example', (t: TestContext) => {
724
- * t.assert.ok(condition);
725
- * });
726
- *
727
- * // Omitting the type annotation will result in a compilation error.
728
- * test('example', t => {
729
- * t.assert.ok(condition)); // Error: 't' needs an explicit type annotation.
730
- * });
731
- * ```
732
- */
733
- ok: typeof import("node:assert").ok;
734
- /**
735
- * Identical to the `rejects` function from the `node:assert` module, but bound to the test context.
736
- */
737
- rejects: typeof import("node:assert").rejects;
738
- /**
739
- * Identical to the `strictEqual` function from the `node:assert` module, but bound to the test context.
740
- *
741
- * **Note:** as this method returns a type assertion, the context parameter in the callback signature must have a
742
- * type annotation, otherwise an error will be raised by the TypeScript compiler:
743
- * ```ts
744
- * import { test, type TestContext } from 'node:test';
745
- *
746
- * // The test function's context parameter must have a type annotation.
747
- * test('example', (t: TestContext) => {
748
- * t.assert.strictEqual(actual, expected);
749
- * });
750
- *
751
- * // Omitting the type annotation will result in a compilation error.
752
- * test('example', t => {
753
- * t.assert.strictEqual(actual, expected); // Error: 't' needs an explicit type annotation.
754
- * });
755
- * ```
756
- */
757
- strictEqual: typeof import("node:assert").strictEqual;
758
- /**
759
- * Identical to the `throws` function from the `node:assert` module, but bound to the test context.
760
- */
761
- throws: typeof import("node:assert").throws;
762
- }
646
+ interface TestContextAssert extends
647
+ Pick<
648
+ typeof import("assert"),
649
+ | "deepEqual"
650
+ | "deepStrictEqual"
651
+ | "doesNotMatch"
652
+ | "doesNotReject"
653
+ | "doesNotThrow"
654
+ | "equal"
655
+ | "fail"
656
+ | "ifError"
657
+ | "match"
658
+ | "notDeepEqual"
659
+ | "notDeepStrictEqual"
660
+ | "notEqual"
661
+ | "notStrictEqual"
662
+ | "ok"
663
+ | "rejects"
664
+ | "strictEqual"
665
+ | "throws"
666
+ >
667
+ {}
763
668
 
764
669
  /**
765
670
  * An instance of `SuiteContext` is passed to each suite function in order to