@types/node 24.7.1 → 24.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/perf_hooks.d.ts CHANGED
@@ -48,13 +48,13 @@ declare module "perf_hooks" {
48
48
  * the type of garbage collection operation that occurred.
49
49
  * See perf_hooks.constants for valid values.
50
50
  */
51
- readonly kind?: number | undefined;
51
+ readonly kind: number;
52
52
  /**
53
53
  * When `performanceEntry.entryType` is equal to 'gc', the `performance.flags`
54
54
  * property contains additional information about garbage collection operation.
55
55
  * See perf_hooks.constants for valid values.
56
56
  */
57
- readonly flags?: number | undefined;
57
+ readonly flags: number;
58
58
  }
59
59
  /**
60
60
  * The constructor of this class is not exposed to users directly.
@@ -92,11 +92,6 @@ declare module "perf_hooks" {
92
92
  * @since v8.5.0
93
93
  */
94
94
  readonly entryType: EntryType;
95
- /**
96
- * Additional detail specific to the `entryType`.
97
- * @since v16.0.0
98
- */
99
- readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type.
100
95
  toJSON(): any;
101
96
  }
102
97
  /**
@@ -104,6 +99,7 @@ declare module "perf_hooks" {
104
99
  * @since v18.2.0, v16.17.0
105
100
  */
106
101
  class PerformanceMark extends PerformanceEntry {
102
+ readonly detail: any;
107
103
  readonly duration: 0;
108
104
  readonly entryType: "mark";
109
105
  }
