@types/node 22.1.0 → 22.2.0
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/README.md +1 -1
- node/fs/promises.d.ts +15 -1
- node/fs.d.ts +45 -2
- node/package.json +2 -2
- node/perf_hooks.d.ts +37 -1
- node/test.d.ts +120 -0
- node/zlib.d.ts +9 -0
node/README.md
CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
9
9
|
|
10
10
|
### Additional Details
|
11
|
-
* Last updated: Fri,
|
11
|
+
* Last updated: Fri, 09 Aug 2024 18:08:59 GMT
|
12
12
|
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
13
13
|
|
14
14
|
# Credits
|
node/fs/promises.d.ts
CHANGED
@@ -21,6 +21,8 @@ declare module "fs/promises" {
|
|
21
21
|
Dir,
|
22
22
|
Dirent,
|
23
23
|
GlobOptions,
|
24
|
+
GlobOptionsWithFileTypes,
|
25
|
+
GlobOptionsWithoutFileTypes,
|
24
26
|
MakeDirectoryOptions,
|
25
27
|
Mode,
|
26
28
|
ObjectEncodingOptions,
|
@@ -1243,7 +1245,19 @@ declare module "fs/promises" {
|
|
1243
1245
|
/**
|
1244
1246
|
* Retrieves the files matching the specified pattern.
|
1245
1247
|
*/
|
1246
|
-
function glob(pattern: string | string[]
|
1248
|
+
function glob(pattern: string | string[]): AsyncIterableIterator<string>;
|
1249
|
+
function glob(
|
1250
|
+
pattern: string | string[],
|
1251
|
+
opt: GlobOptionsWithFileTypes,
|
1252
|
+
): AsyncIterableIterator<Dirent>;
|
1253
|
+
function glob(
|
1254
|
+
pattern: string | string[],
|
1255
|
+
opt: GlobOptionsWithoutFileTypes,
|
1256
|
+
): AsyncIterableIterator<string>;
|
1257
|
+
function glob(
|
1258
|
+
pattern: string | string[],
|
1259
|
+
opt: GlobOptions,
|
1260
|
+
): AsyncIterableIterator<Dirent> | AsyncIterableIterator<string>;
|
1247
1261
|
}
|
1248
1262
|
declare module "node:fs/promises" {
|
1249
1263
|
export * from "fs/promises";
|
node/fs.d.ts
CHANGED
@@ -4324,6 +4324,18 @@ declare module "fs" {
|
|
4324
4324
|
* Function to filter out files/directories. Return true to exclude the item, false to include it.
|
4325
4325
|
*/
|
4326
4326
|
exclude?: ((fileName: string) => boolean) | undefined;
|
4327
|
+
/**
|
4328
|
+
* `true` if the glob should return paths as `Dirent`s, `false` otherwise.
|
4329
|
+
* @default false
|
4330
|
+
* @since v22.2.0
|
4331
|
+
*/
|
4332
|
+
withFileTypes?: boolean | undefined;
|
4333
|
+
}
|
4334
|
+
export interface GlobOptionsWithFileTypes extends GlobOptions {
|
4335
|
+
withFileTypes: true;
|
4336
|
+
}
|
4337
|
+
export interface GlobOptionsWithoutFileTypes extends GlobOptions {
|
4338
|
+
withFileTypes?: false | undefined;
|
4327
4339
|
}
|
4328
4340
|
/**
|
4329
4341
|
* Retrieves the files matching the specified pattern.
|
@@ -4332,15 +4344,46 @@ declare module "fs" {
|
|
4332
4344
|
pattern: string | string[],
|
4333
4345
|
callback: (err: NodeJS.ErrnoException | null, matches: string[]) => void,
|
4334
4346
|
): void;
|
4347
|
+
export function glob(
|
4348
|
+
pattern: string | string[],
|
4349
|
+
options: GlobOptionsWithFileTypes,
|
4350
|
+
callback: (
|
4351
|
+
err: NodeJS.ErrnoException | null,
|
4352
|
+
matches: Dirent[],
|
4353
|
+
) => void,
|
4354
|
+
): void;
|
4355
|
+
export function glob(
|
4356
|
+
pattern: string | string[],
|
4357
|
+
options: GlobOptionsWithoutFileTypes,
|
4358
|
+
callback: (
|
4359
|
+
err: NodeJS.ErrnoException | null,
|
4360
|
+
matches: string[],
|
4361
|
+
) => void,
|
4362
|
+
): void;
|
4335
4363
|
export function glob(
|
4336
4364
|
pattern: string | string[],
|
4337
4365
|
options: GlobOptions,
|
4338
|
-
callback: (
|
4366
|
+
callback: (
|
4367
|
+
err: NodeJS.ErrnoException | null,
|
4368
|
+
matches: Dirent[] | string[],
|
4369
|
+
) => void,
|
4339
4370
|
): void;
|
4340
4371
|
/**
|
4341
4372
|
* Retrieves the files matching the specified pattern.
|
4342
4373
|
*/
|
4343
|
-
export function globSync(pattern: string | string[]
|
4374
|
+
export function globSync(pattern: string | string[]): string[];
|
4375
|
+
export function globSync(
|
4376
|
+
pattern: string | string[],
|
4377
|
+
options: GlobOptionsWithFileTypes,
|
4378
|
+
): Dirent[];
|
4379
|
+
export function globSync(
|
4380
|
+
pattern: string | string[],
|
4381
|
+
options: GlobOptionsWithoutFileTypes,
|
4382
|
+
): string[];
|
4383
|
+
export function globSync(
|
4384
|
+
pattern: string | string[],
|
4385
|
+
options: GlobOptions,
|
4386
|
+
): Dirent[] | string[];
|
4344
4387
|
}
|
4345
4388
|
declare module "node:fs" {
|
4346
4389
|
export * from "fs";
|
node/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/node",
|
3
|
-
"version": "22.
|
3
|
+
"version": "22.2.0",
|
4
4
|
"description": "TypeScript definitions for node",
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
6
6
|
"license": "MIT",
|
@@ -212,6 +212,6 @@
|
|
212
212
|
"dependencies": {
|
213
213
|
"undici-types": "~6.13.0"
|
214
214
|
},
|
215
|
-
"typesPublisherContentHash": "
|
215
|
+
"typesPublisherContentHash": "e8a1feecc621a4e4c40517dba1262b6a77dcb9cdd874f74c76cb391931926c7c",
|
216
216
|
"typeScriptVersion": "4.8"
|
217
217
|
}
|
node/perf_hooks.d.ts
CHANGED
@@ -31,7 +31,17 @@
|
|
31
31
|
*/
|
32
32
|
declare module "perf_hooks" {
|
33
33
|
import { AsyncResource } from "node:async_hooks";
|
34
|
-
type EntryType =
|
34
|
+
type EntryType =
|
35
|
+
| "dns" // Node.js only
|
36
|
+
| "function" // Node.js only
|
37
|
+
| "gc" // Node.js only
|
38
|
+
| "http2" // Node.js only
|
39
|
+
| "http" // Node.js only
|
40
|
+
| "mark" // available on the Web
|
41
|
+
| "measure" // available on the Web
|
42
|
+
| "net" // Node.js only
|
43
|
+
| "node" // Node.js only
|
44
|
+
| "resource"; // available on the Web
|
35
45
|
interface NodeGCPerformanceDetail {
|
36
46
|
/**
|
37
47
|
* When `performanceEntry.entryType` is equal to 'gc', the `performance.kind` property identifies
|
@@ -114,6 +124,7 @@ declare module "perf_hooks" {
|
|
114
124
|
* @since v8.5.0
|
115
125
|
*/
|
116
126
|
class PerformanceNodeTiming extends PerformanceEntry {
|
127
|
+
readonly entryType: "node";
|
117
128
|
/**
|
118
129
|
* The high resolution millisecond timestamp at which the Node.js process
|
119
130
|
* completed bootstrapping. If bootstrapping has not yet finished, the property
|
@@ -270,6 +281,30 @@ declare module "perf_hooks" {
|
|
270
281
|
* @param name
|
271
282
|
*/
|
272
283
|
mark(name: string, options?: MarkOptions): PerformanceMark;
|
284
|
+
/**
|
285
|
+
* Creates a new `PerformanceResourceTiming` entry in the Resource Timeline.
|
286
|
+
* A `PerformanceResourceTiming` is a subclass of `PerformanceEntry` whose `performanceEntry.entryType` is always `'resource'`.
|
287
|
+
* Performance resources are used to mark moments in the Resource Timeline.
|
288
|
+
* @param timingInfo [Fetch Timing Info](https://fetch.spec.whatwg.org/#fetch-timing-info)
|
289
|
+
* @param requestedUrl The resource url
|
290
|
+
* @param initiatorType The initiator name, e.g: 'fetch'
|
291
|
+
* @param global
|
292
|
+
* @param cacheMode The cache mode must be an empty string ('') or 'local'
|
293
|
+
* @param bodyInfo [Fetch Response Body Info](https://fetch.spec.whatwg.org/#response-body-info)
|
294
|
+
* @param responseStatus The response's status code
|
295
|
+
* @param deliveryType The delivery type. Default: ''.
|
296
|
+
* @since v18.2.0, v16.17.0
|
297
|
+
*/
|
298
|
+
markResourceTiming(
|
299
|
+
timingInfo: object,
|
300
|
+
requestedUrl: string,
|
301
|
+
initiatorType: string,
|
302
|
+
global: object,
|
303
|
+
cacheMode: "" | "local",
|
304
|
+
bodyInfo: object,
|
305
|
+
responseStatus: number,
|
306
|
+
deliveryType?: string,
|
307
|
+
): PerformanceResourceTiming;
|
273
308
|
/**
|
274
309
|
* Creates a new PerformanceMeasure entry in the Performance Timeline.
|
275
310
|
* A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
|
@@ -543,6 +578,7 @@ declare module "perf_hooks" {
|
|
543
578
|
* @since v18.2.0, v16.17.0
|
544
579
|
*/
|
545
580
|
class PerformanceResourceTiming extends PerformanceEntry {
|
581
|
+
readonly entryType: "resource";
|
546
582
|
protected constructor();
|
547
583
|
/**
|
548
584
|
* The high resolution millisecond timestamp at immediately before dispatching the `fetch`
|
node/test.d.ts
CHANGED
@@ -461,6 +461,12 @@ declare module "node:test" {
|
|
461
461
|
* @since v18.0.0, v16.17.0
|
462
462
|
*/
|
463
463
|
class TestContext {
|
464
|
+
/**
|
465
|
+
* An object containing assertion methods bound to the test context.
|
466
|
+
* The top-level functions from the `node:assert` module are exposed here for the purpose of creating test plans.
|
467
|
+
* @since v22.2.0
|
468
|
+
*/
|
469
|
+
readonly assert: TestContextAssert;
|
464
470
|
/**
|
465
471
|
* This function is used to create a hook running before subtest of the current test.
|
466
472
|
* @param fn The hook function. If the hook uses callbacks, the callback function is passed as the second argument.
|
@@ -508,6 +514,42 @@ declare module "node:test" {
|
|
508
514
|
* @since v18.8.0, v16.18.0
|
509
515
|
*/
|
510
516
|
readonly name: string;
|
517
|
+
/**
|
518
|
+
* Used to set the number of assertions and subtests that are expected to run within the test.
|
519
|
+
* If the number of assertions and subtests that run does not match the expected count, the test will fail.
|
520
|
+
*
|
521
|
+
* To make sure assertions are tracked, the assert functions on `context.assert` must be used,
|
522
|
+
* instead of importing from the `node:assert` module.
|
523
|
+
* ```js
|
524
|
+
* test('top level test', (t) => {
|
525
|
+
* t.plan(2);
|
526
|
+
* t.assert.ok('some relevant assertion here');
|
527
|
+
* t.test('subtest', () => {});
|
528
|
+
* });
|
529
|
+
* ```
|
530
|
+
*
|
531
|
+
* When working with asynchronous code, the `plan` function can be used to ensure that the correct number of assertions are run:
|
532
|
+
* ```js
|
533
|
+
* test('planning with streams', (t, done) => {
|
534
|
+
* function* generate() {
|
535
|
+
* yield 'a';
|
536
|
+
* yield 'b';
|
537
|
+
* yield 'c';
|
538
|
+
* }
|
539
|
+
* const expected = ['a', 'b', 'c'];
|
540
|
+
* t.plan(expected.length);
|
541
|
+
* const stream = Readable.from(generate());
|
542
|
+
* stream.on('data', (chunk) => {
|
543
|
+
* t.assert.strictEqual(chunk, expected.shift());
|
544
|
+
* });
|
545
|
+
* stream.on('end', () => {
|
546
|
+
* done();
|
547
|
+
* });
|
548
|
+
* });
|
549
|
+
* ```
|
550
|
+
* @since v22.2.0
|
551
|
+
*/
|
552
|
+
plan(count: number): void;
|
511
553
|
/**
|
512
554
|
* If `shouldRunOnlyTests` is truthy, the test context will only run tests that
|
513
555
|
* have the `only` option set. Otherwise, all tests are run. If Node.js was not
|
@@ -584,6 +626,76 @@ declare module "node:test" {
|
|
584
626
|
*/
|
585
627
|
readonly mock: MockTracker;
|
586
628
|
}
|
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
|
+
deepStrictEqual: typeof import("node:assert").deepStrictEqual;
|
638
|
+
/**
|
639
|
+
* Identical to the `doesNotMatch` function from the `node:assert` module, but bound to the test context.
|
640
|
+
*/
|
641
|
+
doesNotMatch: typeof import("node:assert").doesNotMatch;
|
642
|
+
/**
|
643
|
+
* Identical to the `doesNotReject` function from the `node:assert` module, but bound to the test context.
|
644
|
+
*/
|
645
|
+
doesNotReject: typeof import("node:assert").doesNotReject;
|
646
|
+
/**
|
647
|
+
* Identical to the `doesNotThrow` function from the `node:assert` module, but bound to the test context.
|
648
|
+
*/
|
649
|
+
doesNotThrow: typeof import("node:assert").doesNotThrow;
|
650
|
+
/**
|
651
|
+
* Identical to the `equal` function from the `node:assert` module, but bound to the test context.
|
652
|
+
*/
|
653
|
+
equal: typeof import("node:assert").equal;
|
654
|
+
/**
|
655
|
+
* Identical to the `fail` function from the `node:assert` module, but bound to the test context.
|
656
|
+
*/
|
657
|
+
fail: typeof import("node:assert").fail;
|
658
|
+
/**
|
659
|
+
* Identical to the `ifError` function from the `node:assert` module, but bound to the test context.
|
660
|
+
*/
|
661
|
+
ifError: typeof import("node:assert").ifError;
|
662
|
+
/**
|
663
|
+
* Identical to the `match` function from the `node:assert` module, but bound to the test context.
|
664
|
+
*/
|
665
|
+
match: typeof import("node:assert").match;
|
666
|
+
/**
|
667
|
+
* Identical to the `notDeepEqual` function from the `node:assert` module, but bound to the test context.
|
668
|
+
*/
|
669
|
+
notDeepEqual: typeof import("node:assert").notDeepEqual;
|
670
|
+
/**
|
671
|
+
* Identical to the `notDeepStrictEqual` function from the `node:assert` module, but bound to the test context.
|
672
|
+
*/
|
673
|
+
notDeepStrictEqual: typeof import("node:assert").notDeepStrictEqual;
|
674
|
+
/**
|
675
|
+
* Identical to the `notEqual` function from the `node:assert` module, but bound to the test context.
|
676
|
+
*/
|
677
|
+
notEqual: typeof import("node:assert").notEqual;
|
678
|
+
/**
|
679
|
+
* Identical to the `notStrictEqual` function from the `node:assert` module, but bound to the test context.
|
680
|
+
*/
|
681
|
+
notStrictEqual: typeof import("node:assert").notStrictEqual;
|
682
|
+
/**
|
683
|
+
* Identical to the `ok` function from the `node:assert` module, but bound to the test context.
|
684
|
+
*/
|
685
|
+
ok: typeof import("node:assert").ok;
|
686
|
+
/**
|
687
|
+
* Identical to the `rejects` function from the `node:assert` module, but bound to the test context.
|
688
|
+
*/
|
689
|
+
rejects: typeof import("node:assert").rejects;
|
690
|
+
/**
|
691
|
+
* Identical to the `strictEqual` function from the `node:assert` module, but bound to the test context.
|
692
|
+
*/
|
693
|
+
strictEqual: typeof import("node:assert").strictEqual;
|
694
|
+
/**
|
695
|
+
* Identical to the `throws` function from the `node:assert` module, but bound to the test context.
|
696
|
+
*/
|
697
|
+
throws: typeof import("node:assert").throws;
|
698
|
+
}
|
587
699
|
|
588
700
|
/**
|
589
701
|
* An instance of `SuiteContext` is passed to each suite function in order to
|
@@ -643,6 +755,14 @@ declare module "node:test" {
|
|
643
755
|
* @default false
|
644
756
|
*/
|
645
757
|
todo?: boolean | string | undefined;
|
758
|
+
/**
|
759
|
+
* The number of assertions and subtests expected to be run in the test.
|
760
|
+
* If the number of assertions run in the test does not match the number
|
761
|
+
* specified in the plan, the test will fail.
|
762
|
+
* @default undefined
|
763
|
+
* @since v22.2.0
|
764
|
+
*/
|
765
|
+
plan?: number | undefined;
|
646
766
|
}
|
647
767
|
/**
|
648
768
|
* This function creates a hook that runs before executing a suite.
|
node/zlib.d.ts
CHANGED
@@ -172,6 +172,15 @@ declare module "zlib" {
|
|
172
172
|
interface DeflateRaw extends stream.Transform, Zlib, ZlibReset, ZlibParams {}
|
173
173
|
interface InflateRaw extends stream.Transform, Zlib, ZlibReset {}
|
174
174
|
interface Unzip extends stream.Transform, Zlib {}
|
175
|
+
/**
|
176
|
+
* Computes a 32-bit [Cyclic Redundancy Check](https://en.wikipedia.org/wiki/Cyclic_redundancy_check) checksum of `data`.
|
177
|
+
* If `value` is specified, it is used as the starting value of the checksum, otherwise, 0 is used as the starting value.
|
178
|
+
* @param data When `data` is a string, it will be encoded as UTF-8 before being used for computation.
|
179
|
+
* @param value An optional starting value. It must be a 32-bit unsigned integer. @default 0
|
180
|
+
* @returns A 32-bit unsigned integer containing the checksum.
|
181
|
+
* @since v22.2.0
|
182
|
+
*/
|
183
|
+
function crc32(data: string | Buffer | NodeJS.ArrayBufferView, value?: number): number;
|
175
184
|
/**
|
176
185
|
* Creates and returns a new `BrotliCompress` object.
|
177
186
|
* @since v11.7.0, v10.16.0
|