@types/node 20.16.10 → 20.16.12

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.16/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/v20.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Fri, 27 Sep 2024 16:08:32 GMT
11
+ * Last updated: Wed, 16 Oct 2024 23:36:24 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
@@ -0,0 +1,16 @@
1
+ // Polyfills for the explicit resource management types added in TypeScript 5.2.
2
+ // TODO: remove once this package no longer supports TS 5.1, and replace with a
3
+ // <reference> to TypeScript's disposable library in index.d.ts.
4
+
5
+ interface SymbolConstructor {
6
+ readonly dispose: unique symbol;
7
+ readonly asyncDispose: unique symbol;
8
+ }
9
+
10
+ interface Disposable {
11
+ [Symbol.dispose](): void;
12
+ }
13
+
14
+ interface AsyncDisposable {
15
+ [Symbol.asyncDispose](): PromiseLike<void>;
16
+ }
@@ -0,0 +1,9 @@
1
+ // Declaration files in this directory contain types relating to TypeScript library features
2
+ // that are not included in all TypeScript versions supported by DefinitelyTyped, but
3
+ // which can be made backwards-compatible without needing `typesVersions`.
4
+ // If adding declarations to this directory, please specify which versions of TypeScript require them,
5
+ // so that they can be removed when no longer needed.
6
+
7
+ /// <reference path="disposable.d.ts" />
8
+ /// <reference path="indexable.d.ts" />
9
+ /// <reference path="iterators.d.ts" />
@@ -0,0 +1,20 @@
1
+ // Polyfill for ES2022's .at() method on string/array prototypes, added to TypeScript in 4.6.
2
+
3
+ interface RelativeIndexable<T> {
4
+ at(index: number): T | undefined;
5
+ }
6
+
7
+ interface String extends RelativeIndexable<string> {}
8
+ interface Array<T> extends RelativeIndexable<T> {}
9
+ interface ReadonlyArray<T> extends RelativeIndexable<T> {}
10
+ interface Int8Array extends RelativeIndexable<number> {}
11
+ interface Uint8Array extends RelativeIndexable<number> {}
12
+ interface Uint8ClampedArray extends RelativeIndexable<number> {}
13
+ interface Int16Array extends RelativeIndexable<number> {}
14
+ interface Uint16Array extends RelativeIndexable<number> {}
15
+ interface Int32Array extends RelativeIndexable<number> {}
16
+ interface Uint32Array extends RelativeIndexable<number> {}
17
+ interface Float32Array extends RelativeIndexable<number> {}
18
+ interface Float64Array extends RelativeIndexable<number> {}
19
+ interface BigInt64Array extends RelativeIndexable<bigint> {}
20
+ interface BigUint64Array extends RelativeIndexable<bigint> {}
@@ -0,0 +1,21 @@
1
+ // Backwards-compatible iterator interfaces, augmented with iterator helper methods by lib.esnext.iterator in TypeScript 5.6.
2
+ // The IterableIterator interface does not contain these methods, which creates assignability issues in places where IteratorObjects
3
+ // are expected (eg. DOM-compatible APIs) if lib.esnext.iterator is loaded.
4
+ // Also ensures that iterators returned by the Node API, which inherit from Iterator.prototype, correctly expose the iterator helper methods
5
+ // if lib.esnext.iterator is loaded.
6
+ // TODO: remove once this package no longer supports TS 5.5, and replace NodeJS.BuiltinIteratorReturn with BuiltinIteratorReturn.
7
+
8
+ // Placeholders for TS <5.6
9
+ interface IteratorObject<T, TReturn, TNext> {}
10
+ interface AsyncIteratorObject<T, TReturn, TNext> {}
11
+
12
+ declare namespace NodeJS {
13
+ // Populate iterator methods for TS <5.6
14
+ interface Iterator<T, TReturn, TNext> extends globalThis.Iterator<T, TReturn, TNext> {}
15
+ interface AsyncIterator<T, TReturn, TNext> extends globalThis.AsyncIterator<T, TReturn, TNext> {}
16
+
17
+ // Polyfill for TS 5.6's instrinsic BuiltinIteratorReturn type, required for DOM-compatible iterators
18
+ type BuiltinIteratorReturn = ReturnType<any[][typeof Symbol.iterator]> extends
19
+ globalThis.Iterator<any, infer TReturn> ? TReturn
20
+ : any;
21
+ }
node v20.16/events.d.ts CHANGED
@@ -304,12 +304,12 @@ declare module "events" {
304
304
  emitter: NodeJS.EventEmitter,
305
305
  eventName: string | symbol,
306
306
  options?: StaticEventEmitterIteratorOptions,
307
- ): AsyncIterableIterator<any[]>;
307
+ ): NodeJS.AsyncIterator<any[]>;
308
308
  static on(
309
309
  emitter: EventTarget,
310
310
  eventName: string,
311
311
  options?: StaticEventEmitterIteratorOptions,
312
- ): AsyncIterableIterator<any[]>;
312
+ ): NodeJS.AsyncIterator<any[]>;
313
313
  /**
314
314
  * A class method that returns the number of listeners for the given `eventName` registered on the given `emitter`.
315
315
  *
@@ -396,7 +396,7 @@ declare module "events" {
396
396
  * ```
397
397
  * @since v15.4.0
398
398
  * @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
399
- * @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
399
+ * @param eventTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
400
400
  * objects.
401
401
  */