@@ -114,6 +110,7 @@ declare module "perf_hooks" {
114
110
  * @since v18.2.0, v16.17.0
115
111
  */
116
112
  class PerformanceMeasure extends PerformanceEntry {
113
+ readonly detail: any;
117
114
  readonly entryType: "measure";
118
115
  }
119
116
  interface UVMetrics {
@@ -130,6 +127,7 @@ declare module "perf_hooks" {
130
127
  */
131
128
  readonly eventsWaiting: number;
132
129
  }
130
+ // TODO: PerformanceNodeEntry is missing
133
131
  /**
134
132
  * _This property is an extension by Node.js. It is not available in Web browsers._
135
133
  *
@@ -225,7 +223,7 @@ declare module "perf_hooks" {
225
223
  /**
226
224
  * Additional optional detail to include with the mark.
227
225
  */
228
- detail?: unknown | undefined;
226
+ detail?: unknown;
229
227
  /**
230
228
  * Duration between start and end times.
231
229
  */
node/process.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  declare module "process" {
2
+ import { Control, MessageOptions } from "node:child_process";
2
3
  import * as tty from "node:tty";
3
4
  import { Worker } from "node:worker_threads";
4
5
 
@@ -346,7 +347,7 @@ declare module "process" {
346
347
  /**
347
348
  * Can be used to change the default timezone at runtime
348
349
  */
349
- TZ?: string;
350
+ TZ?: string | undefined;
350
351
  }
351
352
  interface HRTime {
352
353
  /**
@@ -990,7 +991,7 @@ declare module "process" {
990
991
  * @since v0.1.13
991
992
  * @param [code=0] The exit code. For string type, only integer strings (e.g.,'1') are allowed.
992
993
  */
993
- exit(code?: number | string | null | undefined): never;
994
+ exit(code?: number | string | null): never;
994
995
  /**
995
996
  * A number which will be the process exit code, when the process either
996
997
  * exits gracefully, or is exited via {@link exit} without specifying
@@ -1001,7 +1002,7 @@ declare module "process" {
1001
1002
  * @default undefined
1002
1003
  * @since v0.11.8
1003
1004
  */
1004
- exitCode?: number | string | number | undefined;
1005
+ exitCode: number | string | null | undefined;
1005
1006
  finalization: {
1006
1007
  /**
1007
1008
  * This function registers a callback to be called when the process emits the `exit` event if the `ref` object was not garbage collected.
@@ -1568,7 +1569,7 @@ declare module "process" {
1568
1569
  * @since v0.1.17
1569
1570
  * @deprecated Since v14.0.0 - Use `main` instead.
1570
1571
  */
1571
- mainModule?: Module | undefined;
1572
+ mainModule?: Module;
1572
1573
  memoryUsage: MemoryUsageFn;
1573
1574
  /**
1574
1575
  * Gets the amount of memory available to the process (in bytes) based on
@@ -1760,18 +1761,7 @@ declare module "process" {
1760
1761
  * If no IPC channel exists, this property is undefined.
1761
1762
  * @since v7.1.0
1762
1763
  */
1763
- channel?: {
1764
- /**
1765
- * This method makes the IPC channel keep the event loop of the process running if .unref() has been called before.
1766
- * @since v7.1.0
1767
- */
1768
- ref(): void;
1769
- /**
1770
- * This method makes the IPC channel not keep the event loop of the process running, and lets it finish even while the channel is open.
1771
- * @since v7.1.0
1772
- */
1773
- unref(): void;
1774
- };
1764
+ channel?: Control;
1775
1765
  /**
1776
1766
  * If Node.js is spawned with an IPC channel, the `process.send()` method can be
1777
1767
  * used to send messages to the parent process. Messages will be received as a `'message'` event on the parent's `ChildProcess` object.
@@ -1786,9 +1776,7 @@ declare module "process" {
1786
1776
  send?(
1787
1777
  message: any,
1788
1778
  sendHandle?: any,
1789
- options?: {
1790
- keepOpen?: boolean | undefined;
1791
- },
1779
+ options?: MessageOptions,
1792
1780
  callback?: (error: Error | null) => void,
1793
1781
  ): boolean;
1794
1782
  /**
@@ -64,7 +64,7 @@ declare module "readline/promises" {
64
64
  constructor(
65
65
  stream: NodeJS.WritableStream,
66
66
  options?: {
67
- autoCommit?: boolean;
67
+ autoCommit?: boolean | undefined;
68
68
  },
69
69
  );
70
70
  /**
node/sea.d.ts CHANGED
@@ -150,4 +150,13 @@ declare module "node:sea" {
150
150
  * @since v20.12.0
151
151
  */
152
152
  function getRawAsset(key: AssetKey): ArrayBuffer;
153
+ /**
154
+ * This method can be used to retrieve an array of all the keys of assets
155
+ * embedded into the single-executable application.
156
+ * An error is thrown when not running inside a single-executable application.
157
+ * @since v24.8.0
158
+ * @returns An array containing all the keys of the assets
159
+ * embedded in the executable. If no assets are embedded, returns an empty array.
160
+ */
161
+ function getAssetKeys(): string[];
153
162
  }
node/stream.d.ts CHANGED
@@ -45,22 +45,22 @@ declare module "stream" {
45
45
  emitClose?: boolean | undefined;
46
46
  highWaterMark?: number | undefined;
47
47
  objectMode?: boolean | undefined;
48
- construct?(this: T, callback: (error?: Error | null) => void): void;
49
- destroy?(this: T, error: Error | null, callback: (error?: Error | null) => void): void;
48
+ construct?: ((this: T, callback: (error?: Error | null) => void) => void) | undefined;
49
+ destroy?: ((this: T, error: Error | null, callback: (error?: Error | null) => void) => void) | undefined;
50
50
  autoDestroy?: boolean | undefined;
51
51
  }
52
52
  interface ReadableOptions<T extends Readable = Readable> extends StreamOptions<T> {
53
53
  encoding?: BufferEncoding | undefined;
54
- read?(this: T, size: number): void;
54
+ read?: ((this: T, size: number) => void) | undefined;
55
55
  }
56
56
  interface ArrayOptions {
57
57
  /**
58
58
  * The maximum concurrent invocations of `fn` to call on the stream at once.
59
59
  * @default 1
60
60
  */
61
- concurrency?: number;
61
+ concurrency?: number | undefined;
62
62
  /** Allows destroying the stream if the signal is aborted. */
63
- signal?: AbortSignal;
63
+ signal?: AbortSignal | undefined;
64
64
  }
65
65
  /**
66
66
  * @since v0.9.4
@@ -697,21 +697,25 @@ declare module "stream" {
697
697
  interface WritableOptions<T extends Writable = Writable> extends StreamOptions<T> {
698
698
  decodeStrings?: boolean | undefined;
699
699
  defaultEncoding?: BufferEncoding | undefined;
700
- write?(
701
- this: T,
702
- chunk: any,
703
- encoding: BufferEncoding,
704
- callback: (error?: Error | null) => void,
705
- ): void;
706
- writev?(
707
- this: T,
708
- chunks: Array<{
709
- chunk: any;
710
- encoding: BufferEncoding;
711
- }>,
712
- callback: (error?: Error | null) => void,
713
- ): void;
714
- final?(this: T, callback: (error?: Error | null) => void): void;
700
+ write?:
701
+ | ((
702
+ this: T,
703
+ chunk: any,
704
+ encoding: BufferEncoding,
705
+ callback: (error?: Error | null) => void,
706
+ ) => void)
707
+ | undefined;
708
+ writev?:
709
+ | ((
710
+ this: T,
711
+ chunks: Array<{
712
+ chunk: any;
713
+ encoding: BufferEncoding;
714
+ }>,
715
+ callback: (error?: Error | null) => void,
716
+ ) => void)
717
+ | undefined;
718
+ final?: ((this: T, callback: (error?: Error | null) => void) => void) | undefined;
715
719
  }
716
720
  /**
717
721
  * @since v0.9.4
@@ -1235,8 +1239,10 @@ declare module "stream" {
1235
1239
  function duplexPair(options?: DuplexOptions): [Duplex, Duplex];
1236
1240
  type TransformCallback = (error?: Error | null, data?: any) => void;
1237
1241
  interface TransformOptions<T extends Transform = Transform> extends DuplexOptions<T> {
1238
- transform?(this: T, chunk: any, encoding: BufferEncoding, callback: TransformCallback): void;
1239
- flush?(this: T, callback: TransformCallback): void;
1242
+ transform?:
1243
+ | ((this: T, chunk: any, encoding: BufferEncoding, callback: TransformCallback) => void)
1244
+ | undefined;
1245
+ flush?: ((this: T, callback: TransformCallback) => void) | undefined;
1240
1246
  }
1241
1247
  /**
1242
1248
  * Transform streams are `Duplex` streams where the output is in some way
@@ -1643,12 +1649,14 @@ declare module "stream" {
1643
1649
  ...streams: Array<NodeJS.ReadWriteStream | NodeJS.WritableStream | PipelineOptions>
1644
1650
  ): Promise<void>;
1645
1651
  }
1652
+ // TODO: this interface never existed; remove in next major
1646
1653
  interface Pipe {
1647
1654
  close(): void;
1648
1655
  hasRef(): boolean;
1649
1656
  ref(): void;
1650
1657
  unref(): void;
1651
1658
  }
1659
+ // TODO: these should all take webstream arguments
1652
1660
  /**
1653
1661
  * Returns whether the stream has encountered an error.
1654
1662
  * @since v17.3.0, v16.14.0
@@ -1657,8 +1665,15 @@ declare module "stream" {
1657
1665
  /**
1658
1666
  * Returns whether the stream is readable.
1659
1667
  * @since v17.4.0, v16.14.0
1668
+ * @returns Only returns `null` if `stream` is not a valid `Readable`, `Duplex` or `ReadableStream`.
1669
+ */
1670
+ function isReadable(stream: Readable | NodeJS.ReadableStream): boolean | null;
1671
+ /**
1672
+ * Returns whether the stream is writable.
1673
+ * @since v20.0.0
1674
+ * @returns Only returns `null` if `stream` is not a valid `Writable`, `Duplex` or `WritableStream`.
1660
1675
  */
1661
- function isReadable(stream: Readable | NodeJS.ReadableStream): boolean;
1676
+ function isWritable(stream: Writable | NodeJS.WritableStream): boolean | null;
1662
1677
  }
1663
1678
  export = Stream;
1664
1679
  }
node/tls.d.ts CHANGED
@@ -586,7 +586,7 @@ declare module "tls" {
586
586
  * requires explicitly specifying a cipher suite with the `ciphers` option.
587
587
  * More information can be found in the RFC 4279.
588
588
  */
589
- pskCallback?(socket: TLSSocket, identity: string): DataView | NodeJS.TypedArray | null;
589
+ pskCallback?: ((socket: TLSSocket, identity: string) => NodeJS.ArrayBufferView | null) | undefined;
590
590
  /**
591
591
  * hint to send to a client to help
592
592
  * with selecting the identity during TLS-PSK negotiation. Will be ignored
@@ -627,7 +627,7 @@ declare module "tls" {
627
627
  * compatible with the selected cipher's digest.
628
628
  * `identity` must use UTF-8 encoding.
629
629
  */
630
- pskCallback?(hint: string | null): PSKCallbackNegotation | null;
630
+ pskCallback?: ((hint: string | null) => PSKCallbackNegotation | null) | undefined;
631
631
  }
632
632
  /**
633
633
  * Accepts encrypted connections using TLS or SSL.
node/v8.d.ts CHANGED
@@ -43,12 +43,12 @@ declare module "v8" {
43
43
  * If true, expose internals in the heap snapshot.
44
44
  * @default false
45
45
  */
46
- exposeInternals?: boolean;
46
+ exposeInternals?: boolean | undefined;
47
47
  /**
48
48
  * If true, expose numeric values in artificial fields.
49
49
  * @default false
50
50
  */
51
- exposeNumericValues?: boolean;
51
+ exposeNumericValues?: boolean | undefined;
52
52
  }
53
53
  /**
54
54
  * Returns an integer representing a version tag derived from the V8 version,
@@ -400,6 +400,22 @@ declare module "v8" {
400
400
  * @since v12.8.0
401
401
  */
402
402
  function getHeapCodeStatistics(): HeapCodeStatistics;
403
+ /**
404
+ * @since v24.8.0
405
+ */
406
+ interface CPUProfileHandle {
407
+ /**
408
+ * Stopping collecting the profile, then return a Promise that fulfills with an error or the
409
+ * profile data.
410
+ * @since v24.8.0
411
+ */
412
+ stop(): Promise<string>;
413
+ /**
414
+ * Stopping collecting the profile and the profile will be discarded.
415
+ * @since v24.8.0
416
+ */
417
+ [Symbol.asyncDispose](): Promise<void>;
418
+ }
403
419
  /**
404
420
  * V8 only supports `Latin-1/ISO-8859-1` and `UTF16` as the underlying representation of a string.
405
421
  * If the `content` uses `Latin-1/ISO-8859-1` as the underlying representation, this function will return true;