@types/node 22.15.21 → 24.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node/README.md +2 -2
- node/assert/strict.d.ts +105 -2
- node/assert.d.ts +162 -101
- node/async_hooks.d.ts +26 -6
- node/buffer.buffer.d.ts +9 -0
- node/buffer.d.ts +15 -7
- node/child_process.d.ts +91 -164
- node/cluster.d.ts +19 -20
- node/console.d.ts +19 -18
- node/crypto.d.ts +1264 -356
- node/dgram.d.ts +10 -9
- node/diagnostics_channel.d.ts +18 -15
- node/dns/promises.d.ts +36 -9
- node/dns.d.ts +95 -37
- node/domain.d.ts +1 -1
- node/events.d.ts +81 -36
- node/fs/promises.d.ts +104 -59
- node/fs.d.ts +414 -137
- node/globals.d.ts +149 -350
- node/globals.typedarray.d.ts +20 -0
- node/http.d.ts +187 -37
- node/http2.d.ts +266 -67
- node/https.d.ts +97 -63
- node/index.d.ts +16 -7
- node/inspector.d.ts +206 -3931
- node/inspector.generated.d.ts +4233 -0
- node/module.d.ts +153 -31
- node/net.d.ts +35 -16
- node/os.d.ts +22 -10
- node/package.json +14 -84
- node/path.d.ts +1 -1
- node/perf_hooks.d.ts +30 -18
- node/process.d.ts +40 -34
- node/punycode.d.ts +1 -1
- node/querystring.d.ts +1 -1
- node/readline/promises.d.ts +1 -2
- node/readline.d.ts +13 -13
- node/repl.d.ts +25 -17
- node/sea.d.ts +10 -1
- node/sqlite.d.ts +438 -9
- node/stream/consumers.d.ts +2 -2
- node/stream/web.d.ts +13 -54
- node/stream.d.ts +68 -47
- node/string_decoder.d.ts +3 -3
- node/test.d.ts +2034 -1975
- node/timers/promises.d.ts +1 -1
- node/timers.d.ts +1 -3
- node/tls.d.ts +124 -114
- node/trace_events.d.ts +6 -6
- node/ts5.6/buffer.buffer.d.ts +10 -2
- node/ts5.6/compatibility/float16array.d.ts +71 -0
- node/ts5.6/globals.typedarray.d.ts +17 -0
- node/ts5.6/index.d.ts +18 -7
- node/ts5.7/compatibility/float16array.d.ts +72 -0
- node/ts5.7/index.d.ts +103 -0
- node/tty.d.ts +1 -1
- node/url.d.ts +119 -34
- node/util.d.ts +46 -305
- node/v8.d.ts +100 -37
- node/vm.d.ts +299 -110
- node/wasi.d.ts +23 -2
- node/web-globals/abortcontroller.d.ts +34 -0
- node/web-globals/crypto.d.ts +32 -0
- node/web-globals/domexception.d.ts +68 -0
- node/web-globals/events.d.ts +97 -0
- node/web-globals/fetch.d.ts +50 -0
- node/web-globals/navigator.d.ts +25 -0
- node/web-globals/storage.d.ts +24 -0
- node/web-globals/streams.d.ts +22 -0
- node/worker_threads.d.ts +225 -75
- node/zlib.d.ts +44 -33
- node/compatibility/disposable.d.ts +0 -16
- node/compatibility/index.d.ts +0 -9
- node/compatibility/indexable.d.ts +0 -23
- node/dom-events.d.ts +0 -124
node/zlib.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ```
|
|
10
10
|
*
|
|
11
11
|
* Compression and decompression are built around the Node.js
|
|
12
|
-
* [Streams API](https://nodejs.org/docs/latest-
|
|
12
|
+
* [Streams API](https://nodejs.org/docs/latest-v24.x/api/stream.html).
|
|
13
13
|
*
|
|
14
14
|
* Compressing or decompressing a stream (such as a file) can be accomplished by
|
|
15
15
|
* piping the source stream through a `zlib` `Transform` stream into a destination
|
|
@@ -89,9 +89,10 @@
|
|
|
89
89
|
* });
|
|
90
90
|
* ```
|
|
91
91
|
* @since v0.5.8
|
|
92
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
92
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/zlib.js)
|
|
93
93
|
*/
|
|
94
94
|
declare module "zlib" {
|
|
95
|
+
import { NonSharedBuffer } from "node:buffer";
|
|
95
96
|
import * as stream from "node:stream";
|
|
96
97
|
interface ZlibOptions {
|
|
97
98
|
/**
|
|
@@ -143,10 +144,14 @@ declare module "zlib" {
|
|
|
143
144
|
}
|
|
144
145
|
| undefined;
|
|
145
146
|
/**
|
|
146
|
-
* Limits output size when using [convenience methods](https://nodejs.org/docs/latest-
|
|
147
|
+
* Limits output size when using [convenience methods](https://nodejs.org/docs/latest-v24.x/api/zlib.html#convenience-methods).
|
|
147
148
|
* @default buffer.kMaxLength
|
|
148
149
|
*/
|
|
149
150
|
maxOutputLength?: number | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* If `true`, returns an object with `buffer` and `engine`.
|
|
153
|
+
*/
|
|
154
|
+
info?: boolean | undefined;
|
|
150
155
|
}
|
|
151
156
|
interface ZstdOptions {
|
|
152
157
|
/**
|
|
@@ -163,19 +168,27 @@ declare module "zlib" {
|
|
|
163
168
|
chunkSize?: number | undefined;
|
|
164
169
|
/**
|
|
165
170
|
* Key-value object containing indexed
|
|
166
|
-
* [Zstd parameters](https://nodejs.org/docs/latest-
|
|
171
|
+
* [Zstd parameters](https://nodejs.org/docs/latest-v24.x/api/zlib.html#zstd-constants).
|
|
167
172
|
*/
|
|
168
173
|
params?: { [key: number]: number | boolean } | undefined;
|
|
169
174
|
/**
|
|
170
175
|
* Limits output size when using
|
|
171
|
-
* [convenience methods](https://nodejs.org/docs/latest-
|
|
176
|
+
* [convenience methods](https://nodejs.org/docs/latest-v24.x/api/zlib.html#convenience-methods).
|
|
172
177
|
* @default buffer.kMaxLength
|
|
173
178
|
*/
|
|
174
179
|
maxOutputLength?: number | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* If `true`, returns an object with `buffer` and `engine`.
|
|
182
|
+
*/
|
|
183
|
+
info?: boolean | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Optional dictionary used to improve compression efficiency when compressing or decompressing data that
|
|
186
|
+
* shares common patterns with the dictionary.
|
|
187
|
+
* @since v24.6.0
|
|
188
|
+
*/
|
|
189
|
+
dictionary?: NodeJS.ArrayBufferView | undefined;
|
|
175
190
|
}
|
|
176
191
|
interface Zlib {
|
|
177
|
-
/** @deprecated Use bytesWritten instead. */
|
|
178
|
-
readonly bytesRead: number;
|
|
179
192
|
readonly bytesWritten: number;
|
|
180
193
|
shell?: boolean | string | undefined;
|
|
181
194
|
close(callback?: () => void): void;
|
|
@@ -215,7 +228,7 @@ declare module "zlib" {
|
|
|
215
228
|
* @returns A 32-bit unsigned integer containing the checksum.
|
|
216
229
|
* @since v22.2.0
|
|
217
230
|
*/
|
|
218
|
-
function crc32(data: string |
|
|
231
|
+
function crc32(data: string | NodeJS.ArrayBufferView, value?: number): number;
|
|
219
232
|
/**
|
|
220
233
|
* Creates and returns a new `BrotliCompress` object.
|
|
221
234
|
* @since v11.7.0, v10.16.0
|
|
@@ -279,124 +292,124 @@ declare module "zlib" {
|
|
|
279
292
|
*/
|
|
280
293
|
function createZstdDecompress(options?: ZstdOptions): ZstdDecompress;
|
|
281
294
|
type InputType = string | ArrayBuffer | NodeJS.ArrayBufferView;
|
|
282
|
-
type CompressCallback = (error: Error | null, result:
|
|
295
|
+
type CompressCallback = (error: Error | null, result: NonSharedBuffer) => void;
|
|
283
296
|
/**
|
|
284
297
|
* @since v11.7.0, v10.16.0
|
|
285
298
|
*/
|
|
286
299
|
function brotliCompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
|
|
287
300
|
function brotliCompress(buf: InputType, callback: CompressCallback): void;
|
|
288
301
|
namespace brotliCompress {
|
|
289
|
-
function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<
|
|
302
|
+
function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<NonSharedBuffer>;
|
|
290
303
|
}
|
|
291
304
|
/**
|
|
292
305
|
* Compress a chunk of data with `BrotliCompress`.
|
|
293
306
|
* @since v11.7.0, v10.16.0
|
|
294
307
|
*/
|
|
295
|
-
function brotliCompressSync(buf: InputType, options?: BrotliOptions):
|
|
308
|
+
function brotliCompressSync(buf: InputType, options?: BrotliOptions): NonSharedBuffer;
|
|
296
309
|
/**
|
|
297
310
|
* @since v11.7.0, v10.16.0
|
|
298
311
|
*/
|
|
299
312
|
function brotliDecompress(buf: InputType, options: BrotliOptions, callback: CompressCallback): void;
|
|
300
313
|
function brotliDecompress(buf: InputType, callback: CompressCallback): void;
|
|
301
314
|
namespace brotliDecompress {
|
|
302
|
-
function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<
|
|
315
|
+
function __promisify__(buffer: InputType, options?: BrotliOptions): Promise<NonSharedBuffer>;
|
|
303
316
|
}
|
|
304
317
|
/**
|
|
305
318
|
* Decompress a chunk of data with `BrotliDecompress`.
|
|
306
319
|
* @since v11.7.0, v10.16.0
|
|
307
320
|
*/
|
|
308
|
-
function brotliDecompressSync(buf: InputType, options?: BrotliOptions):
|
|
321
|
+
function brotliDecompressSync(buf: InputType, options?: BrotliOptions): NonSharedBuffer;
|
|
309
322
|
/**
|
|
310
323
|
* @since v0.6.0
|
|
311
324
|
*/
|
|
312
325
|
function deflate(buf: InputType, callback: CompressCallback): void;
|
|
313
326
|
function deflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
|
314
327
|
namespace deflate {
|
|
315
|
-
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<
|
|
328
|
+
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
|
|
316
329
|
}
|
|
317
330
|
/**
|
|
318
331
|
* Compress a chunk of data with `Deflate`.
|
|
319
332
|
* @since v0.11.12
|
|
320
333
|
*/
|
|
321
|
-
function deflateSync(buf: InputType, options?: ZlibOptions):
|
|
334
|
+
function deflateSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
|
|
322
335
|
/**
|
|
323
336
|
* @since v0.6.0
|
|
324
337
|
*/
|
|
325
338
|
function deflateRaw(buf: InputType, callback: CompressCallback): void;
|
|
326
339
|
function deflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
|
327
340
|
namespace deflateRaw {
|
|
328
|
-
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<
|
|
341
|
+
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
|
|
329
342
|
}
|
|
330
343
|
/**
|
|
331
344
|
* Compress a chunk of data with `DeflateRaw`.
|
|
332
345
|
* @since v0.11.12
|
|
333
346
|
*/
|
|
334
|
-
function deflateRawSync(buf: InputType, options?: ZlibOptions):
|
|
347
|
+
function deflateRawSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
|
|
335
348
|
/**
|
|
336
349
|
* @since v0.6.0
|
|
337
350
|
*/
|
|
338
351
|
function gzip(buf: InputType, callback: CompressCallback): void;
|
|
339
352
|
function gzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
|
340
353
|
namespace gzip {
|
|
341
|
-
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<
|
|
354
|
+
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
|
|
342
355
|
}
|
|
343
356
|
/**
|
|
344
357
|
* Compress a chunk of data with `Gzip`.
|
|
345
358
|
* @since v0.11.12
|
|
346
359
|
*/
|
|
347
|
-
function gzipSync(buf: InputType, options?: ZlibOptions):
|
|
360
|
+
function gzipSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
|
|
348
361
|
/**
|
|
349
362
|
* @since v0.6.0
|
|
350
363
|
*/
|
|
351
364
|
function gunzip(buf: InputType, callback: CompressCallback): void;
|
|
352
365
|
function gunzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
|
353
366
|
namespace gunzip {
|
|
354
|
-
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<
|
|
367
|
+
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
|
|
355
368
|
}
|
|
356
369
|
/**
|
|
357
370
|
* Decompress a chunk of data with `Gunzip`.
|
|
358
371
|
* @since v0.11.12
|
|
359
372
|
*/
|
|
360
|
-
function gunzipSync(buf: InputType, options?: ZlibOptions):
|
|
373
|
+
function gunzipSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
|
|
361
374
|
/**
|
|
362
375
|
* @since v0.6.0
|
|
363
376
|
*/
|
|
364
377
|
function inflate(buf: InputType, callback: CompressCallback): void;
|
|
365
378
|
function inflate(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
|
366
379
|
namespace inflate {
|
|
367
|
-
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<
|
|
380
|
+
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
|
|
368
381
|
}
|
|
369
382
|
/**
|
|
370
383
|
* Decompress a chunk of data with `Inflate`.
|
|
371
384
|
* @since v0.11.12
|
|
372
385
|
*/
|
|
373
|
-
function inflateSync(buf: InputType, options?: ZlibOptions):
|
|
386
|
+
function inflateSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
|
|
374
387
|
/**
|
|
375
388
|
* @since v0.6.0
|
|
376
389
|
*/
|
|
377
390
|
function inflateRaw(buf: InputType, callback: CompressCallback): void;
|
|
378
391
|
function inflateRaw(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
|
379
392
|
namespace inflateRaw {
|
|
380
|
-
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<
|
|
393
|
+
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
|
|
381
394
|
}
|
|
382
395
|
/**
|
|
383
396
|
* Decompress a chunk of data with `InflateRaw`.
|
|
384
397
|
* @since v0.11.12
|
|
385
398
|
*/
|
|
386
|
-
function inflateRawSync(buf: InputType, options?: ZlibOptions):
|
|
399
|
+
function inflateRawSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
|
|
387
400
|
/**
|
|
388
401
|
* @since v0.6.0
|
|
389
402
|
*/
|
|
390
403
|
function unzip(buf: InputType, callback: CompressCallback): void;
|
|
391
404
|
function unzip(buf: InputType, options: ZlibOptions, callback: CompressCallback): void;
|
|
392
405
|
namespace unzip {
|
|
393
|
-
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<
|
|
406
|
+
function __promisify__(buffer: InputType, options?: ZlibOptions): Promise<NonSharedBuffer>;
|
|
394
407
|
}
|
|
395
408
|
/**
|
|
396
409
|
* Decompress a chunk of data with `Unzip`.
|
|
397
410
|
* @since v0.11.12
|
|
398
411
|
*/
|
|
399
|
-
function unzipSync(buf: InputType, options?: ZlibOptions):
|
|
412
|
+
function unzipSync(buf: InputType, options?: ZlibOptions): NonSharedBuffer;
|
|
400
413
|
/**
|
|
401
414
|
* @since v22.15.0
|
|
402
415
|
* @experimental
|
|
@@ -404,14 +417,14 @@ declare module "zlib" {
|
|
|
404
417
|
function zstdCompress(buf: InputType, callback: CompressCallback): void;
|
|
405
418
|
function zstdCompress(buf: InputType, options: ZstdOptions, callback: CompressCallback): void;
|
|
406
419
|
namespace zstdCompress {
|
|
407
|
-
function __promisify__(buffer: InputType, options?: ZstdOptions): Promise<
|
|
420
|
+
function __promisify__(buffer: InputType, options?: ZstdOptions): Promise<NonSharedBuffer>;
|
|
408
421
|
}
|
|
409
422
|
/**
|
|
410
423
|
* Compress a chunk of data with `ZstdCompress`.
|
|
411
424
|
* @since v22.15.0
|
|
412
425
|
* @experimental
|
|
413
426
|
*/
|
|
414
|
-
function zstdCompressSync(buf: InputType, options?: ZstdOptions):
|
|
427
|
+
function zstdCompressSync(buf: InputType, options?: ZstdOptions): NonSharedBuffer;
|
|
415
428
|
/**
|
|
416
429
|
* @since v22.15.0
|
|
417
430
|
* @experimental
|
|
@@ -419,14 +432,14 @@ declare module "zlib" {
|
|
|
419
432
|
function zstdDecompress(buf: InputType, callback: CompressCallback): void;
|
|
420
433
|
function zstdDecompress(buf: InputType, options: ZstdOptions, callback: CompressCallback): void;
|
|
421
434
|
namespace zstdDecompress {
|
|
422
|
-
function __promisify__(buffer: InputType, options?: ZstdOptions): Promise<
|
|
435
|
+
function __promisify__(buffer: InputType, options?: ZstdOptions): Promise<NonSharedBuffer>;
|
|
423
436
|
}
|
|
424
437
|
/**
|
|
425
438
|
* Decompress a chunk of data with `ZstdDecompress`.
|
|
426
439
|
* @since v22.15.0
|
|
427
440
|
* @experimental
|
|
428
441
|
*/
|
|
429
|
-
function zstdDecompressSync(buf: InputType, options?: ZstdOptions):
|
|
442
|
+
function zstdDecompressSync(buf: InputType, options?: ZstdOptions): NonSharedBuffer;
|
|
430
443
|
namespace constants {
|
|
431
444
|
const BROTLI_DECODE: number;
|
|
432
445
|
const BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: number;
|
|
@@ -612,8 +625,6 @@ declare module "zlib" {
|
|
|
612
625
|
const Z_FINISH: number;
|
|
613
626
|
/** @deprecated Use `constants.Z_BLOCK` */
|
|
614
627
|
const Z_BLOCK: number;
|
|
615
|
-
/** @deprecated Use `constants.Z_TREES` */
|
|
616
|
-
const Z_TREES: number;
|
|
617
628
|
// Return codes for the compression/decompression functions.
|
|
618
629
|
// Negative values are errors, positive values are used for special but normal events.
|
|
619
630
|
/** @deprecated Use `constants.Z_OK` */
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// Polyfills for the explicit resource management types added in TypeScript 5.2.
|
|
2
|
-
// TODO: remove once this package no longer supports TS 5.1, and replace with a
|
|
3
|
-
// <reference> to TypeScript's disposable library in index.d.ts.
|
|
4
|
-
|
|
5
|
-
interface SymbolConstructor {
|
|
6
|
-
readonly dispose: unique symbol;
|
|
7
|
-
readonly asyncDispose: unique symbol;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface Disposable {
|
|
11
|
-
[Symbol.dispose](): void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface AsyncDisposable {
|
|
15
|
-
[Symbol.asyncDispose](): PromiseLike<void>;
|
|
16
|
-
}
|
node/compatibility/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Declaration files in this directory contain types relating to TypeScript library features
|
|
2
|
-
// that are not included in all TypeScript versions supported by DefinitelyTyped, but
|
|
3
|
-
// which can be made backwards-compatible without needing `typesVersions`.
|
|
4
|
-
// If adding declarations to this directory, please specify which versions of TypeScript require them,
|
|
5
|
-
// so that they can be removed when no longer needed.
|
|
6
|
-
|
|
7
|
-
/// <reference path="disposable.d.ts" />
|
|
8
|
-
/// <reference path="indexable.d.ts" />
|
|
9
|
-
/// <reference path="iterators.d.ts" />
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Polyfill for ES2022's .at() method on string/array prototypes, added to TypeScript in 4.6.
|
|
2
|
-
// TODO: these methods are not used within @types/node, and should be removed at the next
|
|
3
|
-
// major @types/node version; users should include the es2022 TypeScript libraries
|
|
4
|
-
// if they need these features.
|
|
5
|
-
|
|
6
|
-
interface RelativeIndexable<T> {
|
|
7
|
-
at(index: number): T | undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface String extends RelativeIndexable<string> {}
|
|
11
|
-
interface Array<T> extends RelativeIndexable<T> {}
|
|
12
|
-
interface ReadonlyArray<T> extends RelativeIndexable<T> {}
|
|
13
|
-
interface Int8Array extends RelativeIndexable<number> {}
|
|
14
|
-
interface Uint8Array extends RelativeIndexable<number> {}
|
|
15
|
-
interface Uint8ClampedArray extends RelativeIndexable<number> {}
|
|
16
|
-
interface Int16Array extends RelativeIndexable<number> {}
|
|
17
|
-
interface Uint16Array extends RelativeIndexable<number> {}
|
|
18
|
-
interface Int32Array extends RelativeIndexable<number> {}
|
|
19
|
-
interface Uint32Array extends RelativeIndexable<number> {}
|
|
20
|
-
interface Float32Array extends RelativeIndexable<number> {}
|
|
21
|
-
interface Float64Array extends RelativeIndexable<number> {}
|
|
22
|
-
interface BigInt64Array extends RelativeIndexable<bigint> {}
|
|
23
|
-
interface BigUint64Array extends RelativeIndexable<bigint> {}
|
node/dom-events.d.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
export {}; // Don't export anything!
|
|
2
|
-
|
|
3
|
-
//// DOM-like Events
|
|
4
|
-
// NB: The Event / EventTarget / EventListener implementations below were copied
|
|
5
|
-
// from lib.dom.d.ts, then edited to reflect Node's documentation at
|
|
6
|
-
// https://nodejs.org/api/events.html#class-eventtarget.
|
|
7
|
-
// Please read that link to understand important implementation differences.
|
|
8
|
-
|
|
9
|
-
// This conditional type will be the existing global Event in a browser, or
|
|
10
|
-
// the copy below in a Node environment.
|
|
11
|
-
type __Event = typeof globalThis extends { onmessage: any; Event: any } ? {}
|
|
12
|
-
: {
|
|
13
|
-
/** This is not used in Node.js and is provided purely for completeness. */
|
|
14
|
-
readonly bubbles: boolean;
|
|
15
|
-
/** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */
|
|
16
|
-
cancelBubble: () => void;
|
|
17
|
-
/** True if the event was created with the cancelable option */
|
|
18
|
-
readonly cancelable: boolean;
|
|
19
|
-
/** This is not used in Node.js and is provided purely for completeness. */
|
|
20
|
-
readonly composed: boolean;
|
|
21
|
-
/** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */
|
|
22
|
-
composedPath(): [EventTarget?];
|
|
23
|
-
/** Alias for event.target. */
|
|
24
|
-
readonly currentTarget: EventTarget | null;
|
|
25
|
-
/** Is true if cancelable is true and event.preventDefault() has been called. */
|
|
26
|
-
readonly defaultPrevented: boolean;
|
|
27
|
-
/** This is not used in Node.js and is provided purely for completeness. */
|
|
28
|
-
readonly eventPhase: 0 | 2;
|
|
29
|
-
/** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */
|
|
30
|
-
readonly isTrusted: boolean;
|
|
31
|
-
/** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */
|
|
32
|
-
preventDefault(): void;
|
|
33
|
-
/** This is not used in Node.js and is provided purely for completeness. */
|
|
34
|
-
returnValue: boolean;
|
|
35
|
-
/** Alias for event.target. */
|
|
36
|
-
readonly srcElement: EventTarget | null;
|
|
37
|
-
/** Stops the invocation of event listeners after the current one completes. */
|
|
38
|
-
stopImmediatePropagation(): void;
|
|
39
|
-
/** This is not used in Node.js and is provided purely for completeness. */
|
|
40
|
-
stopPropagation(): void;
|
|
41
|
-
/** The `EventTarget` dispatching the event */
|
|
42
|
-
readonly target: EventTarget | null;
|
|
43
|
-
/** The millisecond timestamp when the Event object was created. */
|
|
44
|
-
readonly timeStamp: number;
|
|
45
|
-
/** Returns the type of event, e.g. "click", "hashchange", or "submit". */
|
|
46
|
-
readonly type: string;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// See comment above explaining conditional type
|
|
50
|
-
type __EventTarget = typeof globalThis extends { onmessage: any; EventTarget: any } ? {}
|
|
51
|
-
: {
|
|
52
|
-
/**
|
|
53
|
-
* Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value.
|
|
54
|
-
*
|
|
55
|
-
* If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched.
|
|
56
|
-
*
|
|
57
|
-
* The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification.
|
|
58
|
-
* Specifically, the `capture` option is used as part of the key when registering a `listener`.
|
|
59
|
-
* Any individual `listener` may be added once with `capture = false`, and once with `capture = true`.
|
|
60
|
-
*/
|
|
61
|
-
addEventListener(
|
|
62
|
-
type: string,
|
|
63
|
-
listener: EventListener | EventListenerObject,
|
|
64
|
-
options?: AddEventListenerOptions | boolean,
|
|
65
|
-
): void;
|
|
66
|
-
/** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */
|
|
67
|
-
dispatchEvent(event: Event): boolean;
|
|
68
|
-
/** Removes the event listener in target's event listener list with the same type, callback, and options. */
|
|
69
|
-
removeEventListener(
|
|
70
|
-
type: string,
|
|
71
|
-
listener: EventListener | EventListenerObject,
|
|
72
|
-
options?: EventListenerOptions | boolean,
|
|
73
|
-
): void;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
interface EventInit {
|
|
77
|
-
bubbles?: boolean;
|
|
78
|
-
cancelable?: boolean;
|
|
79
|
-
composed?: boolean;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
interface EventListenerOptions {
|
|
83
|
-
/** Not directly used by Node.js. Added for API completeness. Default: `false`. */
|
|
84
|
-
capture?: boolean;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
interface AddEventListenerOptions extends EventListenerOptions {
|
|
88
|
-
/** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
|
|
89
|
-
once?: boolean;
|
|
90
|
-
/** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
|
|
91
|
-
passive?: boolean;
|
|
92
|
-
/** The listener will be removed when the given AbortSignal object's `abort()` method is called. */
|
|
93
|
-
signal?: AbortSignal;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
interface EventListener {
|
|
97
|
-
(evt: Event): void;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
interface EventListenerObject {
|
|
101
|
-
handleEvent(object: Event): void;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
import {} from "events"; // Make this an ambient declaration
|
|
105
|
-
declare global {
|
|
106
|
-
/** An event which takes place in the DOM. */
|
|
107
|
-
interface Event extends __Event {}
|
|
108
|
-
var Event: typeof globalThis extends { onmessage: any; Event: infer T } ? T
|
|
109
|
-
: {
|
|
110
|
-
prototype: __Event;
|
|
111
|
-
new(type: string, eventInitDict?: EventInit): __Event;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* EventTarget is a DOM interface implemented by objects that can
|
|
116
|
-
* receive events and may have listeners for them.
|
|
117
|
-
*/
|
|
118
|
-
interface EventTarget extends __EventTarget {}
|
|
119
|
-
var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T
|
|
120
|
-
: {
|
|
121
|
-
prototype: __EventTarget;
|
|
122
|
-
new(): __EventTarget;
|
|
123
|
-
};
|
|
124
|
-
}
|