@types/node 18.17.19 → 18.18.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.
Files changed (111) hide show
  1. {node v18.17 → node v18.18}/README.md +1 -1
  2. {node v18.17 → node v18.18}/child_process.d.ts +5 -0
  3. {node v18.17/ts4.8 → node v18.18}/dgram.d.ts +5 -0
  4. {node v18.17 → node v18.18}/events.d.ts +35 -0
  5. {node v18.17 → node v18.18}/fs/promises.d.ts +5 -0
  6. {node v18.17 → node v18.18}/globals.d.ts +22 -0
  7. {node v18.17 → node v18.18}/index.d.ts +1 -1
  8. {node v18.17/ts4.8 → node v18.18}/module.d.ts +45 -4
  9. {node v18.17/ts4.8 → node v18.18}/net.d.ts +11 -6
  10. {node v18.17 → node v18.18}/package.json +2 -2
  11. {node v18.17 → node v18.18}/stream.d.ts +5 -0
  12. {node v18.17 → node v18.18}/test.d.ts +55 -40
  13. {node v18.17 → node v18.18}/timers.d.ts +12 -2
  14. {node v18.17 → node v18.18}/ts4.8/child_process.d.ts +5 -0
  15. {node v18.17 → node v18.18/ts4.8}/dgram.d.ts +5 -0
  16. {node v18.17 → node v18.18}/ts4.8/events.d.ts +35 -0
  17. {node v18.17 → node v18.18}/ts4.8/fs/promises.d.ts +5 -0
  18. {node v18.17 → node v18.18}/ts4.8/globals.d.ts +24 -1
  19. {node v18.17 → node v18.18/ts4.8}/module.d.ts +45 -4
  20. {node v18.17 → node v18.18/ts4.8}/net.d.ts +5 -0
  21. {node v18.17 → node v18.18}/ts4.8/stream.d.ts +169 -0
  22. {node v18.17 → node v18.18}/ts4.8/test.d.ts +69 -40
  23. {node v18.17 → node v18.18}/ts4.8/timers.d.ts +19 -2
  24. {node v18.17 → node v18.18}/ts4.8/url.d.ts +13 -4
  25. {node v18.17 → node v18.18}/url.d.ts +13 -4
  26. {node v18.17 → node v18.18}/LICENSE +0 -0
  27. {node v18.17 → node v18.18}/assert/strict.d.ts +0 -0
  28. {node v18.17 → node v18.18}/assert.d.ts +0 -0
  29. {node v18.17 → node v18.18}/async_hooks.d.ts +0 -0
  30. {node v18.17 → node v18.18}/buffer.d.ts +0 -0
  31. {node v18.17 → node v18.18}/cluster.d.ts +0 -0
  32. {node v18.17 → node v18.18}/console.d.ts +0 -0
  33. {node v18.17 → node v18.18}/constants.d.ts +0 -0
  34. {node v18.17 → node v18.18}/crypto.d.ts +0 -0
  35. {node v18.17 → node v18.18}/diagnostics_channel.d.ts +0 -0
  36. {node v18.17 → node v18.18}/dns/promises.d.ts +0 -0
  37. {node v18.17 → node v18.18}/dns.d.ts +0 -0
  38. {node v18.17 → node v18.18}/dom-events.d.ts +0 -0
  39. {node v18.17 → node v18.18}/domain.d.ts +0 -0
  40. {node v18.17 → node v18.18}/fs.d.ts +0 -0
  41. {node v18.17 → node v18.18}/globals.global.d.ts +0 -0
  42. {node v18.17 → node v18.18}/http.d.ts +0 -0
  43. {node v18.17 → node v18.18}/http2.d.ts +0 -0
  44. {node v18.17 → node v18.18}/https.d.ts +0 -0
  45. {node v18.17 → node v18.18}/inspector.d.ts +0 -0
  46. {node v18.17 → node v18.18}/os.d.ts +0 -0
  47. {node v18.17 → node v18.18}/path.d.ts +0 -0
  48. {node v18.17 → node v18.18}/perf_hooks.d.ts +0 -0
  49. {node v18.17 → node v18.18}/process.d.ts +0 -0
  50. {node v18.17 → node v18.18}/punycode.d.ts +0 -0
  51. {node v18.17 → node v18.18}/querystring.d.ts +0 -0
  52. {node v18.17 → node v18.18}/readline/promises.d.ts +0 -0
  53. {node v18.17 → node v18.18}/readline.d.ts +0 -0
  54. {node v18.17 → node v18.18}/repl.d.ts +0 -0
  55. {node v18.17 → node v18.18}/stream/consumers.d.ts +0 -0
  56. {node v18.17 → node v18.18}/stream/promises.d.ts +0 -0
  57. {node v18.17 → node v18.18}/stream/web.d.ts +0 -0
  58. {node v18.17 → node v18.18}/string_decoder.d.ts +0 -0
  59. {node v18.17 → node v18.18}/timers/promises.d.ts +0 -0
  60. {node v18.17 → node v18.18}/tls.d.ts +0 -0
  61. {node v18.17 → node v18.18}/trace_events.d.ts +0 -0
  62. {node v18.17 → node v18.18}/ts4.8/assert/strict.d.ts +0 -0
  63. {node v18.17 → node v18.18}/ts4.8/assert.d.ts +0 -0
  64. {node v18.17 → node v18.18}/ts4.8/async_hooks.d.ts +0 -0
  65. {node v18.17 → node v18.18}/ts4.8/buffer.d.ts +0 -0
  66. {node v18.17 → node v18.18}/ts4.8/cluster.d.ts +0 -0
  67. {node v18.17 → node v18.18}/ts4.8/console.d.ts +0 -0
  68. {node v18.17 → node v18.18}/ts4.8/constants.d.ts +0 -0
  69. {node v18.17 → node v18.18}/ts4.8/crypto.d.ts +0 -0
  70. {node v18.17 → node v18.18}/ts4.8/diagnostics_channel.d.ts +0 -0
  71. {node v18.17 → node v18.18}/ts4.8/dns/promises.d.ts +0 -0
  72. {node v18.17 → node v18.18}/ts4.8/dns.d.ts +0 -0
  73. {node v18.17 → node v18.18}/ts4.8/dom-events.d.ts +0 -0
  74. {node v18.17 → node v18.18}/ts4.8/domain.d.ts +0 -0
  75. {node v18.17 → node v18.18}/ts4.8/fs.d.ts +0 -0
  76. {node v18.17 → node v18.18}/ts4.8/globals.global.d.ts +0 -0
  77. {node v18.17 → node v18.18}/ts4.8/http.d.ts +0 -0
  78. {node v18.17 → node v18.18}/ts4.8/http2.d.ts +0 -0
  79. {node v18.17 → node v18.18}/ts4.8/https.d.ts +0 -0
  80. {node v18.17 → node v18.18}/ts4.8/index.d.ts +0 -0
  81. {node v18.17 → node v18.18}/ts4.8/inspector.d.ts +0 -0
  82. {node v18.17 → node v18.18}/ts4.8/os.d.ts +0 -0
  83. {node v18.17 → node v18.18}/ts4.8/path.d.ts +0 -0
  84. {node v18.17 → node v18.18}/ts4.8/perf_hooks.d.ts +0 -0
  85. {node v18.17 → node v18.18}/ts4.8/process.d.ts +0 -0
  86. {node v18.17 → node v18.18}/ts4.8/punycode.d.ts +0 -0
  87. {node v18.17 → node v18.18}/ts4.8/querystring.d.ts +0 -0
  88. {node v18.17 → node v18.18}/ts4.8/readline/promises.d.ts +0 -0
  89. {node v18.17 → node v18.18}/ts4.8/readline.d.ts +0 -0
  90. {node v18.17 → node v18.18}/ts4.8/repl.d.ts +0 -0
  91. {node v18.17 → node v18.18}/ts4.8/stream/consumers.d.ts +0 -0
  92. {node v18.17 → node v18.18}/ts4.8/stream/promises.d.ts +0 -0
  93. {node v18.17 → node v18.18}/ts4.8/stream/web.d.ts +0 -0
  94. {node v18.17 → node v18.18}/ts4.8/string_decoder.d.ts +0 -0
  95. {node v18.17 → node v18.18}/ts4.8/timers/promises.d.ts +0 -0
  96. {node v18.17 → node v18.18}/ts4.8/tls.d.ts +0 -0
  97. {node v18.17 → node v18.18}/ts4.8/trace_events.d.ts +0 -0
  98. {node v18.17 → node v18.18}/ts4.8/tty.d.ts +0 -0
  99. {node v18.17 → node v18.18}/ts4.8/util.d.ts +0 -0
  100. {node v18.17 → node v18.18}/ts4.8/v8.d.ts +0 -0
  101. {node v18.17 → node v18.18}/ts4.8/vm.d.ts +0 -0
  102. {node v18.17 → node v18.18}/ts4.8/wasi.d.ts +0 -0
  103. {node v18.17 → node v18.18}/ts4.8/worker_threads.d.ts +0 -0
  104. {node v18.17 → node v18.18}/ts4.8/zlib.d.ts +0 -0
  105. {node v18.17 → node v18.18}/tty.d.ts +0 -0
  106. {node v18.17 → node v18.18}/util.d.ts +0 -0
  107. {node v18.17 → node v18.18}/v8.d.ts +0 -0
  108. {node v18.17 → node v18.18}/vm.d.ts +0 -0
  109. {node v18.17 → node v18.18}/wasi.d.ts +0 -0
  110. {node v18.17 → node v18.18}/worker_threads.d.ts +0 -0
  111. {node v18.17 → node v18.18}/zlib.d.ts +0 -0
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v18.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Sat, 23 Sep 2023 20:38:33 GMT
11
+ * Last updated: Mon, 25 Sep 2023 20:06:16 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
14
 