402
402
  static setMaxListeners(n?: number, ...eventTargets: Array<EventTarget | NodeJS.EventEmitter>): void;
node v20.16/fs.d.ts CHANGED
@@ -282,7 +282,7 @@ declare module "fs" {
282
282
  /**
283
283
  * Asynchronously iterates over the directory via `readdir(3)` until all entries have been read.
284
284
  */
285
- [Symbol.asyncIterator](): AsyncIterableIterator<Dirent>;
285
+ [Symbol.asyncIterator](): NodeJS.AsyncIterator<Dirent>;
286
286
  /**
287
287
  * Asynchronously close the directory's underlying resource handle.
288
288
  * Subsequent reads will result in errors.
@@ -111,6 +111,8 @@ declare global {
111
111
  interface RequireResolve extends NodeJS.RequireResolve {}
112
112
  interface NodeModule extends NodeJS.Module {}
113
113
 
114
+ var global: typeof globalThis;
115
+
114
116
  var process: NodeJS.Process;
115
117
  var console: Console;
116
118
 
@@ -182,53 +184,6 @@ declare global {
182
184
  };
183
185
  // #endregion borrowed
184
186
 
185
- // #region Disposable
186
- interface SymbolConstructor {
187
- /**
188
- * A method that is used to release resources held by an object. Called by the semantics of the `using` statement.
189
- */
190
- readonly dispose: unique symbol;
191
-
192
- /**
193
- * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement.
194
- */
195
- readonly asyncDispose: unique symbol;
196
- }
197
-
198
- interface Disposable {
199
- [Symbol.dispose](): void;
200
- }
201
-
202
- interface AsyncDisposable {
203
- [Symbol.asyncDispose](): PromiseLike<void>;
204
- }
205
- // #endregion Disposable
206
-
207
- // #region ArrayLike.at()
208
- interface RelativeIndexable<T> {
209
- /**
210
- * Takes an integer value and returns the item at that index,
211
- * allowing for positive and negative integers.
212
- * Negative integers count back from the last item in the array.
213
- */
214
- at(index: number): T | undefined;
215
- }
216
- interface String extends RelativeIndexable<string> {}
217
- interface Array<T> extends RelativeIndexable<T> {}
218
- interface ReadonlyArray<T> extends RelativeIndexable<T> {}
219
- interface Int8Array extends RelativeIndexable<number> {}
220
- interface Uint8Array extends RelativeIndexable<number> {}
221
- interface Uint8ClampedArray extends RelativeIndexable<number> {}
222
- interface Int16Array extends RelativeIndexable<number> {}
223
- interface Uint16Array extends RelativeIndexable<number> {}
224
- interface Int32Array extends RelativeIndexable<number> {}
225
- interface Uint32Array extends RelativeIndexable<number> {}
226
- interface Float32Array extends RelativeIndexable<number> {}
227
- interface Float64Array extends RelativeIndexable<number> {}
228
- interface BigInt64Array extends RelativeIndexable<bigint> {}
229
- interface BigUint64Array extends RelativeIndexable<bigint> {}
230
- // #endregion ArrayLike.at() end
231
-
232
187
  /**
233
188
  * @since v17.0.0
234
189
  *
@@ -381,7 +336,7 @@ declare global {
381
336
  unpipe(destination?: WritableStream): this;
382
337
  unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
383
338
  wrap(oldStream: ReadableStream): this;
384
- [Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
339
+ [Symbol.asyncIterator](): NodeJS.AsyncIterator<string | Buffer>;
385
340
  }
386
341
 
387
342
  interface WritableStream extends EventEmitter {
@@ -450,6 +405,18 @@ declare global {
450
405
  interface ReadOnlyDict<T> {
451
406
  readonly [key: string]: T | undefined;
452
407
  }
408
+
409
+ /** An iterable iterator returned by the Node.js API. */
410
+ // Default TReturn/TNext in v20 is `any`, for compatibility with the previously-used IterableIterator.
411
+ interface Iterator<T, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
412
+ [Symbol.iterator](): NodeJS.Iterator<T, TReturn, TNext>;
413
+ }
414
+
415
+ /** An async iterable iterator returned by the Node.js API. */
416
+ // Default TReturn/TNext in v20 is `any`, for compatibility with the previously-used AsyncIterableIterator.
417
+ interface AsyncIterator<T, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
418
+ [Symbol.asyncIterator](): NodeJS.AsyncIterator<T, TReturn, TNext>;
419
+ }
453
420
  }
