@types/node 16.18.71 → 16.18.73

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 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: Mon, 15 Jan 2024 04:07:53 GMT
11
+ * Last updated: Fri, 19 Jan 2024 21:07:03 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
@@ -0,0 +1,122 @@
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
+ }
93
+
94
+ interface EventListener {
95
+ (evt: Event): void;
96
+ }
97
+
98
+ interface EventListenerObject {
99
+ handleEvent(object: Event): void;
100
+ }
101
+
102
+ import {} from "events"; // Make this an ambient declaration
103
+ declare global {
104
+ /** An event which takes place in the DOM. */
105
+ interface Event extends __Event {}
106
+ var Event: typeof globalThis extends { onmessage: any; Event: infer T } ? T
107
+ : {
108
+ prototype: __Event;
109
+ new(type: string, eventInitDict?: EventInit): __Event;
110
+ };
111
+
112
+ /**
113
+ * EventTarget is a DOM interface implemented by objects that can
114
+ * receive events and may have listeners for them.
115
+ */
116
+ interface EventTarget extends __EventTarget {}
117
+ var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T
118
+ : {
119
+ prototype: __EventTarget;
120
+ new(): __EventTarget;
121
+ };
122
+ }
@@ -57,25 +57,29 @@ interface AbortController {
57
57
  }
58
58
 
59
59
  /** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
60
- interface AbortSignal {
60
+ interface AbortSignal extends EventTarget {
61
61
  /**
62
62
  * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
63
63
  */
64
64
  readonly aborted: boolean;
65
65
  readonly reason: any;
66
+ onabort: null | ((this: AbortSignal, event: Event) => any);
67
+ throwIfAborted(): void;
66
68
  }
67
69
 
68
- declare var AbortController: {
69
- prototype: AbortController;
70
- new(): AbortController;
71
- };
72
-
73
- declare var AbortSignal: {
74
- prototype: AbortSignal;
75
- new(): AbortSignal;
76
- abort(reason?: any): AbortSignal;
77
- timeout(milliseconds: number): AbortSignal;
78
- };
70
+ declare var AbortController: typeof globalThis extends { onmessage: any; AbortController: infer T } ? T
71
+ : {
72
+ prototype: AbortController;
73
+ new(): AbortController;
74
+ };
75
+
76
+ declare var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal: infer T } ? T
77
+ : {
78
+ prototype: AbortSignal;
79
+ new(): AbortSignal;
80
+ abort(reason?: any): AbortSignal;
81
+ timeout(milliseconds: number): AbortSignal;
82
+ };
79
83
  // #endregion borrowed
80
84
 
81
85
  // #region ArrayLike.at()
node v16.18/index.d.ts CHANGED
@@ -45,7 +45,7 @@
45
45
  /// <reference path="diagnostics_channel.d.ts" />
46
46
  /// <reference path="dns.d.ts" />
47
47
  /// <reference path="dns/promises.d.ts" />
48
- /// <reference path="dns/promises.d.ts" />
48
+ /// <reference path="dom-events.d.ts" />
49
49
  /// <reference path="domain.d.ts" />
50
50
  /// <reference path="events.d.ts" />
51
51
  /// <reference path="fs.d.ts" />
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "16.18.71",
3
+ "version": "16.18.73",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -222,7 +222,7 @@
222
222
  },
223
223
  "scripts": {},
224
224
  "dependencies": {},
225
- "typesPublisherContentHash": "408c5b0e2936344d0ce7cecbea35013d99c9c3831649e625c736a618136d4e69",
225
+ "typesPublisherContentHash": "b67615e4b4f22ffadeb3291a219e642d13721b33c2a3e27996c8a691932f6a9e",
226
226
  "typeScriptVersion": "4.6",
227
227
  "nonNpm": true
228
228
  }
@@ -0,0 +1,122 @@
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
+ }
93
+
94
+ interface EventListener {
95
+ (evt: Event): void;
96
+ }
97
+
98
+ interface EventListenerObject {
99
+ handleEvent(object: Event): void;
100
+ }
101
+
102
+ import {} from "events"; // Make this an ambient declaration
103
+ declare global {
104
+ /** An event which takes place in the DOM. */
105
+ interface Event extends __Event {}
106
+ var Event: typeof globalThis extends { onmessage: any; Event: infer T } ? T
107
+ : {
108
+ prototype: __Event;
109
+ new(type: string, eventInitDict?: EventInit): __Event;
110
+ };
111
+
112
+ /**
113
+ * EventTarget is a DOM interface implemented by objects that can
114
+ * receive events and may have listeners for them.
115
+ */
116
+ interface EventTarget extends __EventTarget {}
117
+ var EventTarget: typeof globalThis extends { onmessage: any; EventTarget: infer T } ? T
118
+ : {
119
+ prototype: __EventTarget;
120
+ new(): __EventTarget;
121
+ };
122
+ }
@@ -57,23 +57,29 @@ interface AbortController {
57
57
  }
58
58
 
59
59
  /** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
60
- interface AbortSignal {
60
+ interface AbortSignal extends EventTarget {
61
61
  /**
62
62
  * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
63
63
  */
64
64
  readonly aborted: boolean;
65
+ readonly reason: any;
66
+ onabort: null | ((this: AbortSignal, event: Event) => any);
67
+ throwIfAborted(): void;
65
68
  }
66
69
 
67
- declare var AbortController: {
68
- prototype: AbortController;
69
- new(): AbortController;
70
- };
71
-
72
- declare var AbortSignal: {
73
- prototype: AbortSignal;
74
- new(): AbortSignal;
75
- // TODO: Add abort() static
76
- };
70
+ declare var AbortController: typeof globalThis extends { onmessage: any; AbortController: infer T } ? T
71
+ : {
72
+ prototype: AbortController;
73
+ new(): AbortController;
74
+ };
75
+
76
+ declare var AbortSignal: typeof globalThis extends { onmessage: any; AbortSignal: infer T } ? T
77
+ : {
78
+ prototype: AbortSignal;
79
+ new(): AbortSignal;
80
+ abort(reason?: any): AbortSignal;
81
+ timeout(milliseconds: number): AbortSignal;
82
+ };
77
83
  // #endregion borrowed
78
84
 
79
85
  // #region ArrayLike.at()
@@ -87,6 +93,7 @@ interface RelativeIndexable<T> {
87
93
  }
88
94
  interface String extends RelativeIndexable<string> {}
89
95
  interface Array<T> extends RelativeIndexable<T> {}
96
+ interface ReadonlyArray<T> extends RelativeIndexable<T> {}
90
97
  interface Int8Array extends RelativeIndexable<number> {}
91
98
  interface Uint8Array extends RelativeIndexable<number> {}
92
99
  interface Uint8ClampedArray extends RelativeIndexable<number> {}
@@ -141,7 +148,7 @@ declare namespace NodeJS {
141
148
  /**
142
149
  * Name of the script [if this function was defined in a script]
143
150
  */
144
- getFileName(): string | null;
151
+ getFileName(): string | undefined;
145
152
 
146
153
  /**
147
154
  * Current line number [if this function was defined in a script]
@@ -45,7 +45,7 @@
45
45
  /// <reference path="diagnostics_channel.d.ts" />
46
46
  /// <reference path="dns.d.ts" />
47
47
  /// <reference path="dns/promises.d.ts" />
48
- /// <reference path="dns/promises.d.ts" />
48
+ /// <reference path="dom-events.d.ts" />
49
49
  /// <reference path="domain.d.ts" />
50
50
  /// <reference path="events.d.ts" />
51
51
  /// <reference path="fs.d.ts" />