@types/node 22.15.21 → 22.18.10

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 (76) hide show
  1. node v22.18/README.md +15 -0
  2. node/assert.d.ts → node v22.18/assert.d.ts +19 -0
  3. node/buffer.d.ts → node v22.18/buffer.d.ts +6 -2
  4. node/child_process.d.ts → node v22.18/child_process.d.ts +41 -131
  5. node/cluster.d.ts → node v22.18/cluster.d.ts +3 -4
  6. node/compatibility/disposable.d.ts → node v22.18/compatibility/disposable.d.ts +0 -2
  7. node/compatibility/indexable.d.ts → node v22.18/compatibility/indexable.d.ts +0 -3
  8. node/compatibility/iterators.d.ts → node v22.18/compatibility/iterators.d.ts +0 -1
  9. node/crypto.d.ts → node v22.18/crypto.d.ts +52 -36
  10. node/diagnostics_channel.d.ts → node v22.18/diagnostics_channel.d.ts +17 -12
  11. node/dns/promises.d.ts → node v22.18/dns/promises.d.ts +36 -9
  12. node/dns.d.ts → node v22.18/dns.d.ts +74 -21
  13. node/events.d.ts → node v22.18/events.d.ts +80 -35
  14. node/fs/promises.d.ts → node v22.18/fs/promises.d.ts +44 -39
  15. node/fs.d.ts → node v22.18/fs.d.ts +67 -56
  16. node v22.18/globals.d.ts +172 -0
  17. node/http.d.ts → node v22.18/http.d.ts +71 -10
  18. node/http2.d.ts → node v22.18/http2.d.ts +85 -5
  19. node/https.d.ts → node v22.18/https.d.ts +14 -12
  20. node/index.d.ts → node v22.18/index.d.ts +7 -3
  21. node/inspector.d.ts → node v22.18/inspector.generated.d.ts +219 -10
  22. node/module.d.ts → node v22.18/module.d.ts +136 -17
  23. node/net.d.ts → node v22.18/net.d.ts +5 -5
  24. node/os.d.ts → node v22.18/os.d.ts +13 -3
  25. node/package.json → node v22.18/package.json +3 -83
  26. node/perf_hooks.d.ts → node v22.18/perf_hooks.d.ts +8 -10
  27. node/process.d.ts → node v22.18/process.d.ts +10 -23
  28. node/readline/promises.d.ts → node v22.18/readline/promises.d.ts +1 -2
  29. node/repl.d.ts → node v22.18/repl.d.ts +3 -5
  30. node/sqlite.d.ts → node v22.18/sqlite.d.ts +207 -0
  31. node/stream/web.d.ts → node v22.18/stream/web.d.ts +8 -0
  32. node/stream.d.ts → node v22.18/stream.d.ts +34 -32
  33. node v22.18/test.d.ts +2162 -0
  34. node/tls.d.ts → node v22.18/tls.d.ts +2 -2
  35. node/ts5.6/index.d.ts → node v22.18/ts5.6/index.d.ts +7 -3
  36. node/url.d.ts → node v22.18/url.d.ts +12 -3
  37. node/util.d.ts → node v22.18/util.d.ts +20 -5
  38. node/v8.d.ts → node v22.18/v8.d.ts +62 -32
  39. node/vm.d.ts → node v22.18/vm.d.ts +62 -54
  40. node v22.18/web-globals/abortcontroller.d.ts +34 -0
  41. node v22.18/web-globals/domexception.d.ts +68 -0
  42. node v22.18/web-globals/events.d.ts +97 -0
  43. node v22.18/web-globals/fetch.d.ts +46 -0
  44. node v22.18/web-globals/navigator.d.ts +22 -0
  45. node v22.18/web-globals/storage.d.ts +24 -0
  46. node/worker_threads.d.ts → node v22.18/worker_threads.d.ts +105 -74
  47. node/zlib.d.ts → node v22.18/zlib.d.ts +8 -2
  48. node/README.md +0 -15
  49. node/dom-events.d.ts +0 -124
  50. node/globals.d.ts +0 -371
  51. node/test.d.ts +0 -2280
  52. {node → node v22.18}/LICENSE +0 -0
  53. {node → node v22.18}/assert/strict.d.ts +0 -0
  54. node/async_hooks.d.ts → node v22.18/async_hooks.d.ts +1 -1
  55. {node → node v22.18}/buffer.buffer.d.ts +0 -0
  56. {node → node v22.18}/compatibility/index.d.ts +0 -0
  57. {node → node v22.18}/console.d.ts +0 -0
  58. {node → node v22.18}/constants.d.ts +0 -0
  59. {node → node v22.18}/dgram.d.ts +0 -0
  60. {node → node v22.18}/domain.d.ts +0 -0
  61. {node → node v22.18}/globals.typedarray.d.ts +0 -0
  62. {node → node v22.18}/path.d.ts +0 -0
  63. {node → node v22.18}/punycode.d.ts +0 -0
  64. {node → node v22.18}/querystring.d.ts +0 -0
  65. {node → node v22.18}/readline.d.ts +0 -0
  66. {node → node v22.18}/sea.d.ts +0 -0
  67. {node → node v22.18}/stream/consumers.d.ts +0 -0
  68. {node → node v22.18}/stream/promises.d.ts +0 -0
  69. {node → node v22.18}/string_decoder.d.ts +0 -0
  70. {node → node v22.18}/timers/promises.d.ts +0 -0
  71. {node → node v22.18}/timers.d.ts +0 -0
  72. {node → node v22.18}/trace_events.d.ts +0 -0
  73. {node → node v22.18}/ts5.6/buffer.buffer.d.ts +0 -0
  74. {node → node v22.18}/ts5.6/globals.typedarray.d.ts +0 -0
  75. {node → node v22.18}/tty.d.ts +0 -0
  76. {node → node v22.18}/wasi.d.ts +0 -0
