@types/node 22.15.33 → 22.18.13

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 (77) hide show
  1. node v22.18/README.md +15 -0
  2. {node v22.15 → node v22.18}/assert.d.ts +19 -0
  3. {node v22.15 → node v22.18}/buffer.buffer.d.ts +9 -0
  4. {node v22.15 → node v22.18}/buffer.d.ts +14 -6
  5. {node v22.15 → node v22.18}/child_process.d.ts +89 -162
  6. {node v22.15 → node v22.18}/cluster.d.ts +4 -5
  7. {node v22.15 → node v22.18}/crypto.d.ts +203 -167
  8. {node v22.15 → node v22.18}/dgram.d.ts +9 -8
  9. {node v22.15 → node v22.18}/dns/promises.d.ts +11 -10
  10. {node v22.15 → node v22.18}/dns.d.ts +19 -20
  11. {node v22.15 → node v22.18}/events.d.ts +80 -35
  12. {node v22.15 → node v22.18}/fs/promises.d.ts +78 -56
  13. {node v22.15 → node v22.18}/fs.d.ts +153 -129
  14. node v22.18/globals.d.ts +172 -0
  15. node v22.18/globals.typedarray.d.ts +38 -0
  16. {node v22.15 → node v22.18}/http.d.ts +112 -32
  17. {node v22.15 → node v22.18}/http2.d.ts +45 -26
  18. {node v22.15 → node v22.18}/https.d.ts +96 -62
  19. {node v22.15 → node v22.18}/index.d.ts +7 -3
  20. node v22.15/inspector.d.ts → node v22.18/inspector.generated.d.ts +219 -10
  21. {node v22.15 → node v22.18}/module.d.ts +70 -13
  22. {node v22.15 → node v22.18}/net.d.ts +12 -11
  23. {node v22.15 → node v22.18}/os.d.ts +14 -3
  24. {node v22.15 → node v22.18}/package.json +3 -83
  25. {node v22.15 → node v22.18}/perf_hooks.d.ts +6 -8
  26. {node v22.15 → node v22.18}/process.d.ts +15 -27
  27. {node v22.15 → node v22.18}/readline/promises.d.ts +1 -2
  28. {node v22.15 → node v22.18}/repl.d.ts +3 -5
  29. {node v22.15 → node v22.18}/sqlite.d.ts +212 -6
  30. {node v22.15 → node v22.18}/stream/consumers.d.ts +2 -2
  31. {node v22.15 → node v22.18}/stream/web.d.ts +8 -0
  32. {node v22.15 → node v22.18}/stream.d.ts +29 -33
  33. {node v22.15 → node v22.18}/string_decoder.d.ts +2 -2
  34. node v22.18/test.d.ts +2162 -0
  35. {node v22.15 → node v22.18}/tls.d.ts +90 -66
  36. {node v22.15 → node v22.18}/ts5.6/buffer.buffer.d.ts +10 -2
  37. node v22.18/ts5.6/globals.typedarray.d.ts +34 -0
  38. {node v22.15 → node v22.18}/ts5.6/index.d.ts +7 -3
  39. {node v22.15 → node v22.18}/url.d.ts +13 -4
  40. {node v22.15 → node v22.18}/util.d.ts +21 -6
  41. {node v22.15 → node v22.18}/v8.d.ts +33 -35
  42. {node v22.15 → node v22.18}/vm.d.ts +21 -50
  43. {node v22.15 → node v22.18}/wasi.d.ts +1 -1
  44. node v22.18/web-globals/abortcontroller.d.ts +34 -0
  45. node v22.18/web-globals/domexception.d.ts +68 -0
  46. node v22.15/dom-events.d.ts → node v22.18/web-globals/events.d.ts +49 -51
  47. node v22.18/web-globals/fetch.d.ts +46 -0
  48. node v22.18/web-globals/navigator.d.ts +22 -0
  49. node v22.18/web-globals/storage.d.ts +24 -0
  50. {node v22.15 → node v22.18}/worker_threads.d.ts +86 -67
  51. {node v22.15 → node v22.18}/zlib.d.ts +33 -26
  52. node v22.15/README.md +0 -15
  53. node v22.15/globals.d.ts +0 -364
  54. node v22.15/globals.typedarray.d.ts +0 -21
  55. node v22.15/test.d.ts +0 -2278
  56. node v22.15/ts5.6/globals.typedarray.d.ts +0 -19
  57. {node v22.15 → node v22.18}/LICENSE +0 -0
  58. {node v22.15 → node v22.18}/assert/strict.d.ts +0 -0
  59. {node v22.15 → node v22.18}/async_hooks.d.ts +1 -1
  60. {node v22.15 → node v22.18}/compatibility/disposable.d.ts +0 -0
  61. {node v22.15 → node v22.18}/compatibility/index.d.ts +0 -0
  62. {node v22.15 → node v22.18}/compatibility/indexable.d.ts +0 -0
  63. {node v22.15 → node v22.18}/compatibility/iterators.d.ts +0 -0
  64. {node v22.15 → node v22.18}/console.d.ts +0 -0
  65. {node v22.15 → node v22.18}/constants.d.ts +0 -0
  66. {node v22.15 → node v22.18}/diagnostics_channel.d.ts +0 -0
  67. {node v22.15 → node v22.18}/domain.d.ts +0 -0
  68. {node v22.15 → node v22.18}/path.d.ts +0 -0
  69. {node v22.15 → node v22.18}/punycode.d.ts +0 -0
  70. {node v22.15 → node v22.18}/querystring.d.ts +0 -0
  71. {node v22.15 → node v22.18}/readline.d.ts +0 -0
  72. {node v22.15 → node v22.18}/sea.d.ts +0 -0
  73. {node v22.15 → node v22.18}/stream/promises.d.ts +0 -0
  74. {node v22.15 → node v22.18}/timers/promises.d.ts +0 -0
  75. {node v22.15 → node v22.18}/timers.d.ts +0 -0
  76. {node v22.15 → node v22.18}/trace_events.d.ts +0 -0
  77. {node v22.15 → node v22.18}/tty.d.ts +0 -0