@@ -305,6 +305,11 @@ declare module "child_process" {
305
305
  * @since v0.1.90
306
306
  */
307
307
  kill(signal?: NodeJS.Signals | number): boolean;
308
+ /**
309
+ * Calls {@link ChildProcess.kill} with `'SIGTERM'`.
310
+ * @since v18.18.0
311
+ */
312
+ [Symbol.dispose](): void;
308
313
  /**
309
314
  * When an IPC channel has been established between the parent and child (
310
315
  * i.e. when using {@link fork}), the `subprocess.send()` method can
@@ -574,6 +574,11 @@ declare module "dgram" {
574
574
  prependOnceListener(event: "error", listener: (err: Error) => void): this;
575
575
  prependOnceListener(event: "listening", listener: () => void): this;
576
576
  prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
577
+ /**
578
+ * Calls `socket.close()` and returns a promise that fulfills when the socket has closed.
579
+ * @since v18.18.0
580
+ */
581
+ [Symbol.asyncDispose](): Promise<void>;
577
582
  }
578
583
  }
579
584
  declare module "node:dgram" {
@@ -352,6 +352,41 @@ declare module "events" {
352
352
  * objects.
353
353
  */
354
354
  static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void;
355
+ /**
356
+ * Listens once to the `abort` event on the provided `signal`.
357
+ *
358
+ * Listening to the `abort` event on abort signals is unsafe and may
359
+ * lead to resource leaks since another third party with the signal can
360
+ * call `e.stopImmediatePropagation()`. Unfortunately Node.js cannot change
361
+ * this since it would violate the web standard. Additionally, the original
362
+ * API makes it easy to forget to remove listeners.
363
+ *
364
+ * This API allows safely using `AbortSignal`s in Node.js APIs by solving these
365
+ * two issues by listening to the event such that `stopImmediatePropagation` does
366
+ * not prevent the listener from running.
367
+ *
368
+ * Returns a disposable so that it may be unsubscribed from more easily.
369
+ *
370
+ * ```js
371
+ * import { addAbortListener } from 'node:events';
372
+ *
373
+ * function example(signal) {
374
+ * let disposable;
375
+ * try {
376
+ * signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
377
+ * disposable = addAbortListener(signal, (e) => {
378
+ * // Do something when signal is aborted.
379
+ * });
380
+ * } finally {
381
+ * disposable?.[Symbol.dispose]();
382
+ * }
383
+ * }
384
+ * ```
385
+ * @since v18.18.0
386
+ * @experimental
387
+ * @return Disposable that removes the `abort` listener.
388
+ */
389
+ static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
355
390
  /**
356
391
  * This symbol shall be used to install a listener for only monitoring `'error'`
357
392
  * events. Listeners installed using this symbol are called before the regular
@@ -468,6 +468,11 @@ declare module "fs/promises" {
468
468
  * @return Fulfills with `undefined` upon success.
469
469
  */
470
470
  close(): Promise<void>;
471
+ /**
472
+ * An alias for {@link FileHandle.close()}.
473
+ * @since v18.18.0
474
+ */
475
+ [Symbol.asyncDispose](): Promise<void>;
471
476
  }
472
477
 
473
478
  const constants: typeof fsConstants;
@@ -82,6 +82,28 @@ declare var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal
82
82
  };
