@types/node 22.4.0 → 22.4.2

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 (5) hide show
  1. node/README.md +1 -1
  2. node/globals.d.ts +47 -48
  3. node/package.json +2 -2
  4. node/process.d.ts +20 -15
  5. node/test.d.ts +24 -8
node/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.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Fri, 16 Aug 2024 18:09:07 GMT
11
+ * Last updated: Wed, 21 Aug 2024 01:34:14 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
node/globals.d.ts CHANGED
@@ -2,7 +2,7 @@ export {}; // Make this a module
2
2
 
3
3
  // #region Fetch and friends
4
4
  // Conditional type aliases, used at the end of this file.
5
- // Will either be empty if lib-dom is included, or the undici version otherwise.
5
+ // Will either be empty if lib.dom (or lib.webworker) is included, or the undici version otherwise.
6
6
  type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
7
7
  type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response;
8
8
  type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData;
@@ -17,6 +17,49 @@ type _WebSocket = typeof globalThis extends { onmessage: any } ? {} : import("un
17
17
  type _EventSource = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").EventSource;
18
18
  // #endregion Fetch and friends
19
19
 
20
+ // Conditional type definitions for webstorage interface, which conflicts with lib.dom otherwise.
21
+ type _Storage = typeof globalThis extends { onabort: any } ? {} : {
22
+ /**
23
+ * Returns the number of key/value pairs.
24
+ *
25
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/length)
26
+ */
27
+ readonly length: number;
28
+ /**
29
+ * Removes all key/value pairs, if there are any.
30
+ *
31
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/clear)
32
+ */
33
+ clear(): void;
34
+ /**
35
+ * Returns the current value associated with the given key, or null if the given key does not exist.
36
+ *
37
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/getItem)
38
+ */
39
+ getItem(key: string): string | null;
40
+ /**
41
+ * Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
42
+ *
43
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/key)
44
+ */
45
+ key(index: number): string | null;
46
+ /**
47
+ * Removes the key/value pair with the given key, if a key/value pair with the given key exists.
48
+ *
49
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/removeItem)
50
+ */
51
+ removeItem(key: string): void;
52
+ /**
53
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
54
+ *
55
+ * Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set.
56
+ *
57
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/setItem)
58
+ */
59
+ setItem(key: string, value: string): void;
60
+ [key: string]: any;
61
+ };
62
+
20
63
  declare global {
21
64
  // Declare "static" methods in Error
22
65
  interface ErrorConstructor {
@@ -109,54 +152,10 @@ declare global {
109
152
  *
110
153
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage)
111
154
  */
112
- interface Storage {
113
- /**
114
- * Returns the number of key/value pairs.
115
- *
116
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/length)
117
- */
118
- readonly length: number;
119
- /**
120
- * Removes all key/value pairs, if there are any.
121
- *
122
- * Dispatches a storage event on Window objects holding an equivalent Storage object.
123
- *
124
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/clear)
125
- */
126
- clear(): void;
127
- /**
128
- * Returns the current value associated with the given key, or null if the given key does not exist.
129
- *
130
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/getItem)
131
- */
132
- getItem(key: string): string | null;
133
- /**
134
- * Returns the name of the nth key, or null if n is greater than or equal to the number of key/value pairs.
135
- *
136
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/key)
137
- */
138
- key(index: number): string | null;
139
- /**
140
- * Removes the key/value pair with the given key, if a key/value pair with the given key exists.
141
- *
142
- * Dispatches a storage event on Window objects holding an equivalent Storage object.
143
- *
144
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/removeItem)
145
- */
146
- removeItem(key: string): void;
147
- /**
148
- * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
149
- *
150
- * Throws a "QuotaExceededError" DOMException exception if the new value couldn't be set. (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)
151
- *
152
- * Dispatches a storage event on Window objects holding an equivalent Storage object.
153
- *
154
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Storage/setItem)
155
- */
156
- setItem(key: string, value: string): void;
157
- }
155
+ interface Storage extends _Storage {}
158
156
 
159
- var Storage: typeof globalThis extends { onmessage: any; Storage: infer T } ? T
157
+ // Conditional on `onabort` rather than `onmessage`, in order to exclude lib.webworker
158
+ var Storage: typeof globalThis extends { onabort: any; Storage: infer T } ? T
160
159
  : {
161
160
  prototype: Storage;
162
161
  new(): Storage;
node/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "22.4.0",
3
+ "version": "22.4.2",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -212,6 +212,6 @@
212
212
  "dependencies": {
213
213
  "undici-types": "~6.19.2"
214
214
  },
215
- "typesPublisherContentHash": "f22f2e87b11a05781ab2a2c4b7812aa834cf70e01e9db42c5288e6cc3f15fd47",
215
+ "typesPublisherContentHash": "1661354099f570fd618ceda1a789867f3c8f3e5a51051679453227abe7d5b726",
216
216
  "typeScriptVersion": "4.8"
217
217
  }
node/process.d.ts CHANGED
@@ -322,24 +322,28 @@ declare module "process" {
322
322
  has(scope: string, reference?: string): boolean;
323
323
  }
324
324
  interface ProcessReport {
325
+ /**
326
+ * Write reports in a compact format, single-line JSON, more easily consumable by log processing systems
327
+ * than the default multi-line format designed for human consumption.
328
+ * @since v13.12.0, v12.17.0
329
+ */
330
+ compact: boolean;
325
331
  /**
326
332
  * Directory where the report is written.
333
+ * The default value is the empty string, indicating that reports are written to the current
327
334
  * working directory of the Node.js process.
328
- * @default '' indicating that reports are written to the current
329
335
  */
330
336
  directory: string;
331
337
  /**
332
- * Filename where the report is written.
333
- * The default value is the empty string.
334
- * @default '' the output filename will be comprised of a timestamp,
335
- * PID, and sequence number.
338
+ * Filename where the report is written. If set to the empty string, the output filename will be comprised
339
+ * of a timestamp, PID, and sequence number. The default value is the empty string.
336
340
  */
337
341
  filename: string;
338
342
  /**
339
- * Returns a JSON-formatted diagnostic report for the running process.
340
- * The report's JavaScript stack trace is taken from err, if present.
343
+ * Returns a JavaScript Object representation of a diagnostic report for the running process.
344
+ * The report's JavaScript stack trace is taken from `err`, if present.
341
345
  */
342
- getReport(err?: Error): string;
346
+ getReport(err?: Error): object;
343
347
  /**
344
348
  * If true, a diagnostic report is generated on fatal errors,
345
349
  * such as out of memory errors or failed C++ assertions.
@@ -365,18 +369,19 @@ declare module "process" {
365
369
  /**
366
370
  * Writes a diagnostic report to a file. If filename is not provided, the default filename
367
371
  * includes the date, time, PID, and a sequence number.
368
- * The report's JavaScript stack trace is taken from err, if present.
372
+ * The report's JavaScript stack trace is taken from `err`, if present.
369
373
  *
374
+ * If the value of filename is set to `'stdout'` or `'stderr'`, the report is written
375
+ * to the stdout or stderr of the process respectively.
370
376
  * @param fileName Name of the file where the report is written.
371
377
  * This should be a relative path, that will be appended to the directory specified in
372
378
  * `process.report.directory`, or the current working directory of the Node.js process,
373
379
  * if unspecified.
374
- * @param error A custom error used for reporting the JavaScript stack.
380
+ * @param err A custom error used for reporting the JavaScript stack.
375
381
  * @return Filename of the generated report.
376
382
  */
377
- writeReport(fileName?: string): string;
378
- writeReport(error?: Error): string;
379
383
  writeReport(fileName?: string, err?: Error): string;
384
+ writeReport(err?: Error): string;
380
385
  }
381
386
  interface ResourceUsage {
382
387
  fsRead: number;
@@ -1704,11 +1709,11 @@ declare module "process" {
1704
1709
  */
1705
1710
  allowedNodeEnvironmentFlags: ReadonlySet<string>;
1706
1711
  /**
1707
- * `process.report` is an object whose methods are used to generate diagnostic
1708
- * reports for the current process. Additional documentation is available in the `report documentation`.
1712
+ * `process.report` is an object whose methods are used to generate diagnostic reports for the current process.
1713
+ * Additional documentation is available in the [report documentation](https://nodejs.org/docs/latest-v22.x/api/report.html).
1709
1714
  * @since v11.8.0
1710
1715
  */
1711
- report?: ProcessReport | undefined;
1716
+ report: ProcessReport;
1712
1717
  /**
1713
1718
  * ```js
1714
1719
  * import { resourceUsage } from 'node:process';
node/test.d.ts CHANGED
@@ -1960,31 +1960,47 @@ declare module "node:test/reporters" {
1960
1960
  | { type: "test:watch:drained"; data: undefined };
1961
1961
  type TestEventGenerator = AsyncGenerator<TestEvent, void>;
1962
1962
 
1963
+ interface ReporterConstructorWrapper<T extends new(...args: any[]) => Transform> {
1964
+ new(...args: ConstructorParameters<T>): InstanceType<T>;
1965
+ (...args: ConstructorParameters<T>): InstanceType<T>;
1966
+ }
1967
+
1963
1968
  /**
1964
1969
  * The `dot` reporter outputs the test results in a compact format,
1965
1970
  * where each passing test is represented by a `.`,
1966
1971
  * and each failing test is represented by a `X`.
1972
+ * @since v20.0.0
1967
1973
  */
1968
1974
  function dot(source: TestEventGenerator): AsyncGenerator<"\n" | "." | "X", void>;
1969
1975
  /**
1970
1976
  * The `tap` reporter outputs the test results in the [TAP](https://testanything.org/) format.
1977
+ * @since v20.0.0
1971
1978
  */
1972
1979
  function tap(source: TestEventGenerator): AsyncGenerator<string, void>;
1980
+ class SpecReporter extends Transform {
1981
+ constructor();
1982
+ }
1973
1983
  /**
1974
1984
  * The `spec` reporter outputs the test results in a human-readable format.
1985
+ * @since v20.0.0
1975
1986
  */
1976
- class Spec extends Transform {
1977
- constructor();
1978
- }
1987
+ const spec: ReporterConstructorWrapper<typeof SpecReporter>;
1979
1988
  /**
1980
1989
  * The `junit` reporter outputs test results in a jUnit XML format.
1990
+ * @since v21.0.0
1981
1991
  */
1982
1992
  function junit(source: TestEventGenerator): AsyncGenerator<string, void>;
1993
+ class LcovReporter extends Transform {
1994
+ constructor(opts?: Omit<TransformOptions, "writableObjectMode">);
1995
+ }
1983
1996
  /**
1984
- * The `lcov` reporter outputs test coverage when used with the [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--experimental-test-coverage) flag.
1997
+ * The `lcov` reporter outputs test coverage when used with the
1998
+ * [`--experimental-test-coverage`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--experimental-test-coverage) flag.
1999
+ * @since v22.0.0
1985
2000
  */
1986
- class Lcov extends Transform {
1987
- constructor(opts?: TransformOptions);
1988
- }
1989
- export { dot, junit, Lcov as lcov, Spec as spec, tap, TestEvent };
2001
+ // TODO: change the export to a wrapper function once node@0db38f0 is merged (breaking change)
2002
+ // const lcov: ReporterConstructorWrapper<typeof LcovReporter>;
2003
+ const lcov: LcovReporter;
2004
+
2005
+ export { dot, junit, lcov, spec, tap, TestEvent };
1990
2006
  }