@@ -7,6 +7,7 @@
7
7
  * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/v8.js)
8
8
  */
9
9
  declare module "v8" {
10
+ import { NonSharedBuffer } from "node:buffer";
10
11
  import { Readable } from "node:stream";
11
12
  interface HeapSpaceInfo {
12
13
  space_name: string;
@@ -43,12 +44,12 @@ declare module "v8" {
43
44
  * If true, expose internals in the heap snapshot.
44
45
  * @default false
45
46
  */
46
- exposeInternals?: boolean;
47
+ exposeInternals?: boolean | undefined;
47
48
  /**
48
49
  * If true, expose numeric values in artificial fields.
49
50
  * @default false
50
51
  */
51
- exposeNumericValues?: boolean;
52
+ exposeNumericValues?: boolean | undefined;
52
53
  }
53
54
  /**
54
55
  * Returns an integer representing a version tag derived from the V8 version,
@@ -453,7 +454,7 @@ declare module "v8" {
453
454
  * the buffer is released. Calling this method results in undefined behavior
454
455
  * if a previous write has failed.
455
456
  */
456
- releaseBuffer(): Buffer;
457
+ releaseBuffer(): NonSharedBuffer;
457
458
  /**
458
459
  * Marks an `ArrayBuffer` as having its contents transferred out of band.
459
460
  * Pass the corresponding `ArrayBuffer` in the deserializing context to `deserializer.transferArrayBuffer()`.
@@ -481,7 +482,7 @@ declare module "v8" {
481
482
  * will require a way to compute the length of the buffer.
482
483
  * For use inside of a custom `serializer._writeHostObject()`.
483
484
  */
484
- writeRawBytes(buffer: NodeJS.TypedArray): void;
485
+ writeRawBytes(buffer: NodeJS.ArrayBufferView): void;
485
486
  }
486
487
  /**
487
488
  * A subclass of `Serializer` that serializes `TypedArray`(in particular `Buffer`) and `DataView` objects as host objects, and only
@@ -552,7 +553,7 @@ declare module "v8" {
552
553
  * larger than `buffer.constants.MAX_LENGTH`.
553
554
  * @since v8.0.0
554
555
  */
555
- function serialize(value: any): Buffer;
556
+ function serialize(value: any): NonSharedBuffer;
556
557
  /**
557
558
  * Uses a `DefaultDeserializer` with default options to read a JS value
558
559
  * from a buffer.
@@ -581,7 +582,6 @@ declare module "v8" {
581
582
  /**
582
583
  * The API is a no-op if `--heapsnapshot-near-heap-limit` is already set from the command line or the API is called more than once.
583
584
  * `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
584
- * @experimental
585
585
  * @since v18.10.0, v16.18.0
586
586
  */
587
587
  function setHeapSnapshotNearHeapLimit(limit: number): void;
@@ -807,33 +807,6 @@ declare module "v8" {
807
807
  */
808
808
  const promiseHooks: PromiseHooks;
809
809
  type StartupSnapshotCallbackFn = (args: any) => any;
810
- interface StartupSnapshot {
811
- /**
812
- * Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
813
- * This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
814
- * @since v18.6.0, v16.17.0
815
- */
816
- addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
817
- /**
818
- * Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
819
- * The `callback` and the `data` (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
820
- * to re-acquire resources that the application needs when the application is restarted from the snapshot.
821
- * @since v18.6.0, v16.17.0
822
- */
823
- addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
824
- /**
825
- * This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script.
826
- * If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized
827
- * data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
828
- * @since v18.6.0, v16.17.0
829
- */
830
- setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
831
- /**
832
- * Returns true if the Node.js instance is run to build a snapshot.
833
- * @since v18.6.0, v16.17.0
834
- */
835
- isBuildingSnapshot(): boolean;
836
- }
837
810
  /**
838
811
  * The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
839
812
  *
@@ -912,10 +885,35 @@ declare module "v8" {
912
885
  *
913
886
  * Currently the application deserialized from a user-land snapshot cannot be snapshotted again, so these APIs are only available to applications that are not deserialized from a user-land snapshot.
914
887
  *
915
- * @experimental
916
888
  * @since v18.6.0, v16.17.0
917
889
  */
918
- const startupSnapshot: StartupSnapshot;
890
+ namespace startupSnapshot {
891
+ /**
892
+ * Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
893
+ * This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
894
+ * @since v18.6.0, v16.17.0
895
+ */
896
+ function addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
897
+ /**
898
+ * Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
899
+ * The `callback` and the `data` (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
900
+ * to re-acquire resources that the application needs when the application is restarted from the snapshot.
901
+ * @since v18.6.0, v16.17.0
902
+ */
903
+ function addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
904
+ /**
905
+ * This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script.
906
+ * If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized
907
+ * data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
908
+ * @since v18.6.0, v16.17.0
909
+ */
910
+ function setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
911
+ /**
912
+ * Returns true if the Node.js instance is run to build a snapshot.
913
+ * @since v18.6.0, v16.17.0
914
+ */
915
+ function isBuildingSnapshot(): boolean;
916
+ }
919
917
  }
920
918
  declare module "node:v8" {
921
919
  export * from "v8";
@@ -37,6 +37,7 @@
37
37
  * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/vm.js)
38
38
  */
39
39
  declare module "vm" {
40
+ import { NonSharedBuffer } from "node:buffer";
40
41
  import { ImportAttributes } from "node:module";
41
42
  interface Context extends NodeJS.Dict<any> {}
42
43
  interface BaseOptions {
@@ -65,7 +66,7 @@ declare module "vm" {
65
66
  /**
66
67
  * Provides an optional data with V8's code cache data for the supplied source.
67
68
  */
68
- cachedData?: Buffer | NodeJS.ArrayBufferView | undefined;
69
+ cachedData?: NodeJS.ArrayBufferView | undefined;
69
70
  /** @deprecated in favor of `script.createCachedData()` */
70
71
  produceCachedData?: boolean | undefined;
71
72
  /**
@@ -97,28 +98,22 @@ declare module "vm" {
97
98
  */
98
99
  breakOnSigint?: boolean | undefined;
99
100
  }
100
- interface RunningScriptInNewContextOptions extends RunningScriptOptions {
101
+ interface RunningScriptInNewContextOptions
102
+ extends RunningScriptOptions, Pick<CreateContextOptions, "microtaskMode">
103
+ {
101
104
  /**
102
105
  * Human-readable name of the newly created context.
103
106
  */
104
- contextName?: CreateContextOptions["name"];
107
+ contextName?: CreateContextOptions["name"] | undefined;
105
108
  /**
106
109
  * Origin corresponding to the newly created context for display purposes. The origin should be formatted like a URL,
107
110
  * but with only the scheme, host, and port (if necessary), like the value of the `url.origin` property of a `URL` object.
108
111
  * Most notably, this string should omit the trailing slash, as that denotes a path.
109
112
  */
110
- contextOrigin?: CreateContextOptions["origin"];
111
- contextCodeGeneration?: CreateContextOptions["codeGeneration"];
112
- /**
113
- * If set to `afterEvaluate`, microtasks will be run immediately after the script has run.
114
- */
115
- microtaskMode?: CreateContextOptions["microtaskMode"];
113
+ contextOrigin?: CreateContextOptions["origin"] | undefined;
114
+ contextCodeGeneration?: CreateContextOptions["codeGeneration"] | undefined;
116
115
  }
117
- interface RunningCodeOptions extends RunningScriptOptions {
118
- /**
119
- * Provides an optional data with V8's code cache data for the supplied source.
120
- */
121
- cachedData?: ScriptOptions["cachedData"] | undefined;
116
+ interface RunningCodeOptions extends RunningScriptOptions, Pick<ScriptOptions, "cachedData"> {
122
117
  /**
123
118
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
124
119
  * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
@@ -129,11 +124,9 @@ declare module "vm" {
129
124
  | typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
130
125
  | undefined;
131
126
  }
132
- interface RunningCodeInNewContextOptions extends RunningScriptInNewContextOptions {
133
- /**
134
- * Provides an optional data with V8's code cache data for the supplied source.
135
- */
136
- cachedData?: ScriptOptions["cachedData"] | undefined;
127
+ interface RunningCodeInNewContextOptions
128
+ extends RunningScriptInNewContextOptions, Pick<ScriptOptions, "cachedData">
129
+ {
137
130
  /**
138
131
  * Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
139
132
  * part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
@@ -144,16 +137,7 @@ declare module "vm" {
144
137
  | typeof constants.USE_MAIN_CONTEXT_DEFAULT_LOADER
145
138
  | undefined;
146
139
  }
147
- interface CompileFunctionOptions extends BaseOptions {
148
- /**
149
- * Provides an optional data with V8's code cache data for the supplied source.
150
- */
151
- cachedData?: ScriptOptions["cachedData"] | undefined;
152
- /**
153
- * Specifies whether to produce new cache data.
154
- * @default false
155
- */
156
- produceCachedData?: boolean | undefined;
140
+ interface CompileFunctionOptions extends BaseOptions, Pick<ScriptOptions, "cachedData" | "produceCachedData"> {
157
141
  /**
158
142
  * The sandbox/context in which the said function should be compiled in.
159
143
  */
@@ -378,17 +362,17 @@ declare module "vm" {
378
362
  * ```
379
363
  * @since v10.6.0
380
364
  */
381
- createCachedData(): Buffer;
365
+ createCachedData(): NonSharedBuffer;
382
366
  /** @deprecated in favor of `script.createCachedData()` */
383
- cachedDataProduced?: boolean | undefined;
367
+ cachedDataProduced?: boolean;
384
368
  /**
385
369
  * When `cachedData` is supplied to create the `vm.Script`, this value will be set
386
370
  * to either `true` or `false` depending on acceptance of the data by V8.
387
371
  * Otherwise the value is `undefined`.
388
372
  * @since v5.7.0
389
373
  */
390
- cachedDataRejected?: boolean | undefined;
391
- cachedData?: Buffer | undefined;
374
+ cachedDataRejected?: boolean;
375
+ cachedData?: NonSharedBuffer;
392
376
  /**
393
377
  * When the script is compiled from a source that contains a source map magic
394
378
  * comment, this property will be set to the URL of the source map.
@@ -406,7 +390,7 @@ declare module "vm" {
406
390
  * ```
407
391
  * @since v19.1.0, v18.13.0
408
392
  */
409
- sourceMapURL?: string | undefined;
393
+ sourceMapURL: string | undefined;
410
394
  }
411
395
  /**
412
396
  * If the given `contextObject` is an object, the `vm.createContext()` method will
@@ -616,11 +600,7 @@ declare module "vm" {
616
600
  code: string,
617
601
  params?: readonly string[],
618
602
  options?: CompileFunctionOptions,
619
- ): Function & {
620
- cachedData?: Script["cachedData"] | undefined;
621
- cachedDataProduced?: Script["cachedDataProduced"] | undefined;
622
- cachedDataRejected?: Script["cachedDataRejected"] | undefined;
623
- };
603
+ ): Function & Pick<Script, "cachedData" | "cachedDataProduced" | "cachedDataRejected">;
624
604
  /**
625
605
  * Measure the memory known to V8 and used by all contexts known to the
626
606
  * current V8 isolate, or the main context.
@@ -677,10 +657,7 @@ declare module "vm" {
677
657
  * @experimental
678
658
  */
679
659
  function measureMemory(options?: MeasureMemoryOptions): Promise<MemoryMeasurement>;
680
- interface ModuleEvaluateOptions {
681
- timeout?: RunningScriptOptions["timeout"] | undefined;
682
- breakOnSigint?: RunningScriptOptions["breakOnSigint"] | undefined;
683
- }
660
+ interface ModuleEvaluateOptions extends Pick<RunningScriptOptions, "breakOnSigint" | "timeout"> {}
684
661
  type ModuleLinker = (
685
662
  specifier: string,
686
663
  referencingModule: Module,
@@ -887,19 +864,13 @@ declare module "vm" {
887
864
  */
888
865
  link(linker: ModuleLinker): Promise<void>;
889
866
  }
890
- interface SourceTextModuleOptions {
867
+ interface SourceTextModuleOptions extends Pick<ScriptOptions, "cachedData" | "columnOffset" | "lineOffset"> {
891
868
  /**
892
869
  * String used in stack traces.
893
870
  * @default 'vm:module(i)' where i is a context-specific ascending index.
894
871
  */
895
872
  identifier?: string | undefined;
896
- /**
897
- * Provides an optional data with V8's code cache data for the supplied source.
898
- */
899
- cachedData?: ScriptOptions["cachedData"] | undefined;
900
873
  context?: Context | undefined;
901
- lineOffset?: BaseOptions["lineOffset"] | undefined;
902
- columnOffset?: BaseOptions["columnOffset"] | undefined;
903
874
  /**
904
875
  * Called during evaluation of this module to initialize the `import.meta`.
905
876
  */
@@ -77,7 +77,7 @@ declare module "wasi" {
77
77
  * WASI command itself.
78
78
  * @default []
79
79
  */
80
- args?: string[] | undefined;
80
+ args?: readonly string[] | undefined;
81
81
  /**
82
82
  * An object similar to `process.env` that the WebAssembly
83
83
  * application will see as its environment.
@@ -0,0 +1,34 @@
1
+ export {};
2
+
3
+ type _AbortController = typeof globalThis extends { onmessage: any } ? {} : AbortController;
4
+ interface AbortController {
5
+ readonly signal: AbortSignal;
6
+ abort(reason?: any): void;
7
+ }
8
+
9
+ type _AbortSignal = typeof globalThis extends { onmessage: any } ? {} : AbortSignal;
10
+ interface AbortSignal extends EventTarget {
11
+ readonly aborted: boolean;
12
+ onabort: ((this: AbortSignal, ev: Event) => any) | null;
13
+ readonly reason: any;
14
+ throwIfAborted(): void;
15
+ }
16
+
17
+ declare global {
18
+ interface AbortController extends _AbortController {}
19
+ var AbortController: typeof globalThis extends { onmessage: any; AbortController: infer T } ? T
20
+ : {
21
+ prototype: AbortController;
22
+ new(): AbortController;
23
+ };
24
+
25
+ interface AbortSignal extends _AbortSignal {}
26
+ var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal: infer T } ? T
27
+ : {
28
+ prototype: AbortSignal;
29
+ new(): AbortSignal;
30
+ abort(reason?: any): AbortSignal;
31
+ any(signals: AbortSignal[]): AbortSignal;
32
+ timeout(milliseconds: number): AbortSignal;
33
+ };
34
+ }
@@ -0,0 +1,68 @@
1
+ export {};
2
+
3
+ type _DOMException = typeof globalThis extends { onmessage: any } ? {} : DOMException;
4
+ interface DOMException extends Error {
5
+ readonly code: number;
6
+ readonly message: string;
7
+ readonly name: string;
8
+ readonly INDEX_SIZE_ERR: 1;
9
+ readonly DOMSTRING_SIZE_ERR: 2;
10
+ readonly HIERARCHY_REQUEST_ERR: 3;
11
+ readonly WRONG_DOCUMENT_ERR: 4;
12
+ readonly INVALID_CHARACTER_ERR: 5;
13
+ readonly NO_DATA_ALLOWED_ERR: 6;
14
+ readonly NO_MODIFICATION_ALLOWED_ERR: 7;
15
+ readonly NOT_FOUND_ERR: 8;
16
+ readonly NOT_SUPPORTED_ERR: 9;
17
+ readonly INUSE_ATTRIBUTE_ERR: 10;
18
+ readonly INVALID_STATE_ERR: 11;
19
+ readonly SYNTAX_ERR: 12;
20
+ readonly INVALID_MODIFICATION_ERR: 13;
21
+ readonly NAMESPACE_ERR: 14;
22
+ readonly INVALID_ACCESS_ERR: 15;
23
+ readonly VALIDATION_ERR: 16;
24
+ readonly TYPE_MISMATCH_ERR: 17;
25
+ readonly SECURITY_ERR: 18;
26
+ readonly NETWORK_ERR: 19;
27
+ readonly ABORT_ERR: 20;
28
+ readonly URL_MISMATCH_ERR: 21;
29
+ readonly QUOTA_EXCEEDED_ERR: 22;
30
+ readonly TIMEOUT_ERR: 23;
31
+ readonly INVALID_NODE_TYPE_ERR: 24;
32
+ readonly DATA_CLONE_ERR: 25;
33
+ }
34
+
35
+ declare global {
36
+ interface DOMException extends _DOMException {}
37
+ var DOMException: typeof globalThis extends { onmessage: any; DOMException: infer T } ? T
38
+ : {
39
+ prototype: DOMException;
40
+ new(message?: string, name?: string): DOMException;
41
+ new(message?: string, options?: { name?: string; cause?: unknown }): DOMException;
42
+ readonly INDEX_SIZE_ERR: 1;
43
+ readonly DOMSTRING_SIZE_ERR: 2;
44
+ readonly HIERARCHY_REQUEST_ERR: 3;
45
+ readonly WRONG_DOCUMENT_ERR: 4;
46
+ readonly INVALID_CHARACTER_ERR: 5;
47
+ readonly NO_DATA_ALLOWED_ERR: 6;
48
+ readonly NO_MODIFICATION_ALLOWED_ERR: 7;
49
+ readonly NOT_FOUND_ERR: 8;
50
+ readonly NOT_SUPPORTED_ERR: 9;
51
+ readonly INUSE_ATTRIBUTE_ERR: 10;
52
+ readonly INVALID_STATE_ERR: 11;
53
+ readonly SYNTAX_ERR: 12;
54
+ readonly INVALID_MODIFICATION_ERR: 13;
55
+ readonly NAMESPACE_ERR: 14;
56
+ readonly INVALID_ACCESS_ERR: 15;
57
+ readonly VALIDATION_ERR: 16;
58
+ readonly TYPE_MISMATCH_ERR: 17;
59
+ readonly SECURITY_ERR: 18;
60
+ readonly NETWORK_ERR: 19;
61
+ readonly ABORT_ERR: 20;
62
+ readonly URL_MISMATCH_ERR: 21;
63
+ readonly QUOTA_EXCEEDED_ERR: 22;
64
+ readonly TIMEOUT_ERR: 23;
65
+ readonly INVALID_NODE_TYPE_ERR: 24;
66
+ readonly DATA_CLONE_ERR: 25;
67
+ };
68
+ }
@@ -1,37 +1,62 @@
1
- // Make this a module
2
1
  export {};
3
2
 
4
- // Conditional type aliases, which are later merged into the global scope.
5
- // Will either be empty if the relevant web library is already present, or the @types/node definition otherwise.
3
+ interface AddEventListenerOptions extends EventListenerOptions {
4
+ once?: boolean;
5
+ passive?: boolean;
6
+ signal?: AbortSignal;
7
+ }
8
+
9
+ type _CustomEvent<T = any> = typeof globalThis extends { onmessage: any } ? {} : CustomEvent<T>;
10
+ interface CustomEvent<T = any> extends Event {
11
+ readonly detail: T;
12
+ }
13
+
14
+ interface CustomEventInit<T = any> extends EventInit {
15
+ detail?: T;
16
+ }
6
17
 
7
- type __Event = typeof globalThis extends { onmessage: any } ? {} : Event;
18
+ type _Event = typeof globalThis extends { onmessage: any } ? {} : Event;
8
19
  interface Event {
9
20
  readonly bubbles: boolean;
10
21
  cancelBubble: boolean;
11
22
  readonly cancelable: boolean;
12
23
  readonly composed: boolean;
13
- composedPath(): [EventTarget?];
14
24
  readonly currentTarget: EventTarget | null;
15
25
  readonly defaultPrevented: boolean;
16
26
  readonly eventPhase: 0 | 2;
17
- initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
18
27
  readonly isTrusted: boolean;
19
- preventDefault(): void;
20
- readonly returnValue: boolean;
28
+ returnValue: boolean;
21
29
  readonly srcElement: EventTarget | null;
22
- stopImmediatePropagation(): void;
23
- stopPropagation(): void;
24
30
  readonly target: EventTarget | null;
25
31
  readonly timeStamp: number;
26
32
  readonly type: string;
33
+ composedPath(): [EventTarget?];
34
+ initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
35
+ preventDefault(): void;
36
+ stopImmediatePropagation(): void;
37
+ stopPropagation(): void;
27
38
  }
28
39
 
29
- type __CustomEvent<T = any> = typeof globalThis extends { onmessage: any } ? {} : CustomEvent<T>;
30
- interface CustomEvent<T = any> extends Event {
31
- readonly detail: T;
40
+ interface EventInit {
41
+ bubbles?: boolean;
42
+ cancelable?: boolean;
43
+ composed?: boolean;
44
+ }
45
+
46
+ interface EventListener {
47
+ (evt: Event): void;
48
+ }
49
+
50
+ interface EventListenerObject {
51
+ handleEvent(object: Event): void;
52
+ }
53
+
54
+ type _EventListenerOptions = typeof globalThis extends { onmessage: any } ? {} : EventListenerOptions;
55
+ interface EventListenerOptions {
56
+ capture?: boolean;
32
57
  }
33
58
 
34
- type __EventTarget = typeof globalThis extends { onmessage: any } ? {} : EventTarget;
59
+ type _EventTarget = typeof globalThis extends { onmessage: any } ? {} : EventTarget;
35
60
  interface EventTarget {
36
61
  addEventListener(
37
62
  type: string,
@@ -46,51 +71,24 @@ interface EventTarget {
46
71
  ): void;
47
72
  }
48
73
 
49
- interface EventInit {
50
- bubbles?: boolean;
51
- cancelable?: boolean;
52
- composed?: boolean;
53
- }
54
-
55
- interface CustomEventInit<T = any> extends EventInit {
56
- detail?: T;
57
- }
58
-
59
- interface EventListenerOptions {
60
- capture?: boolean;
61
- }
62
-
63
- interface AddEventListenerOptions extends EventListenerOptions {
64
- once?: boolean;
65
- passive?: boolean;
66
- signal?: AbortSignal;
67
- }
68
-
69
- interface EventListener {
70
- (evt: Event): void;
71
- }
72
-
73
- interface EventListenerObject {
74
- handleEvent(object: Event): void;
75
- }
76
-
77
- // Merge conditional interfaces into global scope, and conditionally declare global constructors.
78
74
  declare global {
79
- interface Event extends __Event {}
75
+ interface CustomEvent<T = any> extends _CustomEvent<T> {}
76
+ var CustomEvent: typeof globalThis extends { onmessage: any; CustomEvent: infer T } ? T
77
+ : {
78
+ prototype: CustomEvent;
79
+ new<T>(type: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
80
+ };
81
+
82
+ interface Event extends _Event {}
80
83
  var Event: typeof globalThis extends { onmessage: any; Event: infer T } ? T
81
84
  : {
82
85
  prototype: Event;
83
86
  new(type: string, eventInitDict?: EventInit): Event;
84
87
  };
85
88
 
86
- interface CustomEvent<T = any> extends __CustomEvent<T> {}
87
- var CustomEvent: typeof globalThis extends { onmessage: any; CustomEvent: infer T } ? T
88
- : {
89
- prototype: CustomEvent;
90
- new<T>(type: string, eventInitDict?: CustomEventInit<T>): CustomEvent<T>;
91
- };
89
+ interface EventListenerOptions extends _EventListenerOptions {}
92
90
 
93
- interface EventTarget extends __EventTarget {}
91
+ interface EventTarget extends _EventTarget {}
94
92
  var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T
95
93
  : {
96
94
  prototype: EventTarget;
@@ -0,0 +1,46 @@
1
+ export {};
2
+
3
+ import * as undici from "undici-types";
4
+
5
+ type _EventSource = typeof globalThis extends { onmessage: any } ? {} : undici.EventSource;
6
+ type _FormData = typeof globalThis extends { onmessage: any } ? {} : undici.FormData;
7
+ type _Headers = typeof globalThis extends { onmessage: any } ? {} : undici.Headers;
8
+ type _MessageEvent = typeof globalThis extends { onmessage: any } ? {} : undici.MessageEvent;
9
+ type _Request = typeof globalThis extends { onmessage: any } ? {} : undici.Request;
10
+ type _RequestInit = typeof globalThis extends { onmessage: any } ? {} : undici.RequestInit;
11
+ type _Response = typeof globalThis extends { onmessage: any } ? {} : undici.Response;
12
+ type _ResponseInit = typeof globalThis extends { onmessage: any } ? {} : undici.ResponseInit;
13
+ type _WebSocket = typeof globalThis extends { onmessage: any } ? {} : undici.WebSocket;
14
+
15
+ declare global {
16
+ function fetch(
17
+ input: string | URL | Request,
18
+ init?: RequestInit,
19
+ ): Promise<Response>;
20
+
21
+ interface EventSource extends _EventSource {}
22
+ var EventSource: typeof globalThis extends { onmessage: any; EventSource: infer T } ? T : typeof undici.EventSource;
23
+
24
+ interface FormData extends _FormData {}
25
+ var FormData: typeof globalThis extends { onmessage: any; FormData: infer T } ? T : typeof undici.FormData;
26
+
27
+ interface Headers extends _Headers {}
28
+ var Headers: typeof globalThis extends { onmessage: any; Headers: infer T } ? T : typeof undici.Headers;
29
+
30
+ interface MessageEvent extends _MessageEvent {}
31
+ var MessageEvent: typeof globalThis extends { onmessage: any; MessageEvent: infer T } ? T
32
+ : typeof undici.MessageEvent;
33
+
34
+ interface Request extends _Request {}
35
+ var Request: typeof globalThis extends { onmessage: any; Request: infer T } ? T : typeof undici.Request;
36
+
37
+ interface RequestInit extends _RequestInit {}
38
+
39
+ interface Response extends _Response {}
40
+ var Response: typeof globalThis extends { onmessage: any; Response: infer T } ? T : typeof undici.Response;
41
+
42
+ interface ResponseInit extends _ResponseInit {}
43
+
44
+ interface WebSocket extends _WebSocket {}
45
+ var WebSocket: typeof globalThis extends { onmessage: any; WebSocket: infer T } ? T : typeof undici.WebSocket;
46
+ }
@@ -0,0 +1,22 @@
1
+ export {};
2
+
3
+ // lib.webworker has `WorkerNavigator` rather than `Navigator`, so conditionals use `onabort` instead of `onmessage`
4
+ type _Navigator = typeof globalThis extends { onabort: any } ? {} : Navigator;
5
+ interface Navigator {
6
+ readonly hardwareConcurrency: number;
7
+ readonly language: string;
8
+ readonly languages: readonly string[];
9
+ readonly platform: string;
10
+ readonly userAgent: string;
11
+ }
12
+
13
+ declare global {
14
+ interface Navigator extends _Navigator {}
15
+ var Navigator: typeof globalThis extends { onabort: any; Navigator: infer T } ? T : {
16
+ prototype: Navigator;
17
+ new(): Navigator;
18
+ };
19
+
20
+ // Needs conditional inference for lib.dom and lib.webworker compatibility
21
+ var navigator: typeof globalThis extends { onmessage: any; navigator: infer T } ? T : Navigator;
22
+ }
@@ -0,0 +1,24 @@
1
+ export {};
2
+
3
+ // These interfaces are absent from lib.webworker, so the conditionals use `onabort` rather than `onmessage`
4
+ type _Storage = typeof globalThis extends { onabort: any } ? {} : Storage;
5
+ interface Storage {
6
+ readonly length: number;
7
+ clear(): void;
8
+ getItem(key: string): string | null;
9
+ key(index: number): string | null;
10
+ removeItem(key: string): void;
11
+ setItem(key: string, value: string): void;
12
+ [key: string]: any;
13
+ }
14
+
15
+ declare global {
16
+ interface Storage extends _Storage {}
17
+ var Storage: typeof globalThis extends { onabort: any; Storage: infer T } ? T : {
18
+ prototype: Storage;
19
+ new(): Storage;
20
+ };
21
+
22
+ var localStorage: Storage;
23
+ var sessionStorage: Storage;
24
+ }