83
83
  // #endregion borrowed
84
84
 
85
+ // #region Disposable
86
+ interface SymbolConstructor {
87
+ /**
88
+ * A method that is used to release resources held by an object. Called by the semantics of the `using` statement.
89
+ */
90
+ readonly dispose: unique symbol;
91
+
92
+ /**
93
+ * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement.
94
+ */
95
+ readonly asyncDispose: unique symbol;
96
+ }
97
+
98
+ interface Disposable {
99
+ [Symbol.dispose](): void;
100
+ }
101
+
102
+ interface AsyncDisposable {
103
+ [Symbol.asyncDispose](): PromiseLike<void>;
104
+ }
105
+ // #endregion Disposable
106
+
85
107
  // #region ArrayLike.at()
86
108
  interface RelativeIndexable<T> {
87
109
  /**
@@ -1,4 +1,4 @@
1
- // Type definitions for non-npm package Node.js 18.17
1
+ // Type definitions for non-npm package Node.js 18.18
2
2
  // Project: https://nodejs.org/
3
3
  // Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
4
4
  // DefinitelyTyped <https://github.com/DefinitelyTyped>
@@ -63,6 +63,24 @@ declare module "module" {
63
63
  originalLine: number;
64
64
  originalColumn: number;
65
65
  }
66
+ interface SourceOrigin {
67
+ /**
68
+ * The name of the range in the source map, if one was provided
69
+ */
70
+ name?: string;
71
+ /**
72
+ * The file name of the original source, as reported in the SourceMap
73
+ */
74
+ fileName: string;
75
+ /**
76
+ * The 1-indexed lineNumber of the corresponding call site in the original source
77
+ */
78
+ lineNumber: number;
79
+ /**
80
+ * The 1-indexed columnNumber of the corresponding call site in the original source
81
+ */
82
+ columnNumber: number;
83
+ }
66
84
  /**
67
85
  * @since v13.7.0, v12.17.0
68
86
  */