454
421
 
455
422
  interface RequestInit extends _RequestInit {}
node v20.16/index.d.ts CHANGED
@@ -22,22 +22,22 @@
22
22
  * IN THE SOFTWARE.
23
23
  */
24
24
 
25
- // NOTE: These definitions support NodeJS and TypeScript 5.7+.
25
+ // NOTE: These definitions support Node.js and TypeScript 5.7+.
26
26
 
27
- // Reference required types from the default lib:
27
+ // Reference required TypeScript libs:
28
28
  /// <reference lib="es2020" />
29
- /// <reference lib="esnext.asynciterable" />
30
- /// <reference lib="esnext.intl" />
31
- /// <reference lib="esnext.bigint" />
32
29
 
33
- // Definitions specific to TypeScript 5.7+
30
+ // TypeScript backwards-compatibility definitions:
31
+ /// <reference path="compatibility/index.d.ts" />
32
+
33
+ // Definitions specific to TypeScript 5.7+:
34
34
  /// <reference path="globals.typedarray.d.ts" />
35
35
  /// <reference path="buffer.buffer.d.ts" />
36
36
 
37
- // Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
37
+ // Definitions for Node.js modules that are not specific to any version of TypeScript:
38
+ /// <reference path="globals.d.ts" />
38
39
  /// <reference path="assert.d.ts" />
39
40
  /// <reference path="assert/strict.d.ts" />
40
- /// <reference path="globals.d.ts" />
41
41
  /// <reference path="async_hooks.d.ts" />
42
42
  /// <reference path="buffer.d.ts" />
43
43
  /// <reference path="child_process.d.ts" />
@@ -89,5 +89,3 @@
89
89
  /// <reference path="wasi.d.ts" />
90
90
  /// <reference path="worker_threads.d.ts" />
91
91
  /// <reference path="zlib.d.ts" />
92
-
93
- /// <reference path="globals.global.d.ts" />
node v20.16/net.d.ts CHANGED
@@ -532,6 +532,12 @@ declare module "net" {
532
532
  * @since v16.5.0
533
533
  */
534
534
  keepAliveInitialDelay?: number | undefined;
535
+ /**
536
+ * Optionally overrides all `net.Socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
537
+ * @default See [stream.getDefaultHighWaterMark()](https://nodejs.org/docs/latest-v20.x/api/stream.html#streamgetdefaulthighwatermarkobjectmode).
538
+ * @since v18.17.0, v20.1.0
539
+ */
540
+ highWaterMark?: number | undefined;
535
541
  }
536
542
  interface DropArgument {
537
543
  localAddress?: string;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "20.16.10",
3
+ "version": "20.16.12",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -219,6 +219,6 @@
219
219
  "dependencies": {
220
220
  "undici-types": "~6.19.2"
221
221
  },
222
- "typesPublisherContentHash": "2f4c1b55d9201830070bc7c8dcc43b9c8024dc917c1ed90429ecdb7e50018259",
222
+ "typesPublisherContentHash": "bf0ad55b978ddf08d52ce086b72799ccfc8fe27373559231ddf273678dfcf1e7",
223
223
  "typeScriptVersion": "4.8"
224
224
  }
