@types/node 16.0.3 → 16.3.3

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 CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (http://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, 09 Jul 2021 00:06:51 GMT
11
+ * Last updated: Fri, 16 Jul 2021 19:01:24 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`
14
14
 
node/assert/strict.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  declare module 'assert/strict' {
2
- import { strict } from 'assert';
2
+ import { strict } from 'node:assert';
3
3
  export = strict;
4
4
  }
5
5
 
6
6
  declare module 'node:assert/strict' {
7
- import * as assert from 'assert/strict';
8
- export = assert;
7
+ import { strict } from 'node:assert';
8
+ export = strict;
9
9
  }
node/async_hooks.d.ts CHANGED
@@ -198,8 +198,7 @@ declare module 'async_hooks' {
198
198
  * I the callback function throws an error, it will be thrown by `run` too. The
199
199
  * stacktrace will not be impacted by this call and the context will be exited.
200
200
  */
201
- // TODO: Apply generic vararg once available
202
- run<R>(store: T, callback: (...args: any[]) => R, ...args: any[]): R;
201
+ run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
203
202
 
204
203
  /**
205
204
  * This methods runs a function synchronously outside of a context and return its
@@ -213,8 +212,7 @@ declare module 'async_hooks' {
213
212
  * stacktrace will not be impacted by this call and the context will be
214
213
  * re-entered.
215
214
  */
216
- // TODO: Apply generic vararg once available
217
- exit<R>(callback: (...args: any[]) => R, ...args: any[]): R;
215
+ exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
218
216
 
219
217
  /**
220
218
  * Calling `asyncLocalStorage.enterWith(store)` will transition into the context
node/buffer.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare module 'buffer' {
2
- import { BinaryLike } from 'crypto';
2
+ import { BinaryLike } from 'node:crypto';
3
3
 
4
4
  export const INSPECT_MAX_BYTES: number;
5
5
  export const kMaxLength: number;
@@ -91,7 +91,7 @@ declare module 'buffer' {
91
91
  * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
92
92
  * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
93
93
  */
94
- class Buffer extends Uint8Array {
94
+ interface BufferConstructor {
95
95
  /**
96
96
  * Allocates a new buffer containing the given {str}.
97
97
  *
@@ -99,21 +99,21 @@ declare module 'buffer' {
99
99
  * @param encoding encoding to use, optional. Default is 'utf8'
100
100
  * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
101
101
  */
102
- constructor(str: string, encoding?: BufferEncoding);
102
+ new(str: string, encoding?: BufferEncoding): Buffer;
103
103
  /**
104
104
  * Allocates a new buffer of {size} octets.
105
105
  *
106
106
  * @param size count of octets to allocate.
107
107
  * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
108
108
  */
109
- constructor(size: number);
109
+ new(size: number): Buffer;
110
110
  /**
111
111
  * Allocates a new buffer containing the given {array} of octets.
112
112
  *
113
113
  * @param array The octets to store.
114
114
  * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
115
115
  */
116
- constructor(array: Uint8Array);
116
+ new(array: Uint8Array): Buffer;
117
117
  /**
118
118
  * Produces a Buffer backed by the same allocated memory as
119
119
  * the given {ArrayBuffer}/{SharedArrayBuffer}.
@@ -122,21 +122,21 @@ declare module 'buffer' {
122
122
  * @param arrayBuffer The ArrayBuffer with which to share memory.
123
123
  * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
124
124
  */
125
- constructor(arrayBuffer: ArrayBuffer | SharedArrayBuffer);
125
+ new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
126
126
  /**
127
127
  * Allocates a new buffer containing the given {array} of octets.
128
128
  *
129
129
  * @param array The octets to store.
130
130
  * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
131
131
  */
132
- constructor(array: ReadonlyArray<any>);
132
+ new(array: ReadonlyArray<any>): Buffer;
133
133
  /**
134
134
  * Copies the passed {buffer} data onto a new {Buffer} instance.
135
135
  *
136
136
  * @param buffer The buffer to copy.
137
137
  * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
138
138
  */
139
- constructor(buffer: Buffer);
139
+ new(buffer: Buffer): Buffer;
140
140
  /**
141
141
  * When passed a reference to the .buffer property of a TypedArray instance,
142
142
  * the newly created Buffer will share the same allocated memory as the TypedArray.
@@ -145,37 +145,37 @@ declare module 'buffer' {
145
145
  *
146
146
  * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
147
147
  */
148
- static from(arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, byteOffset?: number, length?: number): Buffer;
148
+ from(arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>, byteOffset?: number, length?: number): Buffer;
149
149
  /**
150
150
  * Creates a new Buffer using the passed {data}
151
151
  * @param data data to create a new Buffer
152
152
  */
153
- static from(data: Uint8Array | ReadonlyArray<number>): Buffer;
154
- static from(data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>): Buffer;
153
+ from(data: Uint8Array | ReadonlyArray<number>): Buffer;
154
+ from(data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>): Buffer;
155
155
  /**
156
156
  * Creates a new Buffer containing the given JavaScript string {str}.
157
157
  * If provided, the {encoding} parameter identifies the character encoding.
158
158
  * If not provided, {encoding} defaults to 'utf8'.
159
159
  */
160
- static from(str: WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: 'string'): string }, encoding?: BufferEncoding): Buffer;
160
+ from(str: WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: 'string'): string }, encoding?: BufferEncoding): Buffer;
161
161
  /**
162
162
  * Creates a new Buffer using the passed {data}
163
163
  * @param values to create a new Buffer
164
164
  */
165
- static of(...items: number[]): Buffer;
165
+ of(...items: number[]): Buffer;
166
166
  /**
167
167
  * Returns true if {obj} is a Buffer
168
168
  *
169
169
  * @param obj object to test.
170
170
  */
171
- static isBuffer(obj: any): obj is Buffer;
171
+ isBuffer(obj: any): obj is Buffer;
172
172
  /**
173
173
  * Returns true if {encoding} is a valid encoding argument.
174
174
  * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
175
175
  *
176
176
  * @param encoding string to test.
177
177
  */
178
- static isEncoding(encoding: string): encoding is BufferEncoding;
178
+ isEncoding(encoding: string): encoding is BufferEncoding;
179
179
  /**
180
180
  * Gives the actual byte length of a string. encoding defaults to 'utf8'.
181
181
  * This is not the same as String.prototype.length since that returns the number of characters in a string.
@@ -183,7 +183,7 @@ declare module 'buffer' {
183
183
  * @param string string to test.
184
184
  * @param encoding encoding used to evaluate (defaults to 'utf8')
185
185
  */
186
- static byteLength(
186
+ byteLength(
187
187
  string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
188
188
  encoding?: BufferEncoding
189
189
  ): number;
@@ -198,11 +198,11 @@ declare module 'buffer' {
198
198
  * @param totalLength Total length of the buffers when concatenated.
199
199
  * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
200
200
  */
201
- static concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
201
+ concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
202
202
  /**
203
203
  * The same as buf1.compare(buf2).
204
204
  */
205
- static compare(buf1: Uint8Array, buf2: Uint8Array): number;
205
+ compare(buf1: Uint8Array, buf2: Uint8Array): number;
206
206
  /**
207
207
  * Allocates a new buffer of {size} octets.
208
208
  *
@@ -211,26 +211,28 @@ declare module 'buffer' {
211
211
  * If parameter is omitted, buffer will be filled with zeros.
212
212
  * @param encoding encoding used for call to buf.fill while initalizing
213
213
  */
214
- static alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
214
+ alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
215
215
  /**
216
216
  * Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
217
217
  * of the newly created Buffer are unknown and may contain sensitive data.
218
218
  *
219
219
  * @param size count of octets to allocate
220
220
  */
221
- static allocUnsafe(size: number): Buffer;
221
+ allocUnsafe(size: number): Buffer;
222
222
  /**
223
223
  * Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
224
224
  * of the newly created Buffer are unknown and may contain sensitive data.
225
225
  *
226
226
  * @param size count of octets to allocate
227
227
  */
228
- static allocUnsafeSlow(size: number): Buffer;
228
+ allocUnsafeSlow(size: number): Buffer;
229
229
  /**
230
230
  * This is the number of bytes used to determine the size of pre-allocated, internal Buffer instances used for pooling. This value may be modified.
231
231
  */
232
- static poolSize: number;
232
+ poolSize: number;
233
+ }
233
234
 
235
+ interface Buffer extends Uint8Array {
234
236
  write(string: string, encoding?: BufferEncoding): number;
235
237
  write(string: string, offset: number, encoding?: BufferEncoding): number;
236
238
  write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
@@ -321,6 +323,7 @@ declare module 'buffer' {
321
323
  keys(): IterableIterator<number>;
322
324
  values(): IterableIterator<number>;
323
325
  }
326
+ var Buffer: BufferConstructor;
324
327
 
325
328
  /**
326
329
  * Decodes a string of Base64-encoded data into bytes, and encodes those bytes into a string using Latin-1 (ISO-8859-1).
node/child_process.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  declare module 'child_process' {
2
- import { BaseEncodingOptions } from 'fs';
3
- import { EventEmitter, Abortable } from 'events';
4
- import * as net from 'net';
5
- import { Writable, Readable, Stream, Pipe } from 'stream';
2
+ import { ObjectEncodingOptions } from 'node:fs';
3
+ import { EventEmitter, Abortable } from 'node:events';
4
+ import * as net from 'node:net';
5
+ import { Writable, Readable, Stream, Pipe } from 'node:stream';
6
6
 
7
7
  type Serializable = string | object | number | boolean | bigint;
8
8
  type SendHandle = net.Socket | net.Server;
@@ -327,7 +327,7 @@ declare module 'child_process' {
327
327
  // fallback if nothing else matches. Worst case is always `string | Buffer`.
328
328
  function exec(
329
329
  command: string,
330
- options: (BaseEncodingOptions & ExecOptions) | undefined | null,
330
+ options: (ObjectEncodingOptions & ExecOptions) | undefined | null,
331
331
  callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
332
332
  ): ChildProcess;
333
333
 
@@ -341,7 +341,7 @@ declare module 'child_process' {
341
341
  function __promisify__(command: string, options: { encoding: "buffer" | null } & ExecOptions): PromiseWithChild<{ stdout: Buffer, stderr: Buffer }>;
342
342
  function __promisify__(command: string, options: { encoding: BufferEncoding } & ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
343
343
  function __promisify__(command: string, options: ExecOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
344
- function __promisify__(command: string, options?: (BaseEncodingOptions & ExecOptions) | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
344
+ function __promisify__(command: string, options?: (ObjectEncodingOptions & ExecOptions) | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
345
345
  }
346
346
 
347
347
  interface ExecFileOptions extends CommonOptions, Abortable {
@@ -363,9 +363,9 @@ declare module 'child_process' {
363
363
  type ExecFileException = ExecException & NodeJS.ErrnoException;
364
364
 
365
365
  function execFile(file: string): ChildProcess;
366
- function execFile(file: string, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
366
+ function execFile(file: string, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
367
367
  function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
368
- function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
368
+ function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
369
369
 
370
370
  // no `options` definitely means stdout/stderr are `string`.
371
371
  function execFile(file: string, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
@@ -415,13 +415,13 @@ declare module 'child_process' {
415
415
  // fallback if nothing else matches. Worst case is always `string | Buffer`.
416
416
  function execFile(
417
417
  file: string,
418
- options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
418
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
419
419
  callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
420
420
  ): ChildProcess;
421
421
  function execFile(
422
422
  file: string,
423
423
  args: ReadonlyArray<string> | undefined | null,
424
- options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
424
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
425
425
  callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null,
426
426
  ): ChildProcess;
427
427
 
@@ -441,11 +441,11 @@ declare module 'child_process' {
441
441
  ): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
442
442
  function __promisify__(file: string, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
443
443
  function __promisify__(file: string, args: ReadonlyArray<string> | undefined | null, options: ExecFileOptions): PromiseWithChild<{ stdout: string, stderr: string }>;
444
- function __promisify__(file: string, options: (BaseEncodingOptions & ExecFileOptions) | undefined | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
444
+ function __promisify__(file: string, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
445
445
  function __promisify__(
446
446
  file: string,
447
447
  args: ReadonlyArray<string> | undefined | null,
448
- options: (BaseEncodingOptions & ExecFileOptions) | undefined | null,
448
+ options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
449
449
  ): PromiseWithChild<{ stdout: string | Buffer, stderr: string | Buffer }>;
450
450
  }
451
451
 
@@ -488,7 +488,7 @@ declare module 'child_process' {
488
488
  function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
489
489
  function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<Buffer>;
490
490
 
491
- interface CommonExecOptions extends ProcessEnvOptions {
491
+ interface CommonExecOptions extends CommonOptions {
492
492
  input?: string | NodeJS.ArrayBufferView | undefined;
493
493
  stdio?: StdioOptions | undefined;
494
494
  killSignal?: NodeJS.Signals | number | undefined;
node/cluster.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  // Requires `esModuleInterop: true`
2
2
  declare module 'cluster' {
3
- import * as child from 'child_process';
4
- import EventEmitter = require('events');
5
- import * as net from 'net';
3
+ import * as child from 'node:child_process';
4
+ import EventEmitter = require('node:events');
5
+ import * as net from 'node:net';
6
6
 
7
7
  export interface ClusterSettings {
8
8
  execArgv?: string[] | undefined; // default: process.execArgv
@@ -184,4 +184,5 @@ declare module 'cluster' {
184
184
 
185
185
  declare module 'node:cluster' {
186
186
  export * from 'cluster';
187
+ export { default as default } from 'cluster';
187
188
  }
node/console.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  declare module 'console' {
2
- import { InspectOptions } from 'util';
2
+ import console = require('node:console');
3
+ export = console;
4
+ }
5
+
6
+ declare module 'node:console' {
7
+ import { InspectOptions } from 'node:util';
3
8
 
4
9
  global {
5
10
  // This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
@@ -127,8 +132,3 @@ declare module 'console' {
127
132
 
128
133
  export = globalThis.console;
129
134
  }
130
-
131
- declare module 'node:console' {
132
- import console = require('console');
133
- export = console;
134
- }
node/constants.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
2
2
  declare module 'constants' {
3
- import { constants as osConstants, SignalConstants } from 'os';
4
- import { constants as cryptoConstants } from 'crypto';
5
- import { constants as fsConstants } from 'fs';
3
+ import { constants as osConstants, SignalConstants } from 'node:os';
4
+ import { constants as cryptoConstants } from 'node:crypto';
5
+ import { constants as fsConstants } from 'node:fs';
6
6
 
7
7
  const exp: typeof osConstants.errno &
8
8
  typeof osConstants.priority &
node/crypto.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  declare module 'crypto' {
2
- import * as stream from 'stream';
3
- import { PeerCertificate } from 'tls';
2
+ import * as stream from 'node:stream';
3
+ import { PeerCertificate } from 'node:tls';
4
4
 
5
5
  interface Certificate {
6
6
  /**
@@ -1363,8 +1363,6 @@ declare module 'crypto' {
1363
1363
 
1364
1364
  function secureHeapUsed(): SecureHeapUsage;
1365
1365
 
1366
- // TODO: X509Certificate
1367
-
1368
1366
  interface RandomUUIDOptions {
1369
1367
  /**
1370
1368
  * By default, to improve performance,
@@ -1586,6 +1584,10 @@ declare module 'crypto' {
1586
1584
  * Checks the primality of the candidate.
1587
1585
  */
1588
1586
  function checkPrimeSync(value: LargeNumberLike, options?: CheckPrimeOptions): boolean;
1587
+
1588
+ namespace webcrypto {
1589
+ class CryptoKey {} // placeholder
1590
+ }
1589
1591
  }
1590
1592
 
1591
1593
  declare module 'node:crypto' {
node/dgram.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  declare module 'dgram' {
2
- import { AddressInfo } from 'net';
3
- import * as dns from 'dns';
4
- import { EventEmitter, Abortable } from 'events';
2
+ import { AddressInfo } from 'node:net';
3
+ import * as dns from 'node:dns';
4
+ import { EventEmitter, Abortable } from 'node:events';
5
5
 
6
6
  interface RemoteInfo {
7
7
  address: string;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @experimental
3
3
  */
4
- declare module 'diagnostic_channel' {
4
+ declare module 'diagnostics_channel' {
5
5
  /**
6
6
  * Returns wether a named channel has subscribers or not.
7
7
  */
@@ -33,6 +33,6 @@ declare module 'diagnostic_channel' {
33
33
  }
34
34
  }
35
35
 
36
- declare module 'node:diagnostic_channel' {
37
- export * from 'diagnostic_channel';
36
+ declare module 'node:diagnostics_channel' {
37
+ export * from 'diagnostics_channel';
38
38
  }
node/dns/promises.d.ts CHANGED
@@ -14,7 +14,7 @@ declare module "dns/promises" {
14
14
  RecordWithTtl,
15
15
  ResolveOptions,
16
16
  ResolverOptions,
17
- } from "dns";
17
+ } from "node:dns";
18
18
 
19
19
  function getServers(): string[];
20
20
 
node/dns.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare module 'dns' {
2
- import * as dnsPromises from "dns/promises";
2
+ import * as dnsPromises from "node:dns/promises";
3
3
 
4
4
  // Supported getaddrinfo flags.
5
5
  export const ADDRCONFIG: number;
node/domain.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- /**
2
- * @deprecated
3
- */
1
+ /**
2
+ * @deprecated
3
+ */
4
4
  declare module 'domain' {
5
- import EventEmitter = require('events');
5
+ import EventEmitter = require('node:events');
6
6
  class Domain extends EventEmitter {
7
7
  members: Array<EventEmitter | NodeJS.Timer>;
8
8
  enter(): void;
@@ -17,9 +17,9 @@ declare module 'domain' {
17
17
  function create(): Domain;
18
18
  }
19
19
 
20
- /**
21
- * @deprecated
22
- */
20
+ /**
21
+ * @deprecated
22
+ */
23
23
  declare module 'node:domain' {
24
24
  export * from 'domain';
25
25
  }
node/events.d.ts CHANGED
@@ -53,7 +53,7 @@ declare module 'events' {
53
53
  static defaultMaxListeners: number;
54
54
  }
55
55
 
56
- import internal = require('events');
56
+ import internal = require('node:events');
57
57
  namespace EventEmitter {
58
58
  // Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
59
59
  export { internal as EventEmitter };