@@ -73,11 +91,34 @@ declare module "module" {
73
91
  readonly payload: SourceMapPayload;
74
92
  constructor(payload: SourceMapPayload);
75
93
  /**
76
- * Given a line number and column number in the generated source file, returns
77
- * an object representing the position in the original file. The object returned
78
- * consists of the following keys:
94
+ * Given a line offset and column offset in the generated source
95
+ * file, returns an object representing the SourceMap range in the
96
+ * original file if found, or an empty object if not.
97
+ *
98
+ * The object returned contains the following keys:
99
+ *
100
+ * The returned value represents the raw range as it appears in the
101
+ * SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and
102
+ * column numbers as they appear in Error messages and CallSite
103
+ * objects.
104
+ *
105
+ * To get the corresponding 1-indexed line and column numbers from a
106
+ * lineNumber and columnNumber as they are reported by Error stacks
107
+ * and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)`
108
+ * @param lineOffset The zero-indexed line number offset in the generated source
109
+ * @param columnOffset The zero-indexed column number offset in the generated source
110
+ */
111
+ findEntry(lineOffset: number, columnOffset: number): SourceMapping;
112
+ /**
113
+ * Given a 1-indexed `lineNumber` and `columnNumber` from a call site in the generated source,
114
+ * find the corresponding call site location in the original source.
115
+ *
116
+ * If the `lineNumber` and `columnNumber` provided are not found in any source map,
117
+ * then an empty object is returned.
118
+ * @param lineNumber The 1-indexed line number of the call site in the generated source
119
+ * @param columnNumber The 1-indexed column number of the call site in the generated source
79
120
  */
80
- findEntry(line: number, column: number): SourceMapping;
121
+ findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {};
81
122
  }
