@types/node 24.9.0 → 24.9.2

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/fs.d.ts CHANGED
@@ -19,6 +19,7 @@
19
19
  * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/fs.js)
20
20
  */
21
21
  declare module "fs" {
22
+ import { NonSharedBuffer } from "node:buffer";
22
23
  import * as stream from "node:stream";
23
24
  import { Abortable, EventEmitter } from "node:events";
24
25
  import { URL } from "node:url";
@@ -394,23 +395,29 @@ declare module "fs" {
394
395
  * 3. error
395
396
  */
396
397
  addListener(event: string, listener: (...args: any[]) => void): this;
397
- addListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
398
+ addListener(event: "change", listener: (eventType: string, filename: string | NonSharedBuffer) => void): this;
398
399
  addListener(event: "close", listener: () => void): this;
399
400
  addListener(event: "error", listener: (error: Error) => void): this;
400
401
  on(event: string, listener: (...args: any[]) => void): this;
401
- on(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
402
+ on(event: "change", listener: (eventType: string, filename: string | NonSharedBuffer) => void): this;
402
403
  on(event: "close", listener: () => void): this;
403
404
  on(event: "error", listener: (error: Error) => void): this;
404
405
  once(event: string, listener: (...args: any[]) => void): this;
405
- once(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
406
+ once(event: "change", listener: (eventType: string, filename: string | NonSharedBuffer) => void): this;
406
407
  once(event: "close", listener: () => void): this;
407
408
  once(event: "error", listener: (error: Error) => void): this;
408
409
  prependListener(event: string, listener: (...args: any[]) => void): this;
409
- prependListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
410
+ prependListener(
411
+ event: "change",
412
+ listener: (eventType: string, filename: string | NonSharedBuffer) => void,
413
+ ): this;
410
414
  prependListener(event: "close", listener: () => void): this;
411
415
  prependListener(event: "error", listener: (error: Error) => void): this;
412
416
  prependOnceListener(event: string, listener: (...args: any[]) => void): this;
413
- prependOnceListener(event: "change", listener: (eventType: string, filename: string | Buffer) => void): this;
417
+ prependOnceListener(
418
+ event: "change",
419
+ listener: (eventType: string, filename: string | NonSharedBuffer) => void,
420
+ ): this;
414
421
  prependOnceListener(event: "close", listener: () => void): this;
415
422
  prependOnceListener(event: "error", listener: (error: Error) => void): this;
416
423
  }
@@ -1550,7 +1557,7 @@ declare module "fs" {
1550
1557
  export function readlink(
1551
1558
  path: PathLike,
1552
1559
  options: BufferEncodingOption,
1553
- callback: (err: NodeJS.ErrnoException | null, linkString: Buffer) => void,
1560
+ callback: (err: NodeJS.ErrnoException | null, linkString: NonSharedBuffer) => void,
1554
1561
  ): void;
1555
1562
  /**
1556
1563
  * Asynchronous readlink(2) - read value of a symbolic link.
@@ -1560,7 +1567,7 @@ declare module "fs" {
1560
1567
  export function readlink(
1561
1568
  path: PathLike,
1562
1569
  options: EncodingOption,
1563
- callback: (err: NodeJS.ErrnoException | null, linkString: string | Buffer) => void,
1570
+ callback: (err: NodeJS.ErrnoException | null, linkString: string | NonSharedBuffer) => void,
1564
1571
  ): void;
1565
1572
  /**
1566
1573
  * Asynchronous readlink(2) - read value of a symbolic link.
@@ -1582,13 +1589,13 @@ declare module "fs" {
1582
1589
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1583
1590
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1584
1591
  */
1585
- function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
1592
+ function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
1586
1593
  /**
1587
1594
  * Asynchronous readlink(2) - read value of a symbolic link.
1588
1595
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1589
1596
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1590
1597
  */
1591
- function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
1598
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | NonSharedBuffer>;
1592
1599
  }
1593
1600
  /**
1594
1601
  * Returns the symbolic link's string value.
@@ -1607,13 +1614,13 @@ declare module "fs" {
1607
1614
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1608
1615
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1609
1616
  */
1610
- export function readlinkSync(path: PathLike, options: BufferEncodingOption): Buffer;
1617
+ export function readlinkSync(path: PathLike, options: BufferEncodingOption): NonSharedBuffer;
1611
1618
  /**
1612
1619
  * Synchronous readlink(2) - read value of a symbolic link.
1613
1620
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1614
1621
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1615
1622
  */
1616
- export function readlinkSync(path: PathLike, options?: EncodingOption): string | Buffer;
1623
+ export function readlinkSync(path: PathLike, options?: EncodingOption): string | NonSharedBuffer;
1617
1624
  /**
1618
1625
  * Asynchronously computes the canonical pathname by resolving `.`, `..`, and
1619
1626
  * symbolic links.
@@ -1653,7 +1660,7 @@ declare module "fs" {
1653
1660
  export function realpath(
1654
1661
  path: PathLike,
1655
1662
  options: BufferEncodingOption,
1656
- callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void,
1663
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: NonSharedBuffer) => void,
1657
1664
  ): void;
1658
1665
  /**
1659
1666
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
@@ -1663,7 +1670,7 @@ declare module "fs" {
1663
1670
  export function realpath(
1664
1671
  path: PathLike,
1665
1672
  options: EncodingOption,
1666
- callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void,
1673
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | NonSharedBuffer) => void,
1667
1674
  ): void;
1668
1675
  /**
1669
1676
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
@@ -1685,13 +1692,13 @@ declare module "fs" {
1685
1692
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1686
1693
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1687
1694
  */
1688
- function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
1695
+ function __promisify__(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
1689
1696
  /**
1690
1697
  * Asynchronous realpath(3) - return the canonicalized absolute pathname.
1691
1698
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1692
1699
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1693
1700
  */
1694
- function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | Buffer>;
1701
+ function __promisify__(path: PathLike, options?: EncodingOption): Promise<string | NonSharedBuffer>;
1695
1702
  /**
1696
1703
  * Asynchronous [`realpath(3)`](http://man7.org/linux/man-pages/man3/realpath.3.html).
1697
1704
  *
@@ -1717,12 +1724,12 @@ declare module "fs" {
1717
1724
  function native(
1718
1725
  path: PathLike,
1719
1726
  options: BufferEncodingOption,
1720
- callback: (err: NodeJS.ErrnoException | null, resolvedPath: Buffer) => void,
1727
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: NonSharedBuffer) => void,
1721
1728
  ): void;
1722
1729
  function native(
1723
1730
  path: PathLike,
1724
1731
  options: EncodingOption,
1725
- callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | Buffer) => void,
1732
+ callback: (err: NodeJS.ErrnoException | null, resolvedPath: string | NonSharedBuffer) => void,
1726
1733
  ): void;
1727
1734
  function native(
1728
1735
  path: PathLike,
@@ -1742,17 +1749,17 @@ declare module "fs" {
1742
1749
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1743
1750
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1744
1751
  */
1745
- export function realpathSync(path: PathLike, options: BufferEncodingOption): Buffer;
1752
+ export function realpathSync(path: PathLike, options: BufferEncodingOption): NonSharedBuffer;
1746
1753
  /**
1747
1754
  * Synchronous realpath(3) - return the canonicalized absolute pathname.
1748
1755
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1749
1756
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
1750
1757
  */
1751
- export function realpathSync(path: PathLike, options?: EncodingOption): string | Buffer;
1758
+ export function realpathSync(path: PathLike, options?: EncodingOption): string | NonSharedBuffer;
1752
1759
  export namespace realpathSync {
1753
1760
  function native(path: PathLike, options?: EncodingOption): string;
1754
- function native(path: PathLike, options: BufferEncodingOption): Buffer;
1755
- function native(path: PathLike, options?: EncodingOption): string | Buffer;
1761
+ function native(path: PathLike, options: BufferEncodingOption): NonSharedBuffer;
1762
+ function native(path: PathLike, options?: EncodingOption): string | NonSharedBuffer;
1756
1763
  }
1757
1764
  /**
1758
1765
  * Asynchronously removes a file or symbolic link. No arguments other than a
@@ -2122,12 +2129,8 @@ declare module "fs" {
2122
2129
  */
2123
2130
  export function mkdtemp(
2124
2131
  prefix: string,
2125
- options:
2126
- | "buffer"
2127
- | {
2128
- encoding: "buffer";
2129
- },
2130
- callback: (err: NodeJS.ErrnoException | null, folder: Buffer) => void,
2132
+ options: BufferEncodingOption,
2133
+ callback: (err: NodeJS.ErrnoException | null, folder: NonSharedBuffer) => void,
2131
2134
  ): void;
2132
2135
  /**
2133
2136
  * Asynchronously creates a unique temporary directory.
@@ -2137,7 +2140,7 @@ declare module "fs" {
2137
2140
  export function mkdtemp(
2138
2141
  prefix: string,
2139
2142
  options: EncodingOption,
2140
- callback: (err: NodeJS.ErrnoException | null, folder: string | Buffer) => void,
2143
+ callback: (err: NodeJS.ErrnoException | null, folder: string | NonSharedBuffer) => void,
2141
2144
  ): void;
2142
2145
  /**
2143
2146
  * Asynchronously creates a unique temporary directory.
@@ -2159,13 +2162,13 @@ declare module "fs" {
2159
2162
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2160
2163
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2161
2164
  */
2162
- function __promisify__(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
2165
+ function __promisify__(prefix: string, options: BufferEncodingOption): Promise<NonSharedBuffer>;
2163
2166
  /**
2164
2167
  * Asynchronously creates a unique temporary directory.
2165
2168
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2166
2169
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2167
2170
  */
2168
- function __promisify__(prefix: string, options?: EncodingOption): Promise<string | Buffer>;
2171
+ function __promisify__(prefix: string, options?: EncodingOption): Promise<string | NonSharedBuffer>;
2169
2172
  }
2170
2173
  /**
2171
2174
  * Returns the created directory path.
@@ -2183,13 +2186,13 @@ declare module "fs" {
2183
2186
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2184
2187
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2185
2188
  */
2186
- export function mkdtempSync(prefix: string, options: BufferEncodingOption): Buffer;
2189
+ export function mkdtempSync(prefix: string, options: BufferEncodingOption): NonSharedBuffer;
2187
2190
  /**
2188
2191
  * Synchronously creates a unique temporary directory.
2189
2192
  * Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
2190
2193
  * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
2191
2194
  */
2192
- export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer;
2195
+ export function mkdtempSync(prefix: string, options?: EncodingOption): string | NonSharedBuffer;
2193
2196
  export interface DisposableTempDir extends AsyncDisposable {
2194
2197
  /**
2195
2198
  * The path of the created directory.
@@ -2263,7 +2266,7 @@ declare module "fs" {
2263
2266
  recursive?: boolean | undefined;
2264
2267
  }
2265
2268
  | "buffer",
2266
- callback: (err: NodeJS.ErrnoException | null, files: Buffer[]) => void,
2269
+ callback: (err: NodeJS.ErrnoException | null, files: NonSharedBuffer[]) => void,
2267
2270
  ): void;
2268
2271
  /**
2269
2272
  * Asynchronous readdir(3) - read a directory.
@@ -2280,7 +2283,7 @@ declare module "fs" {
2280
2283
  | BufferEncoding
2281
2284
  | undefined
2282
2285
  | null,
2283
- callback: (err: NodeJS.ErrnoException | null, files: string[] | Buffer[]) => void,
2286
+ callback: (err: NodeJS.ErrnoException | null, files: string[] | NonSharedBuffer[]) => void,
2284
2287
  ): void;
2285
2288
  /**
2286
2289
  * Asynchronous readdir(3) - read a directory.
@@ -2315,7 +2318,7 @@ declare module "fs" {
2315
2318
  withFileTypes: true;
2316
2319
  recursive?: boolean | undefined;
2317
2320
  },
2318
- callback: (err: NodeJS.ErrnoException | null, files: Dirent<Buffer>[]) => void,
2321
+ callback: (err: NodeJS.ErrnoException | null, files: Dirent<NonSharedBuffer>[]) => void,
2319
2322
  ): void;
2320
2323
  export namespace readdir {
2321
2324
  /**
@@ -2348,7 +2351,7 @@ declare module "fs" {
2348
2351
  withFileTypes?: false | undefined;
2349
2352
  recursive?: boolean | undefined;
2350
2353
  },
2351
- ): Promise<Buffer[]>;
2354
+ ): Promise<NonSharedBuffer[]>;
2352
2355
  /**
2353
2356
  * Asynchronous readdir(3) - read a directory.
2354
2357
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -2363,7 +2366,7 @@ declare module "fs" {
2363
2366
  })
2364
2367
  | BufferEncoding
2365
2368
  | null,
2366
- ): Promise<string[] | Buffer[]>;
2369
+ ): Promise<string[] | NonSharedBuffer[]>;
2367
2370
  /**
2368
2371
  * Asynchronous readdir(3) - read a directory.
2369
2372
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -2388,7 +2391,7 @@ declare module "fs" {
2388
2391
  withFileTypes: true;
2389
2392
  recursive?: boolean | undefined;
2390
2393
  },
2391
- ): Promise<Dirent<Buffer>[]>;
2394
+ ): Promise<Dirent<NonSharedBuffer>[]>;
2392
2395
  }
2393
2396
  /**
2394
2397
  * Reads the contents of the directory.
@@ -2428,7 +2431,7 @@ declare module "fs" {
2428
2431
  recursive?: boolean | undefined;
2429
2432
  }
2430
2433
  | "buffer",
2431
- ): Buffer[];
2434
+ ): NonSharedBuffer[];
2432
2435
  /**
2433
2436
  * Synchronous readdir(3) - read a directory.
2434
2437
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -2443,7 +2446,7 @@ declare module "fs" {
2443
2446
  })
2444
2447
  | BufferEncoding
2445
2448
  | null,
2446
- ): string[] | Buffer[];
2449
+ ): string[] | NonSharedBuffer[];
2447
2450
  /**
2448
2451
  * Synchronous readdir(3) - read a directory.
2449
2452
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
@@ -2468,7 +2471,7 @@ declare module "fs" {
2468
2471
  withFileTypes: true;
2469
2472
  recursive?: boolean | undefined;
2470
2473
  },
2471
- ): Dirent<Buffer>[];
2474
+ ): Dirent<NonSharedBuffer>[];
2472
2475
  /**
2473
2476
  * Closes the file descriptor. No arguments other than a possible exception are
2474
2477
  * given to the completion callback.
@@ -2835,7 +2838,7 @@ declare module "fs" {
2835
2838
  encoding?: BufferEncoding | null,
2836
2839
  ): number;
2837
2840
  export type ReadPosition = number | bigint;
2838
- export interface ReadSyncOptions {
2841
+ export interface ReadOptions {
2839
2842
  /**
2840
2843
  * @default 0
2841
2844
  */
@@ -2849,9 +2852,15 @@ declare module "fs" {
2849
2852
  */
2850
2853
  position?: ReadPosition | null | undefined;
2851
2854
  }
2852
- export interface ReadAsyncOptions<TBuffer extends NodeJS.ArrayBufferView> extends ReadSyncOptions {
2853
- buffer?: TBuffer;
2855
+ export interface ReadOptionsWithBuffer<T extends NodeJS.ArrayBufferView> extends ReadOptions {
2856
+ buffer?: T | undefined;
2854
2857
  }
2858
+ /** @deprecated Use `ReadOptions` instead. */
2859
+ // TODO: remove in future major
2860
+ export interface ReadSyncOptions extends ReadOptions {}
2861
+ /** @deprecated Use `ReadOptionsWithBuffer` instead. */
2862
+ // TODO: remove in future major
2863
+ export interface ReadAsyncOptions<T extends NodeJS.ArrayBufferView> extends ReadOptionsWithBuffer<T> {}
2855
2864
  /**
2856
2865
  * Read data from the file specified by `fd`.
2857
2866
  *
@@ -2886,15 +2895,15 @@ declare module "fs" {
2886
2895
  * `position` defaults to `null`
2887
2896
  * @since v12.17.0, 13.11.0
2888
2897
  */
2889
- export function read<TBuffer extends NodeJS.ArrayBufferView>(
2898
+ export function read<TBuffer extends NodeJS.ArrayBufferView = NonSharedBuffer>(
2890
2899
  fd: number,
2891
- options: ReadAsyncOptions<TBuffer>,
2900
+ options: ReadOptionsWithBuffer<TBuffer>,
2892
2901
  callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
2893
2902
  ): void;
2894
2903
  export function read<TBuffer extends NodeJS.ArrayBufferView>(
2895
2904
  fd: number,
2896
2905
  buffer: TBuffer,
2897
- options: ReadSyncOptions,
2906
+ options: ReadOptions,
2898
2907
  callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
2899
2908
  ): void;
2900
2909
  export function read<TBuffer extends NodeJS.ArrayBufferView>(
@@ -2904,7 +2913,7 @@ declare module "fs" {
2904
2913
  ): void;
2905
2914
  export function read(
2906
2915
  fd: number,
2907
- callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void,
2916
+ callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NonSharedBuffer) => void,
2908
2917
  ): void;
2909
2918
  export namespace read {
2910
2919
  /**
@@ -2924,16 +2933,16 @@ declare module "fs" {
2924
2933
  bytesRead: number;
2925
2934
  buffer: TBuffer;
2926
2935
  }>;
2927
- function __promisify__<TBuffer extends NodeJS.ArrayBufferView>(
2936
+ function __promisify__<TBuffer extends NodeJS.ArrayBufferView = NonSharedBuffer>(
2928
2937
  fd: number,
2929
- options: ReadAsyncOptions<TBuffer>,
2938
+ options: ReadOptionsWithBuffer<TBuffer>,
2930
2939
  ): Promise<{
2931
2940
  bytesRead: number;
2932
2941
  buffer: TBuffer;
2933
2942
  }>;
2934
2943
  function __promisify__(fd: number): Promise<{
2935
2944
  bytesRead: number;
2936
- buffer: NodeJS.ArrayBufferView;
2945
+ buffer: NonSharedBuffer;
2937
2946
  }>;
2938
2947
  }
2939
2948
  /**
@@ -2955,7 +2964,7 @@ declare module "fs" {
2955
2964
  * Similar to the above `fs.readSync` function, this version takes an optional `options` object.
2956
2965
  * If no `options` object is specified, it will default with the above values.
2957
2966
  */
2958
- export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadSyncOptions): number;
2967
+ export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadOptions): number;
2959
2968
  /**
2960
2969
  * Asynchronously reads the entire contents of a file.
2961
2970
  *
@@ -3628,12 +3637,12 @@ declare module "fs" {
3628
3637
  export function watch(
3629
3638
  filename: PathLike,
3630
3639
  options: WatchOptionsWithBufferEncoding | "buffer",
3631
- listener: WatchListener<Buffer>,
3640
+ listener: WatchListener<NonSharedBuffer>,
3632
3641
  ): FSWatcher;
3633
3642
  export function watch(
3634
3643
  filename: PathLike,
3635
3644
  options: WatchOptions | BufferEncoding | "buffer" | null,
3636
- listener: WatchListener<string | Buffer>,
3645
+ listener: WatchListener<string | NonSharedBuffer>,
3637
3646
  ): FSWatcher;
3638
3647
  export function watch(filename: PathLike, listener: WatchListener<string>): FSWatcher;
3639
3648
  /**
@@ -4344,27 +4353,29 @@ declare module "fs" {
4344
4353
  * @since v12.9.0
4345
4354
  * @param [position='null']
4346
4355
  */
4347
- export function writev(
4356
+ export function writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4348
4357
  fd: number,
4349
- buffers: readonly NodeJS.ArrayBufferView[],
4350
- cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void,
4358
+ buffers: TBuffers,
4359
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: TBuffers) => void,
4351
4360
  ): void;
4352
- export function writev(
4361
+ export function writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4353
4362
  fd: number,
4354
- buffers: readonly NodeJS.ArrayBufferView[],
4363
+ buffers: TBuffers,
4355
4364
  position: number | null,
4356
- cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: NodeJS.ArrayBufferView[]) => void,
4365
+ cb: (err: NodeJS.ErrnoException | null, bytesWritten: number, buffers: TBuffers) => void,
4357
4366
  ): void;
4358
- export interface WriteVResult {
4367
+ // Providing a default type parameter doesn't provide true BC for userland consumers, but at least suppresses TS2314
4368
+ // TODO: remove default in future major version
4369
+ export interface WriteVResult<T extends readonly NodeJS.ArrayBufferView[] = NodeJS.ArrayBufferView[]> {
4359
4370
  bytesWritten: number;
4360
- buffers: NodeJS.ArrayBufferView[];
4371
+ buffers: T;
4361
4372
  }
4362
4373
  export namespace writev {
4363
- function __promisify__(
4374
+ function __promisify__<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4364
4375
  fd: number,
4365
- buffers: readonly NodeJS.ArrayBufferView[],
4376
+ buffers: TBuffers,
4366
4377
  position?: number,
4367
- ): Promise<WriteVResult>;
4378
+ ): Promise<WriteVResult<TBuffers>>;
4368
4379
  }
4369
4380
  /**
4370
4381
  * For detailed information, see the documentation of the asynchronous version of
@@ -4389,27 +4400,29 @@ declare module "fs" {
4389
4400
  * @since v13.13.0, v12.17.0
4390
4401
  * @param [position='null']
4391
4402
  */
4392
- export function readv(
4403
+ export function readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4393
4404
  fd: number,
4394
- buffers: readonly NodeJS.ArrayBufferView[],
4395
- cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void,
4405
+ buffers: TBuffers,
4406
+ cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: TBuffers) => void,
4396
4407
  ): void;
4397
- export function readv(
4408
+ export function readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4398
4409
  fd: number,
4399
- buffers: readonly NodeJS.ArrayBufferView[],
4410
+ buffers: TBuffers,
4400
4411
  position: number | null,
4401
- cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: NodeJS.ArrayBufferView[]) => void,
4412
+ cb: (err: NodeJS.ErrnoException | null, bytesRead: number, buffers: TBuffers) => void,
4402
4413
  ): void;
4403
- export interface ReadVResult {
4414
+ // Providing a default type parameter doesn't provide true BC for userland consumers, but at least suppresses TS2314
4415
+ // TODO: remove default in future major version
4416
+ export interface ReadVResult<T extends readonly NodeJS.ArrayBufferView[] = NodeJS.ArrayBufferView[]> {
4404
4417
  bytesRead: number;
4405
- buffers: NodeJS.ArrayBufferView[];
4418
+ buffers: T;
4406
4419
  }
4407
4420
  export namespace readv {
4408
- function __promisify__(
4421
+ function __promisify__<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
4409
4422
  fd: number,
4410
- buffers: readonly NodeJS.ArrayBufferView[],
4423
+ buffers: TBuffers,
4411
4424
  position?: number,
4412
- ): Promise<ReadVResult>;
4425
+ ): Promise<ReadVResult<TBuffers>>;
4413
4426
  }
4414
4427
  /**
4415
4428
  * For detailed information, see the documentation of the asynchronous version of
@@ -18,5 +18,24 @@ declare global {
18
18
  type ArrayBufferView<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =
19
19
  | TypedArray<TArrayBuffer>
20
20
  | DataView<TArrayBuffer>;
21
+
22
+ // The following aliases are required to allow use of non-shared ArrayBufferViews in @types/node
23
+ // while maintaining compatibility with TS <=5.6.
24
+ // TODO: remove once @types/node no longer supports TS 5.6, and replace with native types.
25
+ type NonSharedUint8Array = Uint8Array<ArrayBuffer>;
26
+ type NonSharedUint8ClampedArray = Uint8ClampedArray<ArrayBuffer>;
27
+ type NonSharedUint16Array = Uint16Array<ArrayBuffer>;
28
+ type NonSharedUint32Array = Uint32Array<ArrayBuffer>;
29
+ type NonSharedInt8Array = Int8Array<ArrayBuffer>;
30
+ type NonSharedInt16Array = Int16Array<ArrayBuffer>;
31
+ type NonSharedInt32Array = Int32Array<ArrayBuffer>;
32
+ type NonSharedBigUint64Array = BigUint64Array<ArrayBuffer>;
33
+ type NonSharedBigInt64Array = BigInt64Array<ArrayBuffer>;
34
+ type NonSharedFloat16Array = Float16Array<ArrayBuffer>;
35
+ type NonSharedFloat32Array = Float32Array<ArrayBuffer>;
36
+ type NonSharedFloat64Array = Float64Array<ArrayBuffer>;
37
+ type NonSharedDataView = DataView<ArrayBuffer>;
38
+ type NonSharedTypedArray = TypedArray<ArrayBuffer>;
39
+ type NonSharedArrayBufferView = ArrayBufferView<ArrayBuffer>;
21
40
  }
22
41
  }