@@ -304,7 +304,7 @@ declare module "readline" {
304
304
  prependOnceListener(event: "SIGINT", listener: () => void): this;
305
305
  prependOnceListener(event: "SIGTSTP", listener: () => void): this;
306
306
  prependOnceListener(event: "history", listener: (history: string[]) => void): this;
307
- [Symbol.asyncIterator](): AsyncIterableIterator<string>;
307
+ [Symbol.asyncIterator](): NodeJS.AsyncIterator<string>;
308
308
  }
309
309
  export type ReadLine = Interface; // type forwarded for backwards compatibility
310
310
  export type Completer = (line: string) => CompleterResult;
@@ -166,6 +166,9 @@ declare module "stream/web" {
166
166
  interface ReadableStreamErrorCallback {
167
167
  (reason: any): void | PromiseLike<void>;
168
168
  }
169
+ interface ReadableStreamAsyncIterator<T> extends NodeJS.AsyncIterator<T, NodeJS.BuiltinIteratorReturn, unknown> {
170
+ [Symbol.asyncIterator](): ReadableStreamAsyncIterator<T>;
171
+ }
169
172
  /** This Streams API interface represents a readable stream of byte data. */
170
173
  interface ReadableStream<R = any> {
171
174
  readonly locked: boolean;
@@ -176,8 +179,8 @@ declare module "stream/web" {
176
179
  pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;
177
180
  pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;
178
181
  tee(): [ReadableStream<R>, ReadableStream<R>];
179
- values(options?: { preventCancel?: boolean }): AsyncIterableIterator<R>;
180
- [Symbol.asyncIterator](): AsyncIterableIterator<R>;
182
+ values(options?: { preventCancel?: boolean }): ReadableStreamAsyncIterator<R>;
183
+ [Symbol.asyncIterator](): ReadableStreamAsyncIterator<R>;
181
184
  }
182
185
  const ReadableStream: {
183
186
  prototype: ReadableStream;
node v20.16/stream.d.ts CHANGED
@@ -422,7 +422,7 @@ declare module "stream" {
422
422
  * or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream.
423
423
  * **Default: `true`**.
424
424
  */
425
- iterator(options?: { destroyOnReturn?: boolean }): AsyncIterableIterator<any>;
425
+ iterator(options?: { destroyOnReturn?: boolean }): NodeJS.AsyncIterator<any>;
426
426
  /**
427
427
  * This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream.
428
428
  * If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream.
@@ -651,7 +651,7 @@ declare module "stream" {
651
651
  removeListener(event: "readable", listener: () => void): this;
652
652
  removeListener(event: "resume", listener: () => void): this;
653
653
  removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
654
- [Symbol.asyncIterator](): AsyncIterableIterator<any>;
654
+ [Symbol.asyncIterator](): NodeJS.AsyncIterator<any>;
655
655
  /**
656
656
  * Calls `readable.destroy()` with an `AbortError` and returns a promise that fulfills when the stream is finished.
657
657
  * @since v20.4.0
@@ -22,22 +22,22 @@
22
22
  * IN THE SOFTWARE.
23
23
  */
24
24
 
25
- // NOTE: These definitions support NodeJS and TypeScript 4.9 through 5.6.
25
+ // NOTE: These definitions support Node.js and TypeScript 4.9 through 5.6.
26
26
 
27
- // Reference required types from the default lib:
27
+ // Reference required TypeScript libs:
28
28
  /// <reference lib="es2020" />
29
- /// <reference lib="esnext.asynciterable" />
30
- /// <reference lib="esnext.intl" />
31
- /// <reference lib="esnext.bigint" />
32
29
 
33
- // Definitions specific to TypeScript 4.9 through 5.6
30
+ // TypeScript backwards-compatibility definitions:
31
+ /// <reference path="../compatibility/index.d.ts" />
32
+
33
+ // Definitions specific to TypeScript 4.9 through 5.6:
34
34
  /// <reference path="./globals.typedarray.d.ts" />
35
35
  /// <reference path="./buffer.buffer.d.ts" />
36
36
 
37
- // Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
37
+ // Definitions for Node.js modules that are not specific to any version of TypeScript:
38
+ /// <reference path="../globals.d.ts" />
38
39
  /// <reference path="../assert.d.ts" />
39
40
  /// <reference path="../assert/strict.d.ts" />
40
- /// <reference path="../globals.d.ts" />
41
41
  /// <reference path="../async_hooks.d.ts" />
42
42
  /// <reference path="../buffer.d.ts" />
43
43
  /// <reference path="../child_process.d.ts" />
@@ -89,4 +89,3 @@
89
89
  /// <reference path="../wasi.d.ts" />
90
90
  /// <reference path="../worker_threads.d.ts" />
91
91
  /// <reference path="../zlib.d.ts" />
92
- /// <reference path="../globals.global.d.ts" />
node v20.16/url.d.ts CHANGED
@@ -740,6 +740,9 @@ declare module "url" {
740
740
  */
741
741
  toJSON(): string;
742
742
  }
743
+ interface URLSearchParamsIterator<T> extends NodeJS.Iterator<T, NodeJS.BuiltinIteratorReturn, unknown> {
744
+ [Symbol.iterator](): URLSearchParamsIterator<T>;
745
+ }
743
746
  /**
744
747
  * The `URLSearchParams` API provides read and write access to the query of a `URL`. The `URLSearchParams` class can also be used standalone with one of the
745
748
  * four following constructors.
@@ -810,7 +813,7 @@ declare module "url" {
810
813
  *
811
814
  * Alias for `urlSearchParams[@@iterator]()`.
812
815
  */
813
- entries(): IterableIterator<[string, string]>;
816
+ entries(): URLSearchParamsIterator<[string, string]>;
814
817
  /**
815
818
  * Iterates over each name-value pair in the query and invokes the given function.
816
819
  *
@@ -864,7 +867,7 @@ declare module "url" {
864
867
  * // foo
865
868
  * ```
866
869
  */
867
- keys(): IterableIterator<string>;
870
+ keys(): URLSearchParamsIterator<string>;
868
871
  /**
869
872
  * Sets the value in the `URLSearchParams` object associated with `name` to `value`. If there are any pre-existing name-value pairs whose names are `name`,
870
873
  * set the first such pair's value to `value` and remove all others. If not,
@@ -914,8 +917,8 @@ declare module "url" {
914
917
  /**
915
918
  * Returns an ES6 `Iterator` over the values of each name-value pair.
916
919
  */
917
- values(): IterableIterator<string>;
918
- [Symbol.iterator](): IterableIterator<[string, string]>;
920
+ values(): URLSearchParamsIterator<string>;
921
+ [Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
919
922
  }
920
923
  import { URL as _URL, URLSearchParams as _URLSearchParams } from "url";
921
924
  global {
node v20.16/util.d.ts CHANGED
@@ -1717,7 +1717,7 @@ declare module "util" {
1717
1717
  * Each item of the iterator is a JavaScript `Array`. The first item of the array
1718
1718
  * is the `name`, the second item of the array is the `value`.
1719
1719
  */
1720
- entries(): IterableIterator<[name: string, value: string]>;
1720
+ entries(): NodeJS.Iterator<[name: string, value: string]>;
1721
1721
  /**
1722
1722
  * Returns the value of the first name-value pair whose name is `name`. If there
1723
1723
  * are no such pairs, `null` is returned.
@@ -1743,7 +1743,7 @@ declare module "util" {
1743
1743
  * // bar
1744
1744
  * ```
1745
1745
  */
1746
- keys(): IterableIterator<string>;
1746
+ keys(): NodeJS.Iterator<string>;
1747
1747
  /**
1748
1748
  * Sets the value in the `MIMEParams` object associated with `name` to `value`. If there are any pre-existing name-value pairs whose names are `name`,
1749
1749
  * set the first such pair's value to `value`.
@@ -1762,11 +1762,11 @@ declare module "util" {
1762
1762
  /**
1763
1763
  * Returns an iterator over the values of each name-value pair.
1764
1764
  */
1765
- values(): IterableIterator<string>;
1765
+ values(): NodeJS.Iterator<string>;
1766
1766
  /**
1767
1767
  * Returns an iterator over each of the name-value pairs in the parameters.
1768
1768
  */
1769
- [Symbol.iterator]: typeof MIMEParams.prototype.entries;
1769
+ [Symbol.iterator](): NodeJS.Iterator<[name: string, value: string]>;
1770
1770
  }
1771
1771
  }
1772
1772
  declare module "util/types" {
@@ -1 +0,0 @@
1
- declare var global: typeof globalThis;