82
123
  interface ImportAssertions extends NodeJS.Dict<string> {
83
124
  type?: string | undefined;
@@ -273,6 +273,12 @@ declare module "net" {
273
273
  * @since v6.1.0
274
274
  */
275
275
  readonly connecting: boolean;
276
+ /**
277
+ * This is `true` if the socket is not connected yet, either because `.connect()`
278
+ * has not yet been called or because it is still in the process of connecting (see `socket.connecting`).
279
+ * @since v10.16.0
280
+ */
281
+ readonly pending: boolean;
276
282
  /**
277
283
  * See `writable.destroyed` for further details.
278
284
  */
@@ -294,12 +300,6 @@ declare module "net" {
294
300
  * @since v18.8.0
295
301
  */
296
302
  readonly localFamily?: string;
297
- /**
298
- * This is `true` if the socket is not connected yet, either because `.connect()`
299
- * has not yet been called or because it is still in the process of connecting (see `socket.connecting`).
300
- * @since v10.16.0
301
- */
302
- readonly pending: boolean;
303
303
  /**
304
304
  * This property represents the state of the connection as a string.
305
305
  * @see {https://nodejs.org/api/net.html#socketreadystate}
@@ -654,6 +654,11 @@ declare module "net" {
654
654
  prependOnceListener(event: "error", listener: (err: Error) => void): this;
655
655
  prependOnceListener(event: "listening", listener: () => void): this;
656
656
  prependOnceListener(event: "drop", listener: (data?: DropArgument) => void): this;
657
+ /**
658
+ * Calls {@link Server.close()} and returns a promise that fulfills when the server has closed.
659
+ * @since v18.18.0
660
+ */
661
+ [Symbol.asyncDispose](): Promise<void>;
657
662
  }
658
663
  type IPVersion = "ipv4" | "ipv6";
659
664
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "18.17.19",
3
+ "version": "18.18.0",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -232,6 +232,6 @@
232
232
  },
233
233
  "scripts": {},
234
234
  "dependencies": {},
235
- "typesPublisherContentHash": "7b1ba7dfb8193add71da2ec241d5edeb642e2742338aabe7e272e1b8b9ebbe41",
235
+ "typesPublisherContentHash": "ad40956229a9b57a72cb2428d13118c8eaeaa1a507d4cd1b29dc0bb540447648",
236
236
  "typeScriptVersion": "4.5"
237
237
  }
@@ -675,6 +675,11 @@ declare module "stream" {
675
675
  removeListener(event: "resume", listener: () => void): this;
676
676
  removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
677
677
  [Symbol.asyncIterator](): AsyncIterableIterator<any>;
678
+ /**
679
+ * Calls `readable.destroy()` with an `AbortError` and returns a promise that fulfills when the stream is finished.
680
+ * @since v18.18.0
681
+ */
682
+ [Symbol.asyncDispose](): Promise<void>;
678
683
  }
