@types/node 16.18.83 → 16.18.85
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 v16.18/README.md +1 -1
- node v16.18/events.d.ts +34 -18
- node v16.18/package.json +2 -2
- node v16.18/ts4.8/events.d.ts +34 -18
node v16.18/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
|
|
|
8
8
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v16.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Wed, 28 Feb 2024 17:35:47 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
|
|
14
14
|
# Credits
|
node v16.18/events.d.ts
CHANGED
|
@@ -58,7 +58,23 @@ declare module "events" {
|
|
|
58
58
|
interface StaticEventEmitterOptions {
|
|
59
59
|
signal?: AbortSignal | undefined;
|
|
60
60
|
}
|
|
61
|
-
interface EventEmitter extends NodeJS.EventEmitter {}
|
|
61
|
+
interface EventEmitter<T extends EventMap<T> = DefaultEventMap> extends NodeJS.EventEmitter<T> {}
|
|
62
|
+
type EventMap<T> = Record<keyof T, any[]> | DefaultEventMap;
|
|
63
|
+
type DefaultEventMap = [never];
|
|
64
|
+
type AnyRest = [...args: any[]];
|
|
65
|
+
type Args<K, T> = T extends DefaultEventMap ? AnyRest : (
|
|
66
|
+
K extends keyof T ? T[K] : never
|
|
67
|
+
);
|
|
68
|
+
type Key<K, T> = T extends DefaultEventMap ? string | symbol : K | keyof T;
|
|
69
|
+
type Key2<K, T> = T extends DefaultEventMap ? string | symbol : K & keyof T;
|
|
70
|
+
type Listener<K, T, F> = T extends DefaultEventMap ? F : (
|
|
71
|
+
K extends keyof T ? (
|
|
72
|
+
T[K] extends unknown[] ? (...args: T[K]) => void : never
|
|
73
|
+
)
|
|
74
|
+
: never
|
|
75
|
+
);
|
|
76
|
+
type Listener1<K, T> = Listener<K, T, (...args: any[]) => void>;
|
|
77
|
+
type Listener2<K, T> = Listener<K, T, Function>;
|
|
62
78
|
/**
|
|
63
79
|
* The `EventEmitter` class is defined and exposed by the `events` module:
|
|
64
80
|
*
|
|
@@ -72,10 +88,10 @@ declare module "events" {
|
|
|
72
88
|
* It supports the following option:
|
|
73
89
|
* @since v0.1.26
|
|
74
90
|
*/
|
|
75
|
-
class EventEmitter {
|
|
91
|
+
class EventEmitter<T extends EventMap<T> = DefaultEventMap> {
|
|
76
92
|
constructor(options?: EventEmitterOptions);
|
|
77
93
|
|
|
78
|
-
[EventEmitter.captureRejectionSymbol]
|
|
94
|
+
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
|
|
79
95
|
|
|
80
96
|
/**
|
|
81
97
|
* Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
|
|
@@ -365,13 +381,13 @@ declare module "events" {
|
|
|
365
381
|
}
|
|
366
382
|
global {
|
|
367
383
|
namespace NodeJS {
|
|
368
|
-
interface EventEmitter {
|
|
369
|
-
[EventEmitter.captureRejectionSymbol]
|
|
384
|
+
interface EventEmitter<T extends EventMap<T> = DefaultEventMap> {
|
|
385
|
+
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
|
|
370
386
|
/**
|
|
371
387
|
* Alias for `emitter.on(eventName, listener)`.
|
|
372
388
|
* @since v0.1.26
|
|
373
389
|
*/
|
|
374
|
-
addListener(eventName:
|
|
390
|
+
addListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
375
391
|
/**
|
|
376
392
|
* Adds the `listener` function to the end of the listeners array for the
|
|
377
393
|
* event named `eventName`. No checks are made to see if the `listener` has
|
|
@@ -402,7 +418,7 @@ declare module "events" {
|
|
|
402
418
|
* @param eventName The name of the event.
|
|
403
419
|
* @param listener The callback function
|
|
404
420
|
*/
|
|
405
|
-
on(eventName:
|
|
421
|
+
on<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
406
422
|
/**
|
|
407
423
|
* Adds a **one-time**`listener` function for the event named `eventName`. The
|
|
408
424
|
* next time `eventName` is triggered, this listener is removed and then invoked.
|
|
@@ -431,7 +447,7 @@ declare module "events" {
|
|
|
431
447
|
* @param eventName The name of the event.
|
|
432
448
|
* @param listener The callback function
|
|
433
449
|
*/
|
|
434
|
-
once(eventName:
|
|
450
|
+
once<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
435
451
|
/**
|
|
436
452
|
* Removes the specified `listener` from the listener array for the event named`eventName`.
|
|
437
453
|
*
|
|
@@ -511,12 +527,12 @@ declare module "events" {
|
|
|
511
527
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
512
528
|
* @since v0.1.26
|
|
513
529
|
*/
|
|
514
|
-
removeListener(eventName:
|
|
530
|
+
removeListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
515
531
|
/**
|
|
516
532
|
* Alias for `emitter.removeListener()`.
|
|
517
533
|
* @since v10.0.0
|
|
518
534
|
*/
|
|
519
|
-
off(eventName:
|
|
535
|
+
off<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
520
536
|
/**
|
|
521
537
|
* Removes all listeners, or those of the specified `eventName`.
|
|
522
538
|
*
|
|
@@ -527,7 +543,7 @@ declare module "events" {
|
|
|
527
543
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
528
544
|
* @since v0.1.26
|
|
529
545
|
*/
|
|
530
|
-
removeAllListeners(event?:
|
|
546
|
+
removeAllListeners(event?: Key<unknown, T>): this;
|
|
531
547
|
/**
|
|
532
548
|
* By default `EventEmitter`s will print a warning if more than `10` listeners are
|
|
533
549
|
* added for a particular event. This is a useful default that helps finding
|
|
@@ -556,7 +572,7 @@ declare module "events" {
|
|
|
556
572
|
* ```
|
|
557
573
|
* @since v0.1.26
|
|
558
574
|
*/
|
|
559
|
-
listeners(eventName:
|
|
575
|
+
listeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
|
|
560
576
|
/**
|
|
561
577
|
* Returns a copy of the array of listeners for the event named `eventName`,
|
|
562
578
|
* including any wrappers (such as those created by `.once()`).
|
|
@@ -586,7 +602,7 @@ declare module "events" {
|
|
|
586
602
|
* ```
|
|
587
603
|
* @since v9.4.0
|
|
588
604
|
*/
|
|
589
|
-
rawListeners(eventName:
|
|
605
|
+
rawListeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
|
|
590
606
|
/**
|
|
591
607
|
* Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
|
|
592
608
|
* to each.
|
|
@@ -627,13 +643,13 @@ declare module "events" {
|
|
|
627
643
|
* ```
|
|
628
644
|
* @since v0.1.26
|
|
629
645
|
*/
|
|
630
|
-
emit(eventName:
|
|
646
|
+
emit<K>(eventName: Key<K, T>, ...args: Args<K, T>): boolean;
|
|
631
647
|
/**
|
|
632
648
|
* Returns the number of listeners listening to the event named `eventName`.
|
|
633
649
|
* @since v3.2.0
|
|
634
650
|
* @param eventName The name of the event being listened for
|
|
635
651
|
*/
|
|
636
|
-
listenerCount(eventName:
|
|
652
|
+
listenerCount<K>(eventName: Key<K, T>, listener?: Listener2<K, T>): number;
|
|
637
653
|
/**
|
|
638
654
|
* Adds the `listener` function to the _beginning_ of the listeners array for the
|
|
639
655
|
* event named `eventName`. No checks are made to see if the `listener` has
|
|
@@ -651,7 +667,7 @@ declare module "events" {
|
|
|
651
667
|
* @param eventName The name of the event.
|
|
652
668
|
* @param listener The callback function
|
|
653
669
|
*/
|
|
654
|
-
prependListener(eventName:
|
|
670
|
+
prependListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
655
671
|
/**
|
|
656
672
|
* Adds a **one-time**`listener` function for the event named `eventName` to the_beginning_ of the listeners array. The next time `eventName` is triggered, this
|
|
657
673
|
* listener is removed, and then invoked.
|
|
@@ -667,7 +683,7 @@ declare module "events" {
|
|
|
667
683
|
* @param eventName The name of the event.
|
|
668
684
|
* @param listener The callback function
|
|
669
685
|
*/
|
|
670
|
-
prependOnceListener(eventName:
|
|
686
|
+
prependOnceListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
671
687
|
/**
|
|
672
688
|
* Returns an array listing the events for which the emitter has registered
|
|
673
689
|
* listeners. The values in the array are strings or `Symbol`s.
|
|
@@ -686,7 +702,7 @@ declare module "events" {
|
|
|
686
702
|
* ```
|
|
687
703
|
* @since v6.0.0
|
|
688
704
|
*/
|
|
689
|
-
eventNames(): Array<string | symbol
|
|
705
|
+
eventNames(): Array<(string | symbol) & Key2<unknown, T>>;
|
|
690
706
|
}
|
|
691
707
|
}
|
|
692
708
|
}
|
node v16.18/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "16.18.
|
|
3
|
+
"version": "16.18.85",
|
|
4
4
|
"description": "TypeScript definitions for node",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -222,6 +222,6 @@
|
|
|
222
222
|
},
|
|
223
223
|
"scripts": {},
|
|
224
224
|
"dependencies": {},
|
|
225
|
-
"typesPublisherContentHash": "
|
|
225
|
+
"typesPublisherContentHash": "fb871ad20cc1ac5a93082e9910ca411338256e85d7b6eee8fb6a92175f6883fd",
|
|
226
226
|
"typeScriptVersion": "4.6"
|
|
227
227
|
}
|
node v16.18/ts4.8/events.d.ts
CHANGED
|
@@ -58,7 +58,23 @@ declare module "events" {
|
|
|
58
58
|
interface StaticEventEmitterOptions {
|
|
59
59
|
signal?: AbortSignal | undefined;
|
|
60
60
|
}
|
|
61
|
-
interface EventEmitter extends NodeJS.EventEmitter {}
|
|
61
|
+
interface EventEmitter<T extends EventMap<T> = DefaultEventMap> extends NodeJS.EventEmitter<T> {}
|
|
62
|
+
type EventMap<T> = Record<keyof T, any[]> | DefaultEventMap;
|
|
63
|
+
type DefaultEventMap = [never];
|
|
64
|
+
type AnyRest = [...args: any[]];
|
|
65
|
+
type Args<K, T> = T extends DefaultEventMap ? AnyRest : (
|
|
66
|
+
K extends keyof T ? T[K] : never
|
|
67
|
+
);
|
|
68
|
+
type Key<K, T> = T extends DefaultEventMap ? string | symbol : K | keyof T;
|
|
69
|
+
type Key2<K, T> = T extends DefaultEventMap ? string | symbol : K & keyof T;
|
|
70
|
+
type Listener<K, T, F> = T extends DefaultEventMap ? F : (
|
|
71
|
+
K extends keyof T ? (
|
|
72
|
+
T[K] extends unknown[] ? (...args: T[K]) => void : never
|
|
73
|
+
)
|
|
74
|
+
: never
|
|
75
|
+
);
|
|
76
|
+
type Listener1<K, T> = Listener<K, T, (...args: any[]) => void>;
|
|
77
|
+
type Listener2<K, T> = Listener<K, T, Function>;
|
|
62
78
|
/**
|
|
63
79
|
* The `EventEmitter` class is defined and exposed by the `events` module:
|
|
64
80
|
*
|
|
@@ -72,10 +88,10 @@ declare module "events" {
|
|
|
72
88
|
* It supports the following option:
|
|
73
89
|
* @since v0.1.26
|
|
74
90
|
*/
|
|
75
|
-
class EventEmitter {
|
|
91
|
+
class EventEmitter<T extends EventMap<T> = DefaultEventMap> {
|
|
76
92
|
constructor(options?: EventEmitterOptions);
|
|
77
93
|
|
|
78
|
-
[EventEmitter.captureRejectionSymbol]
|
|
94
|
+
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
|
|
79
95
|
|
|
80
96
|
/**
|
|
81
97
|
* Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
|
|
@@ -365,13 +381,13 @@ declare module "events" {
|
|
|
365
381
|
}
|
|
366
382
|
global {
|
|
367
383
|
namespace NodeJS {
|
|
368
|
-
interface EventEmitter {
|
|
369
|
-
[EventEmitter.captureRejectionSymbol]
|
|
384
|
+
interface EventEmitter<T extends EventMap<T> = DefaultEventMap> {
|
|
385
|
+
[EventEmitter.captureRejectionSymbol]?<K>(error: Error, event: Key<K, T>, ...args: Args<K, T>): void;
|
|
370
386
|
/**
|
|
371
387
|
* Alias for `emitter.on(eventName, listener)`.
|
|
372
388
|
* @since v0.1.26
|
|
373
389
|
*/
|
|
374
|
-
addListener(eventName:
|
|
390
|
+
addListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
375
391
|
/**
|
|
376
392
|
* Adds the `listener` function to the end of the listeners array for the
|
|
377
393
|
* event named `eventName`. No checks are made to see if the `listener` has
|
|
@@ -402,7 +418,7 @@ declare module "events" {
|
|
|
402
418
|
* @param eventName The name of the event.
|
|
403
419
|
* @param listener The callback function
|
|
404
420
|
*/
|
|
405
|
-
on(eventName:
|
|
421
|
+
on<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
406
422
|
/**
|
|
407
423
|
* Adds a **one-time**`listener` function for the event named `eventName`. The
|
|
408
424
|
* next time `eventName` is triggered, this listener is removed and then invoked.
|
|
@@ -431,7 +447,7 @@ declare module "events" {
|
|
|
431
447
|
* @param eventName The name of the event.
|
|
432
448
|
* @param listener The callback function
|
|
433
449
|
*/
|
|
434
|
-
once(eventName:
|
|
450
|
+
once<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
435
451
|
/**
|
|
436
452
|
* Removes the specified `listener` from the listener array for the event named`eventName`.
|
|
437
453
|
*
|
|
@@ -511,12 +527,12 @@ declare module "events" {
|
|
|
511
527
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
512
528
|
* @since v0.1.26
|
|
513
529
|
*/
|
|
514
|
-
removeListener(eventName:
|
|
530
|
+
removeListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
515
531
|
/**
|
|
516
532
|
* Alias for `emitter.removeListener()`.
|
|
517
533
|
* @since v10.0.0
|
|
518
534
|
*/
|
|
519
|
-
off(eventName:
|
|
535
|
+
off<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
520
536
|
/**
|
|
521
537
|
* Removes all listeners, or those of the specified `eventName`.
|
|
522
538
|
*
|
|
@@ -527,7 +543,7 @@ declare module "events" {
|
|
|
527
543
|
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
|
528
544
|
* @since v0.1.26
|
|
529
545
|
*/
|
|
530
|
-
removeAllListeners(event?:
|
|
546
|
+
removeAllListeners(event?: Key<unknown, T>): this;
|
|
531
547
|
/**
|
|
532
548
|
* By default `EventEmitter`s will print a warning if more than `10` listeners are
|
|
533
549
|
* added for a particular event. This is a useful default that helps finding
|
|
@@ -556,7 +572,7 @@ declare module "events" {
|
|
|
556
572
|
* ```
|
|
557
573
|
* @since v0.1.26
|
|
558
574
|
*/
|
|
559
|
-
listeners(eventName:
|
|
575
|
+
listeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
|
|
560
576
|
/**
|
|
561
577
|
* Returns a copy of the array of listeners for the event named `eventName`,
|
|
562
578
|
* including any wrappers (such as those created by `.once()`).
|
|
@@ -586,7 +602,7 @@ declare module "events" {
|
|
|
586
602
|
* ```
|
|
587
603
|
* @since v9.4.0
|
|
588
604
|
*/
|
|
589
|
-
rawListeners(eventName:
|
|
605
|
+
rawListeners<K>(eventName: Key<K, T>): Array<Listener2<K, T>>;
|
|
590
606
|
/**
|
|
591
607
|
* Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
|
|
592
608
|
* to each.
|
|
@@ -627,13 +643,13 @@ declare module "events" {
|
|
|
627
643
|
* ```
|
|
628
644
|
* @since v0.1.26
|
|
629
645
|
*/
|
|
630
|
-
emit(eventName:
|
|
646
|
+
emit<K>(eventName: Key<K, T>, ...args: Args<K, T>): boolean;
|
|
631
647
|
/**
|
|
632
648
|
* Returns the number of listeners listening to the event named `eventName`.
|
|
633
649
|
* @since v3.2.0
|
|
634
650
|
* @param eventName The name of the event being listened for
|
|
635
651
|
*/
|
|
636
|
-
listenerCount(eventName:
|
|
652
|
+
listenerCount<K>(eventName: Key<K, T>, listener?: Listener2<K, T>): number;
|
|
637
653
|
/**
|
|
638
654
|
* Adds the `listener` function to the _beginning_ of the listeners array for the
|
|
639
655
|
* event named `eventName`. No checks are made to see if the `listener` has
|
|
@@ -651,7 +667,7 @@ declare module "events" {
|
|
|
651
667
|
* @param eventName The name of the event.
|
|
652
668
|
* @param listener The callback function
|
|
653
669
|
*/
|
|
654
|
-
prependListener(eventName:
|
|
670
|
+
prependListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
655
671
|
/**
|
|
656
672
|
* Adds a **one-time**`listener` function for the event named `eventName` to the_beginning_ of the listeners array. The next time `eventName` is triggered, this
|
|
657
673
|
* listener is removed, and then invoked.
|
|
@@ -667,7 +683,7 @@ declare module "events" {
|
|
|
667
683
|
* @param eventName The name of the event.
|
|
668
684
|
* @param listener The callback function
|
|
669
685
|
*/
|
|
670
|
-
prependOnceListener(eventName:
|
|
686
|
+
prependOnceListener<K>(eventName: Key<K, T>, listener: Listener1<K, T>): this;
|
|
671
687
|
/**
|
|
672
688
|
* Returns an array listing the events for which the emitter has registered
|
|
673
689
|
* listeners. The values in the array are strings or `Symbol`s.
|
|
@@ -686,7 +702,7 @@ declare module "events" {
|
|
|
686
702
|
* ```
|
|
687
703
|
* @since v6.0.0
|
|
688
704
|
*/
|
|
689
|
-
eventNames(): Array<string | symbol
|
|
705
|
+
eventNames(): Array<(string | symbol) & Key2<unknown, T>>;
|
|
690
706
|
}
|
|
691
707
|
}
|
|
692
708
|
}
|