@types/node 25.6.2 → 25.8.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 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: Thu, 07 May 2026 22:21:35 GMT
11
+ * Last updated: Thu, 14 May 2026 16:39:50 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node/events.d.ts CHANGED
@@ -528,15 +528,12 @@ declare module "node:events" {
528
528
  * import { addAbortListener } from 'node:events';
529
529
  *
530
530
  * function example(signal) {
531
- * let disposable;
532
- * try {
533
- * signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
534
- * disposable = addAbortListener(signal, (e) => {
535
- * // Do something when signal is aborted.
536
- * });
537
- * } finally {
538
- * disposable?.[Symbol.dispose]();
539
- * }
531
+ * signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
532
+ * // addAbortListener() returns a disposable, so the `using` keyword ensures
533
+ * // the abort listener is automatically removed when this scope exits.
534
+ * using _ = addAbortListener(signal, (e) => {
535
+ * // Do something when signal is aborted.
536
+ * });
540
537
  * }
541
538
  * ```
542
539
  * @since v20.5.0
node/fs/promises.d.ts CHANGED
@@ -802,19 +802,42 @@ declare module "node:fs/promises" {
802
802
  * @since v10.0.0
803
803
  * @return Fulfills with the {fs.Stats} object for the given `path`.
804
804
  */
805
+ function stat(path: PathLike): Promise<Stats>;
805
806
  function stat(
806
807
  path: PathLike,
807
808
  opts?: StatOptions & {
808
809
  bigint?: false | undefined;
810
+ throwIfNoEntry?: true | undefined;
809
811
  },
810
812
  ): Promise<Stats>;
811
813
  function stat(
812
814
  path: PathLike,
813
815
  opts: StatOptions & {
814
816
  bigint: true;
817
+ throwIfNoEntry?: true | undefined;
815
818
  },
816
819
  ): Promise<BigIntStats>;
817
- function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
820
+ function stat(
821
+ path: PathLike,
822
+ opts: StatOptions & {
823
+ bigint?: false | undefined;
824
+ throwIfNoEntry: false;
825
+ },
826
+ ): Promise<Stats | undefined>;
827
+ function stat(
828
+ path: PathLike,
829
+ opts: StatOptions & {
830
+ bigint: true;
831
+ throwIfNoEntry: false;
832
+ },
833
+ ): Promise<BigIntStats | undefined>;
834
+ function stat(
835
+ path: PathLike,
836
+ opts: StatOptions & {
837
+ throwIfNoEntry?: true | undefined;
838
+ },
839
+ ): Promise<Stats | BigIntStats>;
840
+ function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats | undefined>;
818
841
  /**
819
842
  * @since v19.6.0, v18.15.0
820
843
  * @return Fulfills with the {fs.StatFs} object for the given `path`.
node/fs.d.ts CHANGED
@@ -1144,6 +1144,7 @@ declare module "node:fs" {
1144
1144
  options:
1145
1145
  | (StatOptions & {
1146
1146
  bigint?: false | undefined;
1147
+ throwIfNoEntry?: true | undefined;
1147
1148
  })
1148
1149
  | undefined,
1149
1150
  callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void,
@@ -1152,33 +1153,82 @@ declare module "node:fs" {
1152
1153
  path: PathLike,
1153
1154
  options: StatOptions & {
1154
1155
  bigint: true;
1156
+ throwIfNoEntry?: true | undefined;
1155
1157
  },
1156
1158
  callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void,
1157
1159
  ): void;
1158
1160
  function stat(
1159
1161
  path: PathLike,
1160
- options: StatOptions | undefined,
1162
+ options: StatOptions & {
1163
+ bigint?: false | undefined;
1164
+ throwIfNoEntry: false;
1165
+ },
1166
+ callback: (err: NodeJS.ErrnoException | null, stats: Stats | undefined) => void,
1167
+ ): void;
1168
+ function stat(
1169
+ path: PathLike,
1170
+ options: StatOptions & {
1171
+ bigint: true;
1172
+ throwIfNoEntry: false;
1173
+ },
1174
+ callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats | undefined) => void,
1175
+ ): void;
1176
+ function stat(
1177
+ path: PathLike,
1178
+ options: StatOptions & {
1179
+ throwIfNoEntry?: true | undefined;
1180
+ },
1161
1181
  callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void,
1162
1182
  ): void;
1183
+ function stat(
1184
+ path: PathLike,
1185
+ options: StatOptions | undefined,
1186
+ callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats | undefined) => void,
1187
+ ): void;
1163
1188
  namespace stat {
1189
+ // TODO: aliased promisify signatures
1164
1190
  /**
1165
1191
  * Asynchronous stat(2) - Get file status.
1166
1192
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1167
1193
  */
1194
+ function __promisify__(path: PathLike): Promise<Stats>;
1168
1195
  function __promisify__(
1169
1196
  path: PathLike,
1170
1197
  options?: StatOptions & {
1171
1198
  bigint?: false | undefined;
1199
+ throwIfNoEntry?: true | undefined;
1172
1200
  },
1173
1201
  ): Promise<Stats>;
1174
1202
  function __promisify__(
1175
1203
  path: PathLike,
1176
1204
  options: StatOptions & {
1177
1205
  bigint: true;
1206
+ throwIfNoEntry?: true | undefined;
1178
1207
  },
1179
1208
  ): Promise<BigIntStats>;
1180
- function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats>;
1209
+ function __promisify__(
1210
+ path: PathLike,
1211
+ options: StatOptions & {
1212
+ bigint?: false | undefined;
1213
+ throwIfNoEntry: false;
1214
+ },
1215
+ ): Promise<Stats | undefined>;
1216
+ function __promisify__(
1217
+ path: PathLike,
1218
+ options: StatOptions & {
1219
+ bigint: true;
1220
+ throwIfNoEntry: false;
1221
+ },
1222
+ ): Promise<BigIntStats | undefined>;
1223
+ function __promisify__(
1224
+ path: PathLike,
1225
+ options: StatOptions & {
1226
+ throwIfNoEntry?: true | undefined;
1227
+ },
1228
+ ): Promise<Stats | BigIntStats>;
1229
+ function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats | undefined>;
1181
1230
  }
1231
+ /** @deprecated This orphaned interface will be removed in a future version. */
1182
1232
  interface StatSyncFn extends Function {
1183
1233
  (path: PathLike, options?: undefined): Stats;
1184
1234
  (
@@ -1220,7 +1270,42 @@ declare module "node:fs" {
1220
1270
  * Synchronous stat(2) - Get file status.
1221
1271
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1222
1272
  */
1223
- const statSync: StatSyncFn;
1273
+ function statSync(path: PathLike): Stats;
1274
+ function statSync(
1275
+ path: PathLike,
1276
+ options?: StatOptions & {
1277
+ bigint?: false | undefined;
1278
+ throwIfNoEntry?: true | undefined;
1279
+ },
1280
+ ): Stats;
1281
+ function statSync(
1282
+ path: PathLike,
1283
+ options: StatOptions & {
1284
+ bigint: true;
1285
+ throwIfNoEntry?: true | undefined;
1286
+ },
1287
+ ): BigIntStats;
1288
+ function statSync(
1289
+ path: PathLike,
1290
+ options: StatOptions & {
1291
+ bigint?: false | undefined;
1292
+ throwIfNoEntry: false;
1293
+ },
1294
+ ): Stats | undefined;
1295
+ function statSync(
1296
+ path: PathLike,
1297
+ options: StatOptions & {
1298
+ bigint: true;
1299
+ throwIfNoEntry: false;
1300
+ },
1301
+ ): BigIntStats | undefined;
1302
+ function statSync(
1303
+ path: PathLike,
1304
+ options: StatOptions & {
1305
+ throwIfNoEntry?: true | undefined;
1306
+ },
1307
+ ): Stats | BigIntStats;
1308
+ function statSync(path: PathLike, options?: StatOptions): Stats | BigIntStats | undefined;
1224
1309
  /**
1225
1310
  * Invokes the callback with the `fs.Stats` for the file descriptor.
1226
1311
  *
@@ -1410,7 +1495,42 @@ declare module "node:fs" {
1410
1495
  * Synchronous lstat(2) - Get file status. Does not dereference symbolic links.
1411
1496
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1412
1497
  */
1413
- const lstatSync: StatSyncFn;
1498
+ function lstatSync(path: PathLike): Stats;
1499
+ function lstatSync(
1500
+ path: PathLike,
1501
+ options?: StatOptions & {
1502
+ bigint?: false | undefined;
1503
+ throwIfNoEntry?: true | undefined;
1504
+ },
1505
+ ): Stats;
1506
+ function lstatSync(
1507
+ path: PathLike,
1508
+ options: StatOptions & {
1509
+ bigint: true;
1510
+ throwIfNoEntry?: true | undefined;
1511
+ },
1512
+ ): BigIntStats;
1513
+ function lstatSync(
1514
+ path: PathLike,
1515
+ options: StatOptions & {
1516
+ bigint?: false | undefined;
1517
+ throwIfNoEntry: false;
1518
+ },
1519
+ ): Stats | undefined;
1520
+ function lstatSync(
1521
+ path: PathLike,
1522
+ options: StatOptions & {
1523
+ bigint: true;
1524
+ throwIfNoEntry: false;
1525
+ },
1526
+ ): BigIntStats | undefined;
1527
+ function lstatSync(
1528
+ path: PathLike,
1529
+ options: StatOptions & {
1530
+ throwIfNoEntry?: true | undefined;
1531
+ },
1532
+ ): Stats | BigIntStats;
1533
+ function lstatSync(path: PathLike, options?: StatOptions): Stats | BigIntStats | undefined;
1414
1534
  /**
1415
1535
  * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail. No arguments other than
1416
1536
  * a possible
@@ -4461,10 +4581,10 @@ declare module "node:fs" {
4461
4581
  }
4462
4582
  interface StatOptions {
4463
4583
  bigint?: boolean | undefined;
4464
- }
4465
- interface StatSyncOptions extends StatOptions {
4466
4584
  throwIfNoEntry?: boolean | undefined;
4467
4585
  }
4586
+ /** @deprecated This orphaned interface will be removed in a future version. Use `StatOptions` instead. */
4587
+ interface StatSyncOptions extends StatOptions {}
4468
4588
  interface CopyOptionsBase {
4469
4589
  /**
4470
4590
  * Dereference symlinks
node/http2.d.ts CHANGED
@@ -1242,10 +1242,14 @@ declare module "node:http2" {
1242
1242
  > extends SessionOptions {
1243
1243
  streamResetBurst?: number | undefined;
1244
1244
  streamResetRate?: number | undefined;
1245
+ /** @deprecated Use `http1Options.IncomingMessage` instead. */
1245
1246
  Http1IncomingMessage?: Http1Request | undefined;
1247
+ /** @deprecated Use `http1Options.ServerResponse` instead. */
1246
1248
  Http1ServerResponse?: Http1Response | undefined;
1249
+ http1Options?: Http1Options<Http1Request, Http1Response> | undefined;
1247
1250
  Http2ServerRequest?: Http2Request | undefined;
1248
1251
  Http2ServerResponse?: Http2Response | undefined;
1252
+ strictSingleValueFields?: boolean | undefined;
1249
1253
  }
1250
1254
  interface SecureClientSessionOptions extends ClientSessionOptions, tls.ConnectionOptions {}
1251
1255
  interface SecureServerSessionOptions<
@@ -1269,6 +1273,14 @@ declare module "node:http2" {
1269
1273
  allowHTTP1?: boolean | undefined;
1270
1274
  origins?: string[] | undefined;
1271
1275
  }
1276
+ interface Http1Options<
1277
+ Request extends typeof IncomingMessage,
1278
+ Response extends typeof ServerResponse<InstanceType<Request>>,
1279
+ > {
1280
+ IncomingMessage?: Request | undefined;
1281
+ ServerResponse?: Response | undefined;
1282
+ keepAliveTimeout?: number | undefined;
1283
+ }
1272
1284
  interface Http2ServerCommon {
1273
1285
  setTimeout(msec?: number, callback?: () => void): this;
1274
1286
  /**
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "25.6.2",
3
+ "version": "25.8.0",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -147,9 +147,9 @@
147
147
  },
148
148
  "scripts": {},
149
149
  "dependencies": {
150
- "undici-types": "~7.19.0"
150
+ "undici-types": ">=7.24.0 <7.24.7"
151
151
  },
152
152
  "peerDependencies": {},
153
- "typesPublisherContentHash": "89af6b1f98f4dcf78863724bff751d6099486220dae09983e7b6430b0be61ac2",
153
+ "typesPublisherContentHash": "e3b0c76dfc9cc84424890451a36d8ae1dbc86b0b0e49cc458f2a886fda8e4649",
154
154
  "typeScriptVersion": "5.3"
155
155
  }
node/process.d.ts CHANGED
@@ -1474,30 +1474,35 @@ declare module "node:process" {
1474
1474
  * Will generate an object similar to:
1475
1475
  *
1476
1476
  * ```console
1477
- * { node: '20.2.0',
1478
- * acorn: '8.8.2',
1479
- * ada: '2.4.0',
1480
- * ares: '1.19.0',
1481
- * base64: '0.5.0',
1482
- * brotli: '1.0.9',
1483
- * cjs_module_lexer: '1.2.2',
1484
- * cldr: '43.0',
1485
- * icu: '73.1',
1486
- * llhttp: '8.1.0',
1487
- * modules: '115',
1488
- * napi: '8',
1489
- * nghttp2: '1.52.0',
1490
- * nghttp3: '0.7.0',
1491
- * ngtcp2: '0.8.1',
1492
- * openssl: '3.0.8+quic',
1493
- * simdutf: '3.2.9',
1494
- * tz: '2023c',
1495
- * undici: '5.22.0',
1496
- * unicode: '15.0',
1497
- * uv: '1.44.2',
1498
- * uvwasi: '0.0.16',
1499
- * v8: '11.3.244.8-node.9',
1500
- * zlib: '1.2.13' }
1477
+ * { node: '26.0.0-pre',
1478
+ * acorn: '8.15.0',
1479
+ * ada: '3.4.1',
1480
+ * amaro: '1.1.5',
1481
+ * ares: '1.34.6',
1482
+ * brotli: '1.2.0',
1483
+ * merve: '1.0.0',
1484
+ * cldr: '48.0',
1485
+ * icu: '78.2',
1486
+ * llhttp: '9.3.0',
1487
+ * modules: '144',
1488
+ * napi: '10',
1489
+ * nbytes: '0.1.1',
1490
+ * ncrypto: '0.0.1',
1491
+ * nghttp2: '1.68.0',
1492
+ * nghttp3: '',
1493
+ * ngtcp2: '',
1494
+ * openssl: '3.5.4',
1495
+ * simdjson: '4.2.4',
1496
+ * simdutf: '7.3.3',
1497
+ * sqlite: '3.51.2',
1498
+ * tz: '2025c',
1499
+ * undici: '7.18.2',
1500
+ * unicode: '17.0',
1501
+ * uv: '1.51.0',
1502
+ * uvwasi: '0.0.23',
1503
+ * v8: '14.3.127.18-node.10',
1504
+ * zlib: '1.3.1-e00f703',
1505
+ * zstd: '1.5.7' }
1501
1506
  * ```
1502
1507
  * @since v0.2.0
1503
1508
  */
node/sqlite.d.ts CHANGED
@@ -87,6 +87,29 @@ declare module "node:sqlite" {
87
87
  * @default true
88
88
  */
89
89
  defensive?: boolean | undefined;
90
+ /**
91
+ * Configuration for various SQLite limits. These limits
92
+ * can be used to prevent excessive resource consumption when handling
93
+ * potentially malicious input. See [Run-Time Limits](https://www.sqlite.org/c3ref/c_limit_attached.html) and [Limit Constants](https://www.sqlite.org/c3ref/limit.html)
94
+ * in the SQLite documentation for details. Default values are determined by
95
+ * SQLite's compile-time defaults and may vary depending on how SQLite was
96
+ * built. The following properties are supported:
97
+ * @since v25.8.0
98
+ */
99
+ limits?: NodeJS.PartialOptions<DatabaseLimits> | undefined;
100
+ }
101
+ interface DatabaseLimits {
102
+ length: number;
103
+ sqlLength: number;
104
+ column: number;
105
+ exprDepth: number;
106
+ compoundSelect: number;
107
+ vdbeOp: number;
108
+ functionArg: number;
109
+ attach: number;
110
+ likePatternLength: number;
111
+ variableNumber: number;
112
+ triggerDepth: number;
90
113
  }
91
114
  interface CreateSessionOptions {
92
115
  /**
@@ -311,18 +334,17 @@ declare module "node:sqlite" {
311
334
  * @since v22.13.0
312
335
  * @param name The name of the SQLite function to create.
313
336
  * @param options Optional configuration settings for the function.
314
- * @param func The JavaScript function to call when the SQLite
315
- * function is invoked. The return value of this function should be a valid
316
- * SQLite data type: see
317
- * [Type conversion between JavaScript and SQLite](https://nodejs.org/docs/latest-v25.x/api/sqlite.html#type-conversion-between-javascript-and-sqlite).
318
- * The result defaults to `NULL` if the return value is `undefined`.
337
+ * @param fn The JavaScript function to call when the SQLite function is
338
+ * invoked. The return value of this function should be a valid SQLite data type:
339
+ * see [Type conversion between JavaScript and SQLite](https://nodejs.org/docs/latest-v25.x/api/sqlite.html#type-conversion-between-javascript-and-sqlite). The result defaults to
340
+ * `NULL` if the return value is `undefined`.
319
341
  */
320
342
  function(
321
343
  name: string,
322
344
  options: FunctionOptions,
323
- func: (...args: SQLOutputValue[]) => SQLInputValue,
345
+ fn: (...args: SQLOutputValue[]) => SQLInputValue,
324
346
  ): void;
325
- function(name: string, func: (...args: SQLOutputValue[]) => SQLInputValue): void;
347
+ function(name: string, fn: (...args: SQLOutputValue[]) => SQLInputValue): void;
326
348
  /**
327
349
  * Sets an authorizer callback that SQLite will invoke whenever it attempts to
328
350
  * access data or modify the database schema through prepared statements.
@@ -392,6 +414,31 @@ declare module "node:sqlite" {
392
414
  * @since v24.0.0
393
415
  */
394
416
  readonly isTransaction: boolean;
417
+ /**
418
+ * An object for getting and setting SQLite database limits at runtime.
419
+ * Each property corresponds to an SQLite limit and can be read or written.
420
+ *
421
+ * ```js
422
+ * const db = new DatabaseSync(':memory:');
423
+ *
424
+ * // Read current limit
425
+ * console.log(db.limits.length);
426
+ *
427
+ * // Set a new limit
428
+ * db.limits.sqlLength = 100000;
429
+ *
430
+ * // Reset a limit to its compile-time maximum
431
+ * db.limits.sqlLength = Infinity;
432
+ * ```
433
+ *
434
+ * Available properties: `length`, `sqlLength`, `column`, `exprDepth`,
435
+ * `compoundSelect`, `vdbeOp`, `functionArg`, `attach`, `likePatternLength`,
436
+ * `variableNumber`, `triggerDepth`.
437
+ *
438
+ * Setting a property to `Infinity` resets the limit to its compile-time maximum value.
439
+ * @since v25.8.0
440
+ */
441
+ readonly limits: DatabaseLimits;
395
442
  /**
396
443
  * Opens the database specified in the `path` argument of the `DatabaseSync`constructor. This method should only be used when the database is not opened via
397
444
  * the constructor. An exception is thrown if the database is already open.
node/stream.d.ts CHANGED
@@ -1067,7 +1067,7 @@ declare module "node:stream" {
1067
1067
  writableCorked?: number | undefined;
1068
1068
  }
1069
1069
  interface DuplexToWebOptions {
1070
- type?: web.ReadableStreamType | undefined;
1070
+ readableType?: web.ReadableStreamType | undefined;
1071
1071
  }
1072
1072
  interface DuplexEventMap extends ReadableEventMap, WritableEventMap {}
1073
1073
  /**
node/test/reporters.d.ts CHANGED
@@ -8,6 +8,7 @@ declare module "node:test/reporters" {
8
8
  | { type: "test:diagnostic"; data: EventData.TestDiagnostic }
9
9
  | { type: "test:enqueue"; data: EventData.TestEnqueue }
10
10
  | { type: "test:fail"; data: EventData.TestFail }
11
+ | { type: "test:interrupted"; data: EventData.TestInterrupted }
11
12
  | { type: "test:pass"; data: EventData.TestPass }
12
13
  | { type: "test:plan"; data: EventData.TestPlan }
13
14
  | { type: "test:start"; data: EventData.TestStart }
node/test.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare module "node:test" {
2
- import { AssertMethodNames } from "node:assert";
2
+ import { AssertMethodNames, AssertPredicate } from "node:assert";
3
3
  import { Readable, ReadableEventMap } from "node:stream";
4
4
  import { TestEvent } from "node:test/reporters";
5
5
  import { URL } from "node:url";
@@ -111,7 +111,12 @@ declare module "node:test" {
111
111
  function only(name?: string, fn?: SuiteFn): Promise<void>;
112
112
  function only(options?: TestOptions, fn?: SuiteFn): Promise<void>;
113
113
  function only(fn?: SuiteFn): Promise<void>;
114
- // added in v25.5.0, undocumented
114
+ /**
115
+ * This flips the pass/fail reporting for a specific test or suite: a flagged test
116
+ * case must throw in order to pass, and a flagged test case that does not throw
117
+ * fails.
118
+ * @since v25.5.0
119
+ */
115
120
  function expectFailure(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
116
121
  function expectFailure(name?: string, fn?: SuiteFn): Promise<void>;
117
122
  function expectFailure(options?: TestOptions, fn?: SuiteFn): Promise<void>;
@@ -334,6 +339,7 @@ declare module "node:test" {
334
339
  * This options is not compatible with `isolation='none'`. These variables will override
335
340
  * those from the main process, and are not merged with `process.env`.
336
341
  * @since v25.6.0
342
+ * @default process.env
337
343
  */
338
344
  env?: NodeJS.ProcessEnv | undefined;
339
345
  }
@@ -345,6 +351,7 @@ declare module "node:test" {
345
351
  "test:diagnostic": [data: EventData.TestDiagnostic];
346
352
  "test:enqueue": [data: EventData.TestEnqueue];
347
353
  "test:fail": [data: EventData.TestFail];
354
+ "test:interrupted": [data: EventData.TestInterrupted];
348
355
  "test:pass": [data: EventData.TestPass];
349
356
  "test:plan": [data: EventData.TestPlan];
350
357
  "test:start": [data: EventData.TestStart];
@@ -736,6 +743,13 @@ declare module "node:test" {
736
743
  */
737
744
  skip?: string | boolean;
738
745
  }
746
+ interface TestInterrupted {
747
+ /**
748
+ * An array of objects containing information about the
749
+ * interrupted tests.
750
+ */
751
+ tests: TestStart[];
752
+ }
739
753
  interface TestPass extends LocationInfo {
740
754
  /**
741
755
  * Additional execution metadata.
@@ -983,6 +997,34 @@ declare module "node:test" {
983
997
  * @since v21.7.0, v20.12.0
984
998
  */
985
999
  readonly attempt: number;
1000
+ /**
1001
+ * The unique identifier of the worker running the current test file. This value is
1002
+ * derived from the `NODE_TEST_WORKER_ID` environment variable. When running tests
1003
+ * with `--test-isolation=process` (the default), each test file runs in a separate
1004
+ * child process and is assigned a worker ID from 1 to N, where N is the number of
1005
+ * concurrent workers. When running with `--test-isolation=none`, all tests run in
1006
+ * the same process and the worker ID is always 1. This value is `undefined` when
1007
+ * not running in a test context.
1008
+ *
1009
+ * This property is useful for splitting resources (like database connections or
1010
+ * server ports) across concurrent test files:
1011
+ *
1012
+ * ```js
1013
+ * import { test } from 'node:test';
1014
+ * import { process } from 'node:process';
1015
+ *
1016
+ * test('database operations', async (t) => {
1017
+ * // Worker ID is available via context
1018
+ * console.log(`Running in worker ${t.workerId}`);
1019
+ *
1020
+ * // Or via environment variable (available at import time)
1021
+ * const workerId = process.env.NODE_TEST_WORKER_ID;
1022
+ * // Use workerId to allocate separate resources per worker
1023
+ * });
1024
+ * ```
1025
+ * @since v25.8.0
1026
+ */
1027
+ readonly workerId: number | undefined;
986
1028
  /**
987
1029
  * This function is used to set the number of assertions and subtests that are expected to run
988
1030
  * within the test. If the number of assertions and subtests that run does not match the
@@ -1263,6 +1305,17 @@ declare module "node:test" {
1263
1305
  * @default false
1264
1306
  */
1265
1307
  concurrency?: number | boolean | undefined;
1308
+ /**
1309
+ * If truthy, the test is expected to fail. If a non-empty string is provided, that string is displayed
1310
+ * in the test results as the reason why the test is expected to fail. If a
1311
+ * `RegExp`, `Function`, `Object`, or `Error` is provided directly (without wrapping in `{ match: … }`), the test passes
1312
+ * only if the thrown error matches, following the behavior of
1313
+ * `assert.throws`. To provide both a reason and validation, pass an object
1314
+ * with `label` (string) and `match` (RegExp, Function, Object, or Error).
1315
+ * @since v25.5.0
1316
+ * @default false
1317
+ */
1318
+ expectFailure?: boolean | string | AssertPredicate | undefined;
1266
1319
  /**
1267
1320
  * If truthy, and the test context is configured to run `only` tests, then this test will be
1268
1321
  * run. Otherwise, the test is skipped.
@@ -1301,8 +1354,6 @@ declare module "node:test" {
1301
1354
  * @since v22.2.0
1302
1355
  */
1303
1356
  plan?: number | undefined;
1304
- // added in v25.5.0, undocumented
1305
- expectFailure?: boolean | undefined;
1306
1357
  }
1307
1358
  /**
1308
1359
  * This function creates a hook that runs before executing a suite.
node/url.d.ts CHANGED
@@ -229,9 +229,31 @@ declare module "node:url" {
229
229
  * * `result` is returned.
230
230
  * @since v0.1.25
231
231
  * @legacy Use the WHATWG URL API instead.
232
- * @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise). If a string, it is converted to an object by passing it to `url.parse()`.
232
+ * @param urlObject A URL object (as returned by `url.parse()` or constructed otherwise).
233
233
  */
234
- function format(urlObject: UrlObject | string): string;
234
+ function format(urlObject: UrlObject): string;
235
+ /**
236
+ * `url.format(urlString)` is shorthand for `url.format(url.parse(urlString))`.
237
+ *
238
+ * Because it invokes the deprecated `url.parse()` internally, passing a string argument
239
+ * to `url.format()` is itself deprecated.
240
+ *
241
+ * Canonicalizing a URL string can be performed using the WHATWG URL API, by
242
+ * constructing a new URL object and calling `url.toString()`.
243
+ *
244
+ * ```js
245
+ * import { URL } from 'node:url';
246
+ *
247
+ * const unformatted = 'http://[fe80:0:0:0:0:0:0:1]:/a/b?a=b#abc';
248
+ * const formatted = new URL(unformatted).toString();
249
+ *
250
+ * console.log(formatted); // Prints: http://[fe80::1]/a/b?a=b#abc
251
+ * ```
252
+ * @since v0.1.25
253
+ * @deprecated Use the WHATWG URL API instead.
254
+ * @param urlString A string that will be passed to `url.parse()` and then formatted.
255
+ */
256
+ function format(urlString: string): string;
235
257
  /**
236
258
  * The `url.resolve()` method resolves a target URL relative to a base URL in a
237
259
  * manner similar to that of a web browser resolving an anchor tag.
@@ -243,6 +265,8 @@ declare module "node:url" {
243
265
  * url.resolve('http://example.com/one', '/two'); // 'http://example.com/two'
244
266
  * ```
245
267
  *
268
+ * Because it invokes the deprecated `url.parse()` internally, `url.resolve()` is itself deprecated.
269
+ *
246
270
  * To achieve the same result using the WHATWG URL API:
247
271
  *
248
272
  * ```js
@@ -261,7 +285,7 @@ declare module "node:url" {
261
285
  * resolve('http://example.com/one', '/two'); // 'http://example.com/two'
262
286
  * ```
263
287
  * @since v0.1.25
264
- * @legacy Use the WHATWG URL API instead.
288
+ * @deprecated Use the WHATWG URL API instead.
265
289
  * @param from The base URL to use if `to` is a relative URL.
266
290
  * @param to The target URL to resolve.
267
291
  */
node/vm.d.ts CHANGED
@@ -200,16 +200,16 @@ declare module "node:vm" {
200
200
  * The globals are contained in the `context` object.
201
201
  *
202
202
  * ```js
203
- * import vm from 'node:vm';
203
+ * import { createContext, Script } from 'node:vm';
204
204
  *
205
205
  * const context = {
206
206
  * animal: 'cat',
207
207
  * count: 2,
208
208
  * };
209
209
  *
210
- * const script = new vm.Script('count += 1; name = "kitty";');
210
+ * const script = new Script('count += 1; name = "kitty";');
211
211
  *
212
- * vm.createContext(context);
212
+ * createContext(context);
213
213
  * for (let i = 0; i < 10; ++i) {
214
214
  * script.runInContext(context);
215
215
  * }
@@ -243,9 +243,9 @@ declare module "node:vm" {
243
243
  * contained within each individual `context`.
244
244
  *
245
245
  * ```js
246
- * const vm = require('node:vm');
246
+ * import { constants, Script } from 'node:vm';
247
247
  *
248
- * const script = new vm.Script('globalVar = "set"');
248
+ * const script = new Script('globalVar = "set"');
249
249
  *
250
250
  * const contexts = [{}, {}, {}];
251
251
  * contexts.forEach((context) => {
@@ -256,10 +256,10 @@ declare module "node:vm" {
256
256
  * // Prints: [{ globalVar: 'set' }, { globalVar: 'set' }, { globalVar: 'set' }]
257
257
  *
258
258
  * // This would throw if the context is created from a contextified object.
259
- * // vm.constants.DONT_CONTEXTIFY allows creating contexts with ordinary
259
+ * // constants.DONT_CONTEXTIFY allows creating contexts with ordinary
260
260
  * // global objects that can be frozen.
261
- * const freezeScript = new vm.Script('Object.freeze(globalThis); globalThis;');
262
- * const frozenContext = freezeScript.runInNewContext(vm.constants.DONT_CONTEXTIFY);
261
+ * const freezeScript = new Script('Object.freeze(globalThis); globalThis;');
262
+ * const frozenContext = freezeScript.runInNewContext(constants.DONT_CONTEXTIFY);
263
263
  * ```
264
264
  * @since v0.3.1
265
265
  * @param contextObject Either `vm.constants.DONT_CONTEXTIFY` or an object that will be contextified.
@@ -278,11 +278,11 @@ declare module "node:vm" {
278
278
  * executes that code multiple times:
279
279
  *
280
280
  * ```js
281
- * import vm from 'node:vm';
281
+ * import { Script } from 'node:vm';
282
282
  *
283
283
  * global.globalVar = 0;
284
284
  *
285
- * const script = new vm.Script('globalVar += 1', { filename: 'myfile.vm' });
285
+ * const script = new Script('globalVar += 1', { filename: 'myfile.vm' });
286
286
  *
287
287
  * for (let i = 0; i < 1000; ++i) {
288
288
  * script.runInThisContext();
@@ -371,14 +371,14 @@ declare module "node:vm" {
371
371
  * variables will remain unchanged.
372
372
  *
373
373
  * ```js
374
- * const vm = require('node:vm');
374
+ * import { createContext, runInContext } from 'node:vm';
375
375
  *
376
376
  * global.globalVar = 3;
377
377
  *
378
378
  * const context = { globalVar: 1 };
379
- * vm.createContext(context);
379
+ * createContext(context);
380
380
  *
381
- * vm.runInContext('globalVar *= 2;', context);
381
+ * runInContext('globalVar *= 2;', context);
382
382
  *
383
383
  * console.log(context);
384
384
  * // Prints: { globalVar: 2 }
@@ -429,13 +429,13 @@ declare module "node:vm" {
429
429
  * The following example compiles and executes different scripts using a single `contextified` object:
430
430
  *
431
431
  * ```js
432
- * import vm from 'node:vm';
432
+ * import { createContext, runInContext } from 'node:vm';
433
433
  *
434
434
  * const contextObject = { globalVar: 1 };
435
- * vm.createContext(contextObject);
435
+ * createContext(contextObject);
436
436
  *
437
437
  * for (let i = 0; i < 10; ++i) {
438
- * vm.runInContext('globalVar *= 2;', contextObject);
438
+ * runInContext('globalVar *= 2;', contextObject);
439
439
  * }
440
440
  * console.log(contextObject);
441
441
  * // Prints: { globalVar: 1024 }
@@ -466,21 +466,24 @@ declare module "node:vm" {
466
466
  * variable and sets a new one. These globals are contained in the `contextObject`.
467
467
  *
468
468
  * ```js
469
- * const vm = require('node:vm');
469
+ * import { runInNewContext, constants } from 'node:vm';
470
470
  *
471
471
  * const contextObject = {
472
472
  * animal: 'cat',
473
473
  * count: 2,
474
474
  * };
475
475
  *
476
- * vm.runInNewContext('count += 1; name = "kitty"', contextObject);
476
+ * runInNewContext('count += 1; name = "kitty"', contextObject);
477
477
  * console.log(contextObject);
478
478
  * // Prints: { animal: 'cat', count: 3, name: 'kitty' }
479
479
  *
480
480
  * // This would throw if the context is created from a contextified object.
481
481
  * // vm.constants.DONT_CONTEXTIFY allows creating contexts with ordinary global objects that
482
482
  * // can be frozen.
483
- * const frozenContext = vm.runInNewContext('Object.freeze(globalThis); globalThis;', vm.constants.DONT_CONTEXTIFY);
483
+ * const frozenContext = runInNewContext(
484
+ * 'Object.freeze(globalThis); globalThis;',
485
+ * constants.DONT_CONTEXTIFY,
486
+ * );
484
487
  * ```
485
488
  * @since v0.3.1
486
489
  * @param code The JavaScript code to compile and run.
@@ -504,10 +507,10 @@ declare module "node:vm" {
504
507
  * the JavaScript [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) function to run the same code:
505
508
  *
506
509
  * ```js
507
- * import vm from 'node:vm';
510
+ * import { runInThisContext } from 'node:vm';
508
511
  * let localVar = 'initial value';
509
512
  *
510
- * const vmResult = vm.runInThisContext('localVar = "vm";');
513
+ * const vmResult = runInThisContext('localVar = "vm";');
511
514
  * console.log(`vmResult: '${vmResult}', localVar: '${localVar}'`);
512
515
  * // Prints: vmResult: 'vm', localVar: 'initial value'
513
516
  *
@@ -519,38 +522,6 @@ declare module "node:vm" {
519
522
  * Because `vm.runInThisContext()` does not have access to the local scope, `localVar` is unchanged. In contrast,
520
523
  * [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) _does_ have access to the
521
524
  * local scope, so the value `localVar` is changed. In this way `vm.runInThisContext()` is much like an [indirect `eval()` call](https://es5.github.io/#x10.4.2), e.g.`(0,eval)('code')`.
522
- *
523
- * ## Example: Running an HTTP server within a VM
524
- *
525
- * When using either `script.runInThisContext()` or {@link runInThisContext}, the code is executed within the current V8 global
526
- * context. The code passed to this VM context will have its own isolated scope.
527
- *
528
- * In order to run a simple web server using the `node:http` module the code passed
529
- * to the context must either import `node:http` on its own, or have a
530
- * reference to the `node:http` module passed to it. For instance:
531
- *
532
- * ```js
533
- * 'use strict';
534
- * import vm from 'node:vm';
535
- *
536
- * const code = `
537
- * ((require) => {
538
- * const http = require('node:http');
539
- *
540
- * http.createServer((request, response) => {
541
- * response.writeHead(200, { 'Content-Type': 'text/plain' });
542
- * response.end('Hello World\\n');
543
- * }).listen(8124);
544
- *
545
- * console.log('Server running at http://127.0.0.1:8124/');
546
- * })`;
547
- *
548
- * vm.runInThisContext(code)(require);
549
- * ```
550
- *
551
- * The `require()` in the above case shares the state with the context it is
552
- * passed from. This may introduce risks when untrusted code is executed, e.g.
553
- * altering objects in the context in unwanted ways.
554
525
  * @since v0.3.1
555
526
  * @param code The JavaScript code to compile and run.
556
527
  * @return the result of the very last statement executed in the script.
@@ -582,44 +553,32 @@ declare module "node:vm" {
582
553
  * the memory occupied by each heap space in the current V8 instance.
583
554
  *
584
555
  * ```js
585
- * import vm from 'node:vm';
556
+ * import { createContext, measureMemory } from 'node:vm';
586
557
  * // Measure the memory used by the main context.
587
- * vm.measureMemory({ mode: 'summary' })
558
+ * measureMemory({ mode: 'summary' })
588
559
  * // This is the same as vm.measureMemory()
589
560
  * .then((result) => {
590
561
  * // The current format is:
591
562
  * // {
592
- * // total: {
593
- * // jsMemoryEstimate: 2418479, jsMemoryRange: [ 2418479, 2745799 ]
594
- * // }
563
+ * // total: { jsMemoryEstimate: 1601828, jsMemoryRange: [1601828, 5275288] },
564
+ * // WebAssembly: { code: 0, metadata: 33962 },
595
565
  * // }
596
566
  * console.log(result);
597
567
  * });
598
568
  *
599
- * const context = vm.createContext({ a: 1 });
600
- * vm.measureMemory({ mode: 'detailed', execution: 'eager' })
601
- * .then((result) => {
602
- * // Reference the context here so that it won't be GC'ed
603
- * // until the measurement is complete.
604
- * console.log(context.a);
605
- * // {
606
- * // total: {
607
- * // jsMemoryEstimate: 2574732,
608
- * // jsMemoryRange: [ 2574732, 2904372 ]
609
- * // },
610
- * // current: {
611
- * // jsMemoryEstimate: 2438996,
612
- * // jsMemoryRange: [ 2438996, 2768636 ]
613
- * // },
614
- * // other: [
615
- * // {
616
- * // jsMemoryEstimate: 135736,
617
- * // jsMemoryRange: [ 135736, 465376 ]
618
- * // }
619
- * // ]
620
- * // }
621
- * console.log(result);
622
- * });
569
+ * const context = createContext({ a: 1 });
570
+ * measureMemory({ mode: 'detailed', execution: 'eager' }).then((result) => {
571
+ * // Reference the context here so that it won't be GC'ed
572
+ * // until the measurement is complete.
573
+ * console.log('Context:', context.a);
574
+ * // {
575
+ * // total: { jsMemoryEstimate: 1767100, jsMemoryRange: [1767100, 5440560] },
576
+ * // WebAssembly: { code: 0, metadata: 33962 },
577
+ * // current: { jsMemoryEstimate: 1601828, jsMemoryRange: [1601828, 5275288] },
578
+ * // other: [{ jsMemoryEstimate: 165272, jsMemoryRange: [Array] }],
579
+ * // }
580
+ * console.log(result);
581
+ * });
623
582
  * ```
624
583
  * @since v13.10.0
625
584
  * @experimental
@@ -1092,15 +1051,21 @@ declare module "node:vm" {
1092
1051
  * module graphs.
1093
1052
  *
1094
1053
  * ```js
1095
- * import vm from 'node:vm';
1054
+ * import { SyntheticModule } from 'node:vm';
1096
1055
  *
1097
1056
  * const source = '{ "a": 1 }';
1098
- * const module = new vm.SyntheticModule(['default'], function() {
1057
+ * const syntheticModule = new SyntheticModule(['default'], function() {
1099
1058
  * const obj = JSON.parse(source);
1100
1059
  * this.setExport('default', obj);
1101
1060
  * });
1102
1061
  *
1103
- * // Use `module` in linking...
1062
+ * // Use `syntheticModule` in linking
1063
+ * (async () => {
1064
+ * await syntheticModule.link(() => {});
1065
+ * await syntheticModule.evaluate();
1066
+ *
1067
+ * console.log('Default export:', syntheticModule.namespace.default);
1068
+ * })();
1104
1069
  * ```
1105
1070
  * @since v13.0.0, v12.16.0
1106
1071
  * @experimental