679
684
  interface WritableOptions extends StreamOptions<Writable> {
680
685
  decodeStrings?: boolean | undefined;
@@ -59,31 +59,33 @@ declare module "node:test" {
59
59
  * @param options Configuration options for the suite
60
60
  * @param fn The function under suite. Default: A no-op function.
61
61
  */
62
- function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void;
63
- function describe(name?: string, fn?: SuiteFn): void;
64
- function describe(options?: TestOptions, fn?: SuiteFn): void;
65
- function describe(fn?: SuiteFn): void;
62
+ function describe(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
63
+ function describe(name?: string, fn?: SuiteFn): Promise<void>;
64
+ function describe(options?: TestOptions, fn?: SuiteFn): Promise<void>;
65
+ function describe(fn?: SuiteFn): Promise<void>;
66
66
  namespace describe {
67
- // Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`.
68
- function skip(name?: string, options?: TestOptions, fn?: SuiteFn): void;
69
- function skip(name?: string, fn?: SuiteFn): void;
70
- function skip(options?: TestOptions, fn?: SuiteFn): void;
71
- function skip(fn?: SuiteFn): void;
72
-
73
- // Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`.
74
- function todo(name?: string, options?: TestOptions, fn?: SuiteFn): void;
75
- function todo(name?: string, fn?: SuiteFn): void;
76
- function todo(options?: TestOptions, fn?: SuiteFn): void;
77
- function todo(fn?: SuiteFn): void;
78
-
67
+ /**
68
+ * Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`.
69
+ */
70
+ function skip(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
71
+ function skip(name?: string, fn?: SuiteFn): Promise<void>;
72
+ function skip(options?: TestOptions, fn?: SuiteFn): Promise<void>;
73
+ function skip(fn?: SuiteFn): Promise<void>;
74
+ /**
75
+ * Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`.
76
+ */
77
+ function todo(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
78
+ function todo(name?: string, fn?: SuiteFn): Promise<void>;
79
+ function todo(options?: TestOptions, fn?: SuiteFn): Promise<void>;
80
+ function todo(fn?: SuiteFn): Promise<void>;
79
81
  /**
80
82
  * Shorthand for marking a suite as `only`, same as `describe([name], { only: true }[, fn])`.
81
83
  * @since v18.15.0
82
84
  */
83
- function only(name?: string, options?: TestOptions, fn?: SuiteFn): void;
84
- function only(name?: string, fn?: SuiteFn): void;
85
- function only(options?: TestOptions, fn?: SuiteFn): void;
86
- function only(fn?: SuiteFn): void;
85
+ function only(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
86
+ function only(name?: string, fn?: SuiteFn): Promise<void>;
87
+ function only(options?: TestOptions, fn?: SuiteFn): Promise<void>;
88
+ function only(fn?: SuiteFn): Promise<void>;
87
89
  }
88
90
 
89
91
  /**
@@ -94,31 +96,33 @@ declare module "node:test" {
94
96
  * @param fn The function under test. If the test uses callbacks, the callback function is
95
97
  * passed as the second argument. Default: A no-op function.
96
98
  */
97
- function it(name?: string, options?: TestOptions, fn?: TestFn): void;
98
- function it(name?: string, fn?: TestFn): void;
99
- function it(options?: TestOptions, fn?: TestFn): void;
100
- function it(fn?: TestFn): void;
99
+ function it(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
100
+ function it(name?: string, fn?: TestFn): Promise<void>;
101
+ function it(options?: TestOptions, fn?: TestFn): Promise<void>;
102
+ function it(fn?: TestFn): Promise<void>;
101
103
  namespace it {
102
- // Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
103
- function skip(name?: string, options?: TestOptions, fn?: TestFn): void;
104
- function skip(name?: string, fn?: TestFn): void;
105
- function skip(options?: TestOptions, fn?: TestFn): void;
106
- function skip(fn?: TestFn): void;
107
-
108
- // Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
109
- function todo(name?: string, options?: TestOptions, fn?: TestFn): void;
110
- function todo(name?: string, fn?: TestFn): void;
111
- function todo(options?: TestOptions, fn?: TestFn): void;
112
- function todo(fn?: TestFn): void;
113
-
104
+ /**
105
+ * Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
106
+ */
107
+ function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
108
+ function skip(name?: string, fn?: TestFn): Promise<void>;
109
+ function skip(options?: TestOptions, fn?: TestFn): Promise<void>;
110
+ function skip(fn?: TestFn): Promise<void>;
111
+ /**
112
+ * Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
113
+ */
114
+ function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
115
+ function todo(name?: string, fn?: TestFn): Promise<void>;
116
+ function todo(options?: TestOptions, fn?: TestFn): Promise<void>;
117
+ function todo(fn?: TestFn): Promise<void>;
114
118
  /**
115
119
  * Shorthand for marking a test as `only`, same as `it([name], { only: true }[, fn])`.
116
120
  * @since v18.15.0
117
121
  */
118
- function only(name?: string, options?: TestOptions, fn?: TestFn): void;
119
- function only(name?: string, fn?: TestFn): void;
120
- function only(options?: TestOptions, fn?: TestFn): void;
121
- function only(fn?: TestFn): void;
122
+ function only(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
123
+ function only(name?: string, fn?: TestFn): Promise<void>;
124
+ function only(options?: TestOptions, fn?: TestFn): Promise<void>;
125
+ function only(fn?: TestFn): Promise<void>;
122
126
  }
123
127
  /**
124
128
  * Shorthand for skipping a test, same as `test([name], { skip: true }[, fn])`.
@@ -192,10 +196,21 @@ declare module "node:test" {
192
196
  * incremented from the primary's `process.debugPort`.
193
197
  */
194
198
  inspectPort?: number | (() => number) | undefined;
199
+ /**
200
+ * That can be used to only run tests whose name matches the provided pattern.
201
+ * Test name patterns are interpreted as JavaScript regular expressions.
202
+ * For each test that is executed, any corresponding test hooks, such as `beforeEach()`, are also run.
203
+ */
204
+ testNamePatterns?: string | RegExp | string[] | RegExp[];
195
205
  /**
196
206
  * A function that accepts the TestsStream instance and can be used to setup listeners before any tests are run.
197
207
  */
198
208
  setup?: (root: Test) => void | Promise<void>;
209
+ /**
210
+ * Whether to run in watch mode or not.
211
+ * @default false
212
+ */
213
+ watch?: boolean | undefined;
199
214
  }
200
215
  class Test extends AsyncResource {
201
216
  concurrency: number;
@@ -44,6 +44,11 @@ declare module "timers" {
44
44
  */
45
45
  hasRef(): boolean;
46
46
  _onImmediate: Function; // to distinguish it from the Timeout class
47
+ /**
48
+ * Cancels the immediate. This is similar to calling `clearImmediate()`.
49
+ * @since v18.18.0
50
+ */
51
+ [Symbol.dispose](): void;
47
52
  }
48
53
  interface Timeout extends Timer {
49
54
  /**
@@ -64,6 +69,11 @@ declare module "timers" {
64
69
  */
65
70
  refresh(): this;
66
71
  [Symbol.toPrimitive](): number;
72
+ /**
73
+ * Cancels the timeout.
74
+ * @since v18.18.0
75
+ */
76
+ [Symbol.dispose](): void;
67
77
  }
68
78
  }
69
79
  /**
@@ -89,10 +99,10 @@ declare module "timers" {
89
99
  callback: (...args: TArgs) => void,
90
100
  ms?: number,
91
101
  ...args: TArgs
92
- ): NodeJS.Timer;
102
+ ): NodeJS.Timeout;
93
103
  // util.promisify no rest args compability
94
104
  // tslint:disable-next-line void-return
95
- function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timer;
105
+ function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
96
106
  namespace setInterval {
97
107
  const __promisify__: typeof setIntervalPromise;
98
108
  }
@@ -305,6 +305,11 @@ declare module "child_process" {
305
305
  * @since v0.1.90
306
306
  */
307
307
  kill(signal?: NodeJS.Signals | number): boolean;
308
+ /**
309
+ * Calls {@link ChildProcess.kill} with `'SIGTERM'`.
310
+ * @since v18.18.0
311
+ */
312
+ [Symbol.dispose](): void;
308
313
  /**
309
314
  * When an IPC channel has been established between the parent and child (
310
315
  * i.e. when using {@link fork}), the `subprocess.send()` method can
@@ -574,6 +574,11 @@ declare module "dgram" {
574
574
  prependOnceListener(event: "error", listener: (err: Error) => void): this;
575
575
  prependOnceListener(event: "listening", listener: () => void): this;
576
576
  prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
577
+ /**
578
+ * Calls `socket.close()` and returns a promise that fulfills when the socket has closed.
579
+ * @since v18.18.0
580
+ */
581
+ [Symbol.asyncDispose](): Promise<void>;
577
582
  }
578
583
  }
579
584
  declare module "node:dgram" {
@@ -352,6 +352,41 @@ declare module "events" {
352
352
  * objects.
353
353
  */
354
354
  static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void;
355
+ /**
356
+ * Listens once to the `abort` event on the provided `signal`.
357
+ *
358
+ * Listening to the `abort` event on abort signals is unsafe and may
359
+ * lead to resource leaks since another third party with the signal can
360
+ * call `e.stopImmediatePropagation()`. Unfortunately Node.js cannot change
361
+ * this since it would violate the web standard. Additionally, the original
362
+ * API makes it easy to forget to remove listeners.
363
+ *
364
+ * This API allows safely using `AbortSignal`s in Node.js APIs by solving these
365
+ * two issues by listening to the event such that `stopImmediatePropagation` does
366
+ * not prevent the listener from running.
367
+ *
368
+ * Returns a disposable so that it may be unsubscribed from more easily.
369
+ *
370
+ * ```js
371
+ * import { addAbortListener } from 'node:events';
372
+ *
373
+ * function example(signal) {
374
+ * let disposable;
375
+ * try {
376
+ * signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
377
+ * disposable = addAbortListener(signal, (e) => {
378
+ * // Do something when signal is aborted.
379
+ * });
380
+ * } finally {
381
+ * disposable?.[Symbol.dispose]();
382
+ * }
383
+ * }
384
+ * ```
385
+ * @since v18.18.0
386
+ * @experimental
387
+ * @return Disposable that removes the `abort` listener.
388
+ */
389
+ static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
355
390
  /**
356
391
  * This symbol shall be used to install a listener for only monitoring `'error'`
357
392
  * events. Listeners installed using this symbol are called before the regular
@@ -468,6 +468,11 @@ declare module "fs/promises" {
468
468
  * @return Fulfills with `undefined` upon success.
469
469
  */
470
470
  close(): Promise<void>;
471
+ /**
472
+ * An alias for {@link FileHandle.close()}.
473
+ * @since v18.18.0
474
+ */
475
+ [Symbol.asyncDispose](): Promise<void>;
471
476
  }
472
477
 
473
478
  const constants: typeof fsConstants;
@@ -82,6 +82,28 @@ declare var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal
82
82
  };
83
83
  // #endregion borrowed
84
84
 
85
+ // #region Disposable
86
+ interface SymbolConstructor {
87
+ /**
88
+ * A method that is used to release resources held by an object. Called by the semantics of the `using` statement.
89
+ */
90
+ readonly dispose: unique symbol;
91
+
92
+ /**
93
+ * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement.
94
+ */
95
+ readonly asyncDispose: unique symbol;
96
+ }
97
+
98
+ interface Disposable {
99
+ [Symbol.dispose](): void;
100
+ }
101
+
102
+ interface AsyncDisposable {
103
+ [Symbol.asyncDispose](): PromiseLike<void>;
104
+ }
105
+ // #endregion Disposable
106
+
85
107
  // #region ArrayLike.at()
86
108
  interface RelativeIndexable<T> {
87
109
  /**
@@ -93,6 +115,7 @@ interface RelativeIndexable<T> {
93
115
  }
94
116
  interface String extends RelativeIndexable<string> {}
95
117
  interface Array<T> extends RelativeIndexable<T> {}
118
+ interface ReadonlyArray<T> extends RelativeIndexable<T> {}
96
119
  interface Int8Array extends RelativeIndexable<number> {}
97
120
  interface Uint8Array extends RelativeIndexable<number> {}
98
121
  interface Uint8ClampedArray extends RelativeIndexable<number> {}
@@ -157,7 +180,7 @@ declare namespace NodeJS {
157
180
  /**
158
181
  * Name of the script [if this function was defined in a script]
159
182
  */
160
- getFileName(): string | null;
183
+ getFileName(): string | undefined;
161
184
 
162
185
  /**
163
186
  * Current line number [if this function was defined in a script]
@@ -63,6 +63,24 @@ declare module "module" {
63
63
  originalLine: number;
64
64
  originalColumn: number;
65
65
  }
66
+ interface SourceOrigin {
67
+ /**
68
+ * The name of the range in the source map, if one was provided
69
+ */
70
+ name?: string;
71
+ /**
72
+ * The file name of the original source, as reported in the SourceMap
73
+ */
74
+ fileName: string;
75
+ /**
76
+ * The 1-indexed lineNumber of the corresponding call site in the original source
77
+ */
78
+ lineNumber: number;
79
+ /**
80
+ * The 1-indexed columnNumber of the corresponding call site in the original source
81
+ */
82
+ columnNumber: number;
83
+ }
66
84
  /**
67
85
  * @since v13.7.0, v12.17.0
68
86
  */
@@ -73,11 +91,34 @@ declare module "module" {
73
91
  readonly payload: SourceMapPayload;
74
92
  constructor(payload: SourceMapPayload);
75
93
  /**
76
- * Given a line number and column number in the generated source file, returns
77
- * an object representing the position in the original file. The object returned
78
- * consists of the following keys:
94
+ * Given a line offset and column offset in the generated source
95
+ * file, returns an object representing the SourceMap range in the
96
+ * original file if found, or an empty object if not.
97
+ *
98
+ * The object returned contains the following keys:
99
+ *
100
+ * The returned value represents the raw range as it appears in the
101
+ * SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and
102
+ * column numbers as they appear in Error messages and CallSite
103
+ * objects.
104
+ *
105
+ * To get the corresponding 1-indexed line and column numbers from a
106
+ * lineNumber and columnNumber as they are reported by Error stacks
107
+ * and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)`
108
+ * @param lineOffset The zero-indexed line number offset in the generated source
109
+ * @param columnOffset The zero-indexed column number offset in the generated source
110
+ */
111
+ findEntry(lineOffset: number, columnOffset: number): SourceMapping;
112
+ /**
113
+ * Given a 1-indexed `lineNumber` and `columnNumber` from a call site in the generated source,
114
+ * find the corresponding call site location in the original source.
115
+ *
116
+ * If the `lineNumber` and `columnNumber` provided are not found in any source map,
117
+ * then an empty object is returned.
118
+ * @param lineNumber The 1-indexed line number of the call site in the generated source
119
+ * @param columnNumber The 1-indexed column number of the call site in the generated source
79
120
  */
80
- findEntry(line: number, column: number): SourceMapping;
121
+ findOrigin(lineNumber: number, columnNumber: number): SourceOrigin | {};
81
122
  }
82
123
  interface ImportAssertions extends NodeJS.Dict<string> {
83
124
  type?: string | undefined;
@@ -654,6 +654,11 @@ declare module "net" {
654
654
  prependOnceListener(event: "error", listener: (err: Error) => void): this;
655
655
  prependOnceListener(event: "listening", listener: () => void): this;
656
656
  prependOnceListener(event: "drop", listener: (data?: DropArgument) => void): this;
657
+ /**
658
+ * Calls {@link Server.close()} and returns a promise that fulfills when the server has closed.
659
+ * @since v18.18.0
660
+ */
661
+ [Symbol.asyncDispose](): Promise<void>;
657
662
  }
658
663
  type IPVersion = "ipv4" | "ipv6";
659
664
  /**