@@ -29,6 +29,7 @@ declare module "fs/promises" {
29
29
  OpenDirOptions,
30
30
  OpenMode,
31
31
  PathLike,
32
+ ReadPosition,
32
33
  ReadStream,
33
34
  ReadVResult,
34
35
  RmDirOptions,
@@ -39,7 +40,7 @@ declare module "fs/promises" {
39
40
  StatsFs,
40
41
  TimeLike,
41
42
  WatchEventType,
42
- WatchOptions,
43
+ WatchOptions as _WatchOptions,
43
44
  WriteStream,
44
45
  WriteVResult,
45
46
  } from "node:fs";
@@ -69,7 +70,7 @@ declare module "fs/promises" {
69
70
  * @default `buffer.byteLength`
70
71
  */
71
72
  length?: number | null;
72
- position?: number | null;
73
+ position?: ReadPosition | null;
73
74
  }
74
75
  interface CreateReadStreamOptions extends Abortable {
75
76
  encoding?: BufferEncoding | null | undefined;
@@ -87,6 +88,9 @@ declare module "fs/promises" {
87
88
  highWaterMark?: number | undefined;
88
89
  flush?: boolean | undefined;
89
90
  }
91
+ interface ReadableWebStreamOptions {
92
+ autoClose?: boolean | undefined;
93
+ }
90
94
  // TODO: Add `EventEmitter` close
91
95
  interface FileHandle {
92
96
  /**
@@ -229,7 +233,7 @@ declare module "fs/promises" {
229
233
  buffer: T,
230
234
  offset?: number | null,
231
235
  length?: number | null,
232
- position?: number | null,
236
+ position?: ReadPosition | null,
233
237
  ): Promise<FileReadResult<T>>;
234
238
  read<T extends NodeJS.ArrayBufferView = Buffer>(
235
239
  buffer: T,
@@ -259,9 +263,8 @@ declare module "fs/promises" {
259
263
  * While the `ReadableStream` will read the file to completion, it will not
260
264
  * close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method.
261
265
  * @since v17.0.0
262
- * @experimental
263
266
  */
264
- readableWebStream(): ReadableStream;
267
+ readableWebStream(options?: ReadableWebStreamOptions): ReadableStream;
265
268
  /**
266
269
  * Asynchronously reads the entire contents of a file.
267
270
  *
@@ -474,7 +477,8 @@ declare module "fs/promises" {
474
477
  */
475
478
  close(): Promise<void>;
476
479
  /**
477
- * An alias for {@link FileHandle.close()}.
480
+ * Calls `filehandle.close()` and returns a promise that fulfills when the
481
+ * filehandle is closed.
478
482
  * @since v20.4.0
479
483
  */
480
484
  [Symbol.asyncDispose](): Promise<void>;
@@ -1178,6 +1182,16 @@ declare module "fs/promises" {
1178
1182
  * @return Fulfills with an {fs.Dir}.
1179
1183
  */
1180
1184
  function opendir(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
1185
+ interface WatchOptions extends _WatchOptions {
1186
+ maxQueue?: number | undefined;
1187
+ overflow?: "ignore" | "throw" | undefined;
1188
+ }
1189
+ interface WatchOptionsWithBufferEncoding extends WatchOptions {
1190
+ encoding: "buffer";
1191
+ }
1192
+ interface WatchOptionsWithStringEncoding extends WatchOptions {
1193
+ encoding?: BufferEncoding | undefined;
1194
+ }
1181
1195
  /**
1182
1196
  * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
1183
1197
  *
@@ -1210,33 +1224,16 @@ declare module "fs/promises" {
1210
1224
  */
1211
1225
  function watch(
1212
1226
  filename: PathLike,
1213
- options:
1214
- | (WatchOptions & {
1215
- encoding: "buffer";
1216
- })
1217
- | "buffer",
1218
- ): AsyncIterable<FileChangeInfo<Buffer>>;
1219
- /**
1220
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1221
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1222
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1223
- * If `encoding` is not supplied, the default of `'utf8'` is used.
1224
- * If `persistent` is not supplied, the default of `true` is used.
1225
- * If `recursive` is not supplied, the default of `false` is used.
1226
- */
1227
- function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable<FileChangeInfo<string>>;
1228
- /**
1229
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1230
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1231
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1232
- * If `encoding` is not supplied, the default of `'utf8'` is used.
1233
- * If `persistent` is not supplied, the default of `true` is used.
1234
- * If `recursive` is not supplied, the default of `false` is used.
1235
- */
1227
+ options?: WatchOptionsWithStringEncoding | BufferEncoding,
1228
+ ): NodeJS.AsyncIterator<FileChangeInfo<string>>;
1236
1229
  function watch(
1237
1230
  filename: PathLike,
1238
- options: WatchOptions | string,
1239
- ): AsyncIterable<FileChangeInfo<string>> | AsyncIterable<FileChangeInfo<Buffer>>;
1231
+ options: WatchOptionsWithBufferEncoding | "buffer",
1232
+ ): NodeJS.AsyncIterator<FileChangeInfo<Buffer>>;
1233
+ function watch(
1234
+ filename: PathLike,
1235
+ options: WatchOptions | BufferEncoding | "buffer",
1236
+ ): NodeJS.AsyncIterator<FileChangeInfo<string | Buffer>>;
1240
1237
  /**
1241
1238
  * Asynchronously copies the entire directory structure from `src` to `dest`,
1242
1239
  * including subdirectories and files.
@@ -1251,20 +1248,28 @@ declare module "fs/promises" {
1251
1248
  */
1252
1249
  function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
1253
1250
  /**
1254
- * Retrieves the files matching the specified pattern.
1251
+ * ```js
1252
+ * import { glob } from 'node:fs/promises';
1253
+ *
1254
+ * for await (const entry of glob('*.js'))
1255
+ * console.log(entry);
1256
+ * ```
1257
+ * @since v22.0.0
1258
+ * @returns An AsyncIterator that yields the paths of files
1259
+ * that match the pattern.
1255
1260
  */
1256
- function glob(pattern: string | string[]): NodeJS.AsyncIterator<string>;
1261
+ function glob(pattern: string | readonly string[]): NodeJS.AsyncIterator<string>;
1257
1262
  function glob(
1258
- pattern: string | string[],
1259
- opt: GlobOptionsWithFileTypes,
1263
+ pattern: string | readonly string[],
1264
+ options: GlobOptionsWithFileTypes,
1260
1265
  ): NodeJS.AsyncIterator<Dirent>;
1261
1266
  function glob(
1262
- pattern: string | string[],
1263
- opt: GlobOptionsWithoutFileTypes,
1267
+ pattern: string | readonly string[],
1268
+ options: GlobOptionsWithoutFileTypes,
1264
1269
  ): NodeJS.AsyncIterator<string>;
1265
1270
  function glob(
1266
- pattern: string | string[],
1267
- opt: GlobOptions,
1271
+ pattern: string | readonly string[],
1272
+ options: GlobOptions,
1268
1273
  ): NodeJS.AsyncIterator<Dirent | string>;
1269
1274
  }
1270
1275
  declare module "node:fs/promises" {
@@ -243,8 +243,8 @@ declare module "fs" {
243
243
  */
244
244
  name: Name;
245
245
  /**
246
- * The base path that this `fs.Dirent` object refers to.
247
- * @since v20.12.0
246
+ * The path to the parent directory of the file this `fs.Dirent` object refers to.
247
+ * @since v20.12.0, v18.20.0
248
248
  */
249
249
  parentPath: string;
250
250
  /**
@@ -328,6 +328,20 @@ declare module "fs" {
328
328
  * @since v12.12.0
329
329
  */
330
330
  readSync(): Dirent | null;
331
+ /**
332
+ * Calls `dir.close()` if the directory handle is open, and returns a promise that
333
+ * fulfills when disposal is complete.
334
+ * @since v22.17.0
335
+ * @experimental
336
+ */
337
+ [Symbol.asyncDispose](): Promise<void>;
338
+ /**
339
+ * Calls `dir.closeSync()` if the directory handle is open, and returns
340
+ * `undefined`.
341
+ * @since v22.17.0
342
+ * @experimental
343
+ */
344
+ [Symbol.dispose](): void;
331
345
  }
332
346
  /**
333
347
  * Class: fs.StatWatcher
@@ -2371,7 +2385,7 @@ declare module "fs" {
2371
2385
  /**
2372
2386
  * @default null
2373
2387
  */
2374
- position?: number | undefined | null;
2388
+ position?: number | null | undefined;
2375
2389
  }
2376
2390
  /**
2377
2391
  * Write `buffer` to the file specified by `fd`.
@@ -2656,7 +2670,7 @@ declare module "fs" {
2656
2670
  buffer: TBuffer,
2657
2671
  offset: number,
2658
2672
  length: number,
2659
- position: number | null,
2673
+ position: ReadPosition | null,
2660
2674
  ): Promise<{
2661
2675
  bytesRead: number;
2662
2676
  buffer: TBuffer;
@@ -3327,6 +3341,12 @@ declare module "fs" {
3327
3341
  persistent?: boolean | undefined;
3328
3342
  recursive?: boolean | undefined;
3329
3343
  }
3344
+ export interface WatchOptionsWithBufferEncoding extends WatchOptions {
3345
+ encoding: "buffer";
3346
+ }
3347
+ export interface WatchOptionsWithStringEncoding extends WatchOptions {
3348
+ encoding?: BufferEncoding | undefined;
3349
+ }
3330
3350
  export type WatchEventType = "rename" | "change";
3331
3351
  export type WatchListener<T> = (event: WatchEventType, filename: T | null) => void;
3332
3352
  export type StatsListener = (curr: Stats, prev: Stats) => void;
@@ -3353,44 +3373,20 @@ declare module "fs" {
3353
3373
  */
3354
3374
  export function watch(
3355
3375
  filename: PathLike,
3356
- options:
3357
- | (WatchOptions & {
3358
- encoding: "buffer";
3359
- })
3360
- | "buffer",
3361
- listener?: WatchListener<Buffer>,
3376
+ options?: WatchOptionsWithStringEncoding | BufferEncoding | null,
3377
+ listener?: WatchListener<string>,
3362
3378
  ): FSWatcher;
3363
- /**
3364
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3365
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3366
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
3367
- * If `encoding` is not supplied, the default of `'utf8'` is used.
3368
- * If `persistent` is not supplied, the default of `true` is used.
3369
- * If `recursive` is not supplied, the default of `false` is used.
3370
- */
3371
3379
  export function watch(
3372
3380
  filename: PathLike,
3373
- options?: WatchOptions | BufferEncoding | null,
3374
- listener?: WatchListener<string>,
3381
+ options: WatchOptionsWithBufferEncoding | "buffer",
3382
+ listener: WatchListener<Buffer>,
3375
3383
  ): FSWatcher;
3376
- /**
3377
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3378
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3379
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
3380
- * If `encoding` is not supplied, the default of `'utf8'` is used.
3381
- * If `persistent` is not supplied, the default of `true` is used.
3382
- * If `recursive` is not supplied, the default of `false` is used.
3383
- */
3384
3384
  export function watch(
3385
3385
  filename: PathLike,
3386
- options: WatchOptions | string,
3387
- listener?: WatchListener<string | Buffer>,
3386
+ options: WatchOptions | BufferEncoding | "buffer" | null,
3387
+ listener: WatchListener<string | Buffer>,
3388
3388
  ): FSWatcher;
3389
- /**
3390
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
3391
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
3392
- */
3393
- export function watch(filename: PathLike, listener?: WatchListener<string>): FSWatcher;
3389
+ export function watch(filename: PathLike, listener: WatchListener<string>): FSWatcher;
3394
3390
  /**
3395
3391
  * Test whether or not the given path exists by checking with the file system.
3396
3392
  * Then call the `callback` argument with either true or false:
@@ -4200,7 +4196,6 @@ declare module "fs" {
4200
4196
  * blob.stream();
4201
4197
  * ```
4202
4198
  * @since v19.8.0
4203
- * @experimental
4204
4199
  */
4205
4200
  export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise<Blob>;
4206
4201
 
@@ -4219,7 +4214,7 @@ declare module "fs" {
4219
4214
  /**
4220
4215
  * @default false
4221
4216
  */
4222
- recursive?: boolean;
4217
+ recursive?: boolean | undefined;
4223
4218
  }
4224
4219
  /**
4225
4220
  * Synchronously open a directory. See [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html).
@@ -4272,54 +4267,54 @@ declare module "fs" {
4272
4267
  * Dereference symlinks
4273
4268
  * @default false
4274
4269
  */
4275
- dereference?: boolean;
4270
+ dereference?: boolean | undefined;
4276
4271
  /**
4277
4272
  * When `force` is `false`, and the destination
4278
4273
  * exists, throw an error.
4279
4274
  * @default false
4280
4275
  */
4281
- errorOnExist?: boolean;
4276
+ errorOnExist?: boolean | undefined;
4282
4277
  /**
4283
4278
  * Overwrite existing file or directory. _The copy
4284
4279
  * operation will ignore errors if you set this to false and the destination
4285
4280
  * exists. Use the `errorOnExist` option to change this behavior.
4286
4281
  * @default true
4287
4282
  */
4288
- force?: boolean;
4283
+ force?: boolean | undefined;
4289
4284
  /**
4290
4285
  * Modifiers for copy operation. See `mode` flag of {@link copyFileSync()}
4291
4286
  */
4292
- mode?: number;
4287
+ mode?: number | undefined;
4293
4288
  /**
4294
4289
  * When `true` timestamps from `src` will
4295
4290
  * be preserved.
4296
4291
  * @default false
4297
4292
  */
4298
- preserveTimestamps?: boolean;
4293
+ preserveTimestamps?: boolean | undefined;
4299
4294
  /**
4300
4295
  * Copy directories recursively.
4301
4296
  * @default false
4302
4297
  */
4303
- recursive?: boolean;
4298
+ recursive?: boolean | undefined;
4304
4299
  /**
4305
4300
  * When true, path resolution for symlinks will be skipped
4306
4301
  * @default false
4307
4302
  */
4308
- verbatimSymlinks?: boolean;
4303
+ verbatimSymlinks?: boolean | undefined;
4309
4304
  }
4310
4305
  export interface CopyOptions extends CopyOptionsBase {
4311
4306
  /**
4312
4307
  * Function to filter copied files/directories. Return
4313
4308
  * `true` to copy the item, `false` to ignore it.
4314
4309
  */
4315
- filter?(source: string, destination: string): boolean | Promise<boolean>;
4310
+ filter?: ((source: string, destination: string) => boolean | Promise<boolean>) | undefined;
4316
4311
  }
4317
4312
  export interface CopySyncOptions extends CopyOptionsBase {
4318
4313
  /**
4319
4314
  * Function to filter copied files/directories. Return
4320
4315
  * `true` to copy the item, `false` to ignore it.
4321
4316
  */
4322
- filter?(source: string, destination: string): boolean;
4317
+ filter?: ((source: string, destination: string) => boolean) | undefined;
4323
4318
  }
4324
4319
  /**
4325
4320
  * Asynchronously copies the entire directory structure from `src` to `dest`,
@@ -4361,7 +4356,7 @@ declare module "fs" {
4361
4356
  * Current working directory.
4362
4357
  * @default process.cwd()
4363
4358
  */
4364
- cwd?: string | undefined;
4359
+ cwd?: string | URL | undefined;
4365
4360
  /**
4366
4361
  * `true` if the glob should return paths as `Dirent`s, `false` otherwise.
4367
4362
  * @default false
@@ -4386,13 +4381,23 @@ declare module "fs" {
4386
4381
 
4387
4382
  /**
4388
4383
  * Retrieves the files matching the specified pattern.
4384
+ *
4385
+ * ```js
4386
+ * import { glob } from 'node:fs';
4387
+ *
4388
+ * glob('*.js', (err, matches) => {
4389
+ * if (err) throw err;
4390
+ * console.log(matches);
4391
+ * });
4392
+ * ```
4393
+ * @since v22.0.0
4389
4394
  */
4390
4395
  export function glob(
4391
- pattern: string | string[],
4396
+ pattern: string | readonly string[],
4392
4397
  callback: (err: NodeJS.ErrnoException | null, matches: string[]) => void,
4393
4398
  ): void;
4394
4399
  export function glob(
4395
- pattern: string | string[],
4400
+ pattern: string | readonly string[],
4396
4401
  options: GlobOptionsWithFileTypes,
4397
4402
  callback: (
4398
4403
  err: NodeJS.ErrnoException | null,
@@ -4400,7 +4405,7 @@ declare module "fs" {
4400
4405
  ) => void,
4401
4406
  ): void;
4402
4407
  export function glob(
4403
- pattern: string | string[],
4408
+ pattern: string | readonly string[],
4404
4409
  options: GlobOptionsWithoutFileTypes,
4405
4410
  callback: (
4406
4411
  err: NodeJS.ErrnoException | null,
@@ -4408,7 +4413,7 @@ declare module "fs" {
4408
4413
  ) => void,
4409
4414
  ): void;
4410
4415
  export function glob(
4411
- pattern: string | string[],
4416
+ pattern: string | readonly string[],
4412
4417
  options: GlobOptions,
4413
4418
  callback: (
4414
4419
  err: NodeJS.ErrnoException | null,
@@ -4416,19 +4421,25 @@ declare module "fs" {
4416
4421
  ) => void,
4417
4422
  ): void;
4418
4423
  /**
4419
- * Retrieves the files matching the specified pattern.
4424
+ * ```js
4425
+ * import { globSync } from 'node:fs';
4426
+ *
4427
+ * console.log(globSync('*.js'));
4428
+ * ```
4429
+ * @since v22.0.0
4430
+ * @returns paths of files that match the pattern.
4420
4431
  */
4421
- export function globSync(pattern: string | string[]): string[];
4432
+ export function globSync(pattern: string | readonly string[]): string[];
4422
4433
  export function globSync(
4423
- pattern: string | string[],
4434
+ pattern: string | readonly string[],
4424
4435
  options: GlobOptionsWithFileTypes,
4425
4436
  ): Dirent[];
4426
4437
  export function globSync(
4427
- pattern: string | string[],
4438
+ pattern: string | readonly string[],
4428
4439
  options: GlobOptionsWithoutFileTypes,
4429
4440
  ): string[];
4430
4441
  export function globSync(
4431
- pattern: string | string[],
4442
+ pattern: string | readonly string[],
4432
4443
  options: GlobOptions,
4433
4444
  ): Dirent[] | string[];
4434
4445
  }
@@ -0,0 +1,172 @@
1
+ declare var global: typeof globalThis;
2
+
3
+ declare var process: NodeJS.Process;
4
+ declare var console: Console;
5
+
6
+ interface ErrorConstructor {
7
+ /**
8
+ * Creates a `.stack` property on `targetObject`, which when accessed returns
9
+ * a string representing the location in the code at which
10
+ * `Error.captureStackTrace()` was called.
11
+ *
12
+ * ```js
13
+ * const myObject = {};
14
+ * Error.captureStackTrace(myObject);
15
+ * myObject.stack; // Similar to `new Error().stack`
16
+ * ```
17
+ *
18
+ * The first line of the trace will be prefixed with
19
+ * `${myObject.name}: ${myObject.message}`.
20
+ *
21
+ * The optional `constructorOpt` argument accepts a function. If given, all frames
22
+ * above `constructorOpt`, including `constructorOpt`, will be omitted from the
23
+ * generated stack trace.
24
+ *
25
+ * The `constructorOpt` argument is useful for hiding implementation
26
+ * details of error generation from the user. For instance:
27
+ *
28
+ * ```js
29
+ * function a() {
30
+ * b();
31
+ * }
32
+ *
33
+ * function b() {
34
+ * c();
35
+ * }
36
+ *
37
+ * function c() {
38
+ * // Create an error without stack trace to avoid calculating the stack trace twice.
39
+ * const { stackTraceLimit } = Error;
40
+ * Error.stackTraceLimit = 0;
41
+ * const error = new Error();
42
+ * Error.stackTraceLimit = stackTraceLimit;
43
+ *
44
+ * // Capture the stack trace above function b
45
+ * Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
46
+ * throw error;
47
+ * }
48
+ *
49
+ * a();
50
+ * ```
51
+ */
52
+ captureStackTrace(targetObject: object, constructorOpt?: Function): void;
53
+ /**
54
+ * @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
55
+ */
56
+ prepareStackTrace(err: Error, stackTraces: NodeJS.CallSite[]): any;
57
+ /**
58
+ * The `Error.stackTraceLimit` property specifies the number of stack frames
59
+ * collected by a stack trace (whether generated by `new Error().stack` or
60
+ * `Error.captureStackTrace(obj)`).
61
+ *
62
+ * The default value is `10` but may be set to any valid JavaScript number. Changes
63
+ * will affect any stack trace captured _after_ the value has been changed.
64
+ *
65
+ * If set to a non-number value, or set to a negative number, stack traces will
66
+ * not capture any frames.
67
+ */
68
+ stackTraceLimit: number;
69
+ }
70
+
71
+ /**
72
+ * Enable this API with the `--expose-gc` CLI flag.
73
+ */
74
+ declare var gc: NodeJS.GCFunction | undefined;
75
+
76
+ declare namespace NodeJS {
77
+ interface CallSite {
78
+ getColumnNumber(): number | null;
79
+ getEnclosingColumnNumber(): number | null;
80
+ getEnclosingLineNumber(): number | null;
81
+ getEvalOrigin(): string | undefined;
82
+ getFileName(): string | null;
83
+ getFunction(): Function | undefined;
84
+ getFunctionName(): string | null;
85
+ getLineNumber(): number | null;
86
+ getMethodName(): string | null;
87
+ getPosition(): number;
88
+ getPromiseIndex(): number | null;
89
+ getScriptHash(): string;
90
+ getScriptNameOrSourceURL(): string | null;
91
+ getThis(): unknown;
92
+ getTypeName(): string | null;
93
+ isAsync(): boolean;
94
+ isConstructor(): boolean;
95
+ isEval(): boolean;
96
+ isNative(): boolean;
97
+ isPromiseAll(): boolean;
98
+ isToplevel(): boolean;
99
+ }
100
+
101
+ interface ErrnoException extends Error {
102
+ errno?: number | undefined;
103
+ code?: string | undefined;
104
+ path?: string | undefined;
105
+ syscall?: string | undefined;
106
+ }
107
+
108
+ interface ReadableStream extends EventEmitter {
109
+ readable: boolean;
110
+ read(size?: number): string | Buffer;
111
+ setEncoding(encoding: BufferEncoding): this;
112
+ pause(): this;
113
+ resume(): this;
114
+ isPaused(): boolean;
115
+ pipe<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined }): T;
116
+ unpipe(destination?: WritableStream): this;
117
+ unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
118
+ wrap(oldStream: ReadableStream): this;
119
+ [Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
120
+ }
121
+
122
+ interface WritableStream extends EventEmitter {
123
+ writable: boolean;
124
+ write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
125
+ write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
126
+ end(cb?: () => void): this;
127
+ end(data: string | Uint8Array, cb?: () => void): this;
128
+ end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
129
+ }
130
+
131
+ interface ReadWriteStream extends ReadableStream, WritableStream {}
132
+
133
+ interface RefCounted {
134
+ ref(): this;
135
+ unref(): this;
136
+ }
137
+
138
+ interface Dict<T> {
139
+ [key: string]: T | undefined;
140
+ }
141
+
142
+ interface ReadOnlyDict<T> {
143
+ readonly [key: string]: T | undefined;
144
+ }
145
+
146
+ type PartialOptions<T> = { [K in keyof T]?: T[K] | undefined };
147
+
148
+ interface GCFunction {
149
+ (minor?: boolean): void;
150
+ (options: NodeJS.GCOptions & { execution: "async" }): Promise<void>;
151
+ (options: NodeJS.GCOptions): void;
152
+ }
153
+
154
+ interface GCOptions {
155
+ execution?: "sync" | "async" | undefined;
156
+ flavor?: "regular" | "last-resort" | undefined;
157
+ type?: "major-snapshot" | "major" | "minor" | undefined;
158
+ filename?: string | undefined;
159
+ }
160
+
161
+ /** An iterable iterator returned by the Node.js API. */
162
+ // Default TReturn/TNext in v22 is `any`, for compatibility with the previously-used IterableIterator.
163
+ interface Iterator<T, TReturn = any, TNext = any> extends IteratorObject<T, TReturn, TNext> {
164
+ [Symbol.iterator](): NodeJS.Iterator<T, TReturn, TNext>;
165
+ }
166
+
167
+ /** An async iterable iterator returned by the Node.js API. */
168
+ // Default TReturn/TNext in v22 is `any`, for compatibility with the previously-used AsyncIterableIterator.
169
+ interface AsyncIterator<T, TReturn = any, TNext = any> extends AsyncIteratorObject<T, TReturn, TNext> {
170
+ [Symbol.asyncIterator](): NodeJS.AsyncIterator<T, TReturn, TNext>;
171
+ }
172
+ }