@types/node 20.4.10 → 20.5.0
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 +1 -1
- node/child_process.d.ts +5 -0
- node/dgram.d.ts +5 -0
- node/events.d.ts +35 -0
- node/fs/promises.d.ts +5 -0
- node/globals.d.ts +22 -0
- node/index.d.ts +1 -1
- node/net.d.ts +5 -0
- node/package.json +2 -2
- node/stream.d.ts +5 -0
- node/test.d.ts +22 -2
- node/timers.d.ts +12 -2
- node/ts4.8/child_process.d.ts +5 -0
- node/ts4.8/dgram.d.ts +5 -0
- node/ts4.8/events.d.ts +35 -0
- node/ts4.8/fs/promises.d.ts +5 -0
- node/ts4.8/globals.d.ts +22 -0
- node/ts4.8/net.d.ts +5 -0
- node/ts4.8/stream.d.ts +762 -728
- node/ts4.8/test.d.ts +86 -48
- node/ts4.8/timers.d.ts +12 -2
node/ts4.8/test.d.ts
CHANGED
|
@@ -162,33 +162,33 @@ declare module 'node:test' {
|
|
|
162
162
|
* @param [fn='A no-op function'] The function under suite declaring all subtests and subsuites. The first argument to this function is a {@link SuiteContext} object.
|
|
163
163
|
* @return Immediately fulfilled with `undefined`.
|
|
164
164
|
*/
|
|
165
|
-
function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void
|
|
166
|
-
function describe(name?: string, fn?: SuiteFn): void
|
|
167
|
-
function describe(options?: TestOptions, fn?: SuiteFn): void
|
|
168
|
-
function describe(fn?: SuiteFn): void
|
|
165
|
+
function describe(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
166
|
+
function describe(name?: string, fn?: SuiteFn): Promise<void>;
|
|
167
|
+
function describe(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
168
|
+
function describe(fn?: SuiteFn): Promise<void>;
|
|
169
169
|
namespace describe {
|
|
170
170
|
/**
|
|
171
171
|
* Shorthand for skipping a suite, same as `describe([name], { skip: true }[, fn])`.
|
|
172
172
|
*/
|
|
173
|
-
function skip(name?: string, options?: TestOptions, fn?: SuiteFn): void
|
|
174
|
-
function skip(name?: string, fn?: SuiteFn): void
|
|
175
|
-
function skip(options?: TestOptions, fn?: SuiteFn): void
|
|
176
|
-
function skip(fn?: SuiteFn): void
|
|
173
|
+
function skip(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
174
|
+
function skip(name?: string, fn?: SuiteFn): Promise<void>;
|
|
175
|
+
function skip(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
176
|
+
function skip(fn?: SuiteFn): Promise<void>;
|
|
177
177
|
/**
|
|
178
178
|
* Shorthand for marking a suite as `TODO`, same as `describe([name], { todo: true }[, fn])`.
|
|
179
179
|
*/
|
|
180
|
-
function todo(name?: string, options?: TestOptions, fn?: SuiteFn): void
|
|
181
|
-
function todo(name?: string, fn?: SuiteFn): void
|
|
182
|
-
function todo(options?: TestOptions, fn?: SuiteFn): void
|
|
183
|
-
function todo(fn?: SuiteFn): void
|
|
180
|
+
function todo(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
181
|
+
function todo(name?: string, fn?: SuiteFn): Promise<void>;
|
|
182
|
+
function todo(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
183
|
+
function todo(fn?: SuiteFn): Promise<void>;
|
|
184
184
|
/**
|
|
185
185
|
* Shorthand for marking a suite as `only`, same as `describe([name], { only: true }[, fn])`.
|
|
186
186
|
* @since v18.15.0
|
|
187
187
|
*/
|
|
188
|
-
function only(name?: string, options?: TestOptions, fn?: SuiteFn): void
|
|
189
|
-
function only(name?: string, fn?: SuiteFn): void
|
|
190
|
-
function only(options?: TestOptions, fn?: SuiteFn): void
|
|
191
|
-
function only(fn?: SuiteFn): void
|
|
188
|
+
function only(name?: string, options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
189
|
+
function only(name?: string, fn?: SuiteFn): Promise<void>;
|
|
190
|
+
function only(options?: TestOptions, fn?: SuiteFn): Promise<void>;
|
|
191
|
+
function only(fn?: SuiteFn): Promise<void>;
|
|
192
192
|
}
|
|
193
193
|
/**
|
|
194
194
|
* Shorthand for `test()`.
|
|
@@ -196,69 +196,79 @@ declare module 'node:test' {
|
|
|
196
196
|
* The `it()` function is imported from the `node:test` module.
|
|
197
197
|
* @since v18.6.0, v16.17.0
|
|
198
198
|
*/
|
|
199
|
-
function it(name?: string, options?: TestOptions, fn?: TestFn): void
|
|
200
|
-
function it(name?: string, fn?: TestFn): void
|
|
201
|
-
function it(options?: TestOptions, fn?: TestFn): void
|
|
202
|
-
function it(fn?: TestFn): void
|
|
199
|
+
function it(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
200
|
+
function it(name?: string, fn?: TestFn): Promise<void>;
|
|
201
|
+
function it(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
202
|
+
function it(fn?: TestFn): Promise<void>;
|
|
203
203
|
namespace it {
|
|
204
204
|
/**
|
|
205
205
|
* Shorthand for skipping a test, same as `it([name], { skip: true }[, fn])`.
|
|
206
206
|
*/
|
|
207
|
-
function skip(name?: string, options?: TestOptions, fn?: TestFn): void
|
|
208
|
-
function skip(name?: string, fn?: TestFn): void
|
|
209
|
-
function skip(options?: TestOptions, fn?: TestFn): void
|
|
210
|
-
function skip(fn?: TestFn): void
|
|
207
|
+
function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
208
|
+
function skip(name?: string, fn?: TestFn): Promise<void>;
|
|
209
|
+
function skip(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
210
|
+
function skip(fn?: TestFn): Promise<void>;
|
|
211
211
|
/**
|
|
212
212
|
* Shorthand for marking a test as `TODO`, same as `it([name], { todo: true }[, fn])`.
|
|
213
213
|
*/
|
|
214
|
-
function todo(name?: string, options?: TestOptions, fn?: TestFn): void
|
|
215
|
-
function todo(name?: string, fn?: TestFn): void
|
|
216
|
-
function todo(options?: TestOptions, fn?: TestFn): void
|
|
217
|
-
function todo(fn?: TestFn): void
|
|
214
|
+
function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
215
|
+
function todo(name?: string, fn?: TestFn): Promise<void>;
|
|
216
|
+
function todo(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
217
|
+
function todo(fn?: TestFn): Promise<void>;
|
|
218
218
|
/**
|
|
219
219
|
* Shorthand for marking a test as `only`, same as `it([name], { only: true }[, fn])`.
|
|
220
220
|
* @since v18.15.0
|
|
221
221
|
*/
|
|
222
|
-
function only(name?: string, options?: TestOptions, fn?: TestFn): void
|
|
223
|
-
function only(name?: string, fn?: TestFn): void
|
|
224
|
-
function only(options?: TestOptions, fn?: TestFn): void
|
|
225
|
-
function only(fn?: TestFn): void
|
|
222
|
+
function only(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
223
|
+
function only(name?: string, fn?: TestFn): Promise<void>;
|
|
224
|
+
function only(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
225
|
+
function only(fn?: TestFn): Promise<void>;
|
|
226
226
|
}
|
|
227
227
|
/**
|
|
228
228
|
* Shorthand for skipping a test, same as `test([name], { skip: true }[, fn])`.
|
|
229
229
|
* @since v20.2.0
|
|
230
230
|
*/
|
|
231
|
-
function skip(name?: string, options?: TestOptions, fn?: TestFn): void
|
|
232
|
-
function skip(name?: string, fn?: TestFn): void
|
|
233
|
-
function skip(options?: TestOptions, fn?: TestFn): void
|
|
234
|
-
function skip(fn?: TestFn): void
|
|
231
|
+
function skip(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
232
|
+
function skip(name?: string, fn?: TestFn): Promise<void>;
|
|
233
|
+
function skip(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
234
|
+
function skip(fn?: TestFn): Promise<void>;
|
|
235
235
|
/**
|
|
236
236
|
* Shorthand for marking a test as `TODO`, same as `test([name], { todo: true }[, fn])`.
|
|
237
237
|
* @since v20.2.0
|
|
238
238
|
*/
|
|
239
|
-
function todo(name?: string, options?: TestOptions, fn?: TestFn): void
|
|
240
|
-
function todo(name?: string, fn?: TestFn): void
|
|
241
|
-
function todo(options?: TestOptions, fn?: TestFn): void
|
|
242
|
-
function todo(fn?: TestFn): void
|
|
239
|
+
function todo(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
240
|
+
function todo(name?: string, fn?: TestFn): Promise<void>;
|
|
241
|
+
function todo(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
242
|
+
function todo(fn?: TestFn): Promise<void>;
|
|
243
243
|
/**
|
|
244
244
|
* Shorthand for marking a test as `only`, same as `test([name], { only: true }[, fn])`.
|
|
245
245
|
* @since v20.2.0
|
|
246
246
|
*/
|
|
247
|
-
function only(name?: string, options?: TestOptions, fn?: TestFn): void
|
|
248
|
-
function only(name?: string, fn?: TestFn): void
|
|
249
|
-
function only(options?: TestOptions, fn?: TestFn): void
|
|
250
|
-
function only(fn?: TestFn): void
|
|
247
|
+
function only(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
248
|
+
function only(name?: string, fn?: TestFn): Promise<void>;
|
|
249
|
+
function only(options?: TestOptions, fn?: TestFn): Promise<void>;
|
|
250
|
+
function only(fn?: TestFn): Promise<void>;
|
|
251
251
|
/**
|
|
252
252
|
* The type of a function under test. The first argument to this function is a
|
|
253
253
|
* {@link TestContext} object. If the test uses callbacks, the callback function is passed as
|
|
254
254
|
* the second argument.
|
|
255
255
|
*/
|
|
256
|
-
type TestFn = (t: TestContext, done: (result?: any) => void) =>
|
|
256
|
+
type TestFn = (t: TestContext, done: (result?: any) => void) => void | Promise<void>;
|
|
257
257
|
/**
|
|
258
258
|
* The type of a function under Suite.
|
|
259
259
|
* If the test uses callbacks, the callback function is passed as an argument
|
|
260
260
|
*/
|
|
261
|
-
type SuiteFn = (
|
|
261
|
+
type SuiteFn = (s: SuiteContext) => void | Promise<void>;
|
|
262
|
+
interface TestShard {
|
|
263
|
+
/**
|
|
264
|
+
* A positive integer between 1 and `<total>` that specifies the index of the shard to run.
|
|
265
|
+
*/
|
|
266
|
+
index: number;
|
|
267
|
+
/**
|
|
268
|
+
* A positive integer that specifies the total number of shards to split the test files to.
|
|
269
|
+
*/
|
|
270
|
+
total: number;
|
|
271
|
+
}
|
|
262
272
|
interface RunOptions {
|
|
263
273
|
/**
|
|
264
274
|
* If a number is provided, then that many files would run in parallel.
|
|
@@ -301,9 +311,15 @@ declare module 'node:test' {
|
|
|
301
311
|
*/
|
|
302
312
|
setup?: (root: unknown) => void | Promise<void>;
|
|
303
313
|
/**
|
|
304
|
-
* Whether to run in watch mode or not.
|
|
314
|
+
* Whether to run in watch mode or not.
|
|
315
|
+
* @default false
|
|
316
|
+
*/
|
|
317
|
+
watch?: boolean | undefined;
|
|
318
|
+
/**
|
|
319
|
+
* Running tests in a specific shard.
|
|
320
|
+
* @default undefined
|
|
305
321
|
*/
|
|
306
|
-
|
|
322
|
+
shard?: TestShard | undefined;
|
|
307
323
|
}
|
|
308
324
|
class Test extends AsyncResource {
|
|
309
325
|
concurrency: number;
|
|
@@ -504,6 +520,24 @@ declare module 'node:test' {
|
|
|
504
520
|
*/
|
|
505
521
|
readonly mock: MockTracker;
|
|
506
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* An instance of `SuiteContext` is passed to each suite function in order to
|
|
525
|
+
* interact with the test runner. However, the `SuiteContext` constructor is not
|
|
526
|
+
* exposed as part of the API.
|
|
527
|
+
* @since v18.7.0, v16.17.0
|
|
528
|
+
*/
|
|
529
|
+
class SuiteContext {
|
|
530
|
+
/**
|
|
531
|
+
* The name of the suite.
|
|
532
|
+
* @since v18.8.0, v16.18.0
|
|
533
|
+
*/
|
|
534
|
+
readonly name: string;
|
|
535
|
+
/**
|
|
536
|
+
* Can be used to abort test subtasks when the test has been aborted.
|
|
537
|
+
* @since v18.7.0, v16.17.0
|
|
538
|
+
*/
|
|
539
|
+
readonly signal: AbortSignal;
|
|
540
|
+
}
|
|
507
541
|
interface TestOptions {
|
|
508
542
|
/**
|
|
509
543
|
* If a number is provided, then that many tests would run in parallel.
|
|
@@ -1192,6 +1226,10 @@ declare module 'node:test' {
|
|
|
1192
1226
|
* @since v20.4.0
|
|
1193
1227
|
*/
|
|
1194
1228
|
runAll(): void;
|
|
1229
|
+
/**
|
|
1230
|
+
* Calls {@link MockTimers.reset()}.
|
|
1231
|
+
*/
|
|
1232
|
+
[Symbol.dispose](): void;
|
|
1195
1233
|
}
|
|
1196
1234
|
export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock, skip, only, todo };
|
|
1197
1235
|
}
|
node/ts4.8/timers.d.ts
CHANGED
|
@@ -68,6 +68,11 @@ declare module 'timers' {
|
|
|
68
68
|
*/
|
|
69
69
|
hasRef(): boolean;
|
|
70
70
|
_onImmediate: Function; // to distinguish it from the Timeout class
|
|
71
|
+
/**
|
|
72
|
+
* Cancels the immediate. This is similar to calling `clearImmediate()`.
|
|
73
|
+
* @since v20.5.0
|
|
74
|
+
*/
|
|
75
|
+
[Symbol.dispose](): void;
|
|
71
76
|
}
|
|
72
77
|
/**
|
|
73
78
|
* This object is created internally and is returned from `setTimeout()` and `setInterval()`. It can be passed to either `clearTimeout()` or `clearInterval()` in order to cancel the
|
|
@@ -114,6 +119,11 @@ declare module 'timers' {
|
|
|
114
119
|
*/
|
|
115
120
|
refresh(): this;
|
|
116
121
|
[Symbol.toPrimitive](): number;
|
|
122
|
+
/**
|
|
123
|
+
* Cancels the timeout.
|
|
124
|
+
* @since v20.5.0
|
|
125
|
+
*/
|
|
126
|
+
[Symbol.dispose](): void;
|
|
117
127
|
}
|
|
118
128
|
}
|
|
119
129
|
/**
|
|
@@ -163,10 +173,10 @@ declare module 'timers' {
|
|
|
163
173
|
* @param args Optional arguments to pass when the `callback` is called.
|
|
164
174
|
* @return for use with {@link clearInterval}
|
|
165
175
|
*/
|
|
166
|
-
function setInterval<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.
|
|
176
|
+
function setInterval<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timeout;
|
|
167
177
|
// util.promisify no rest args compability
|
|
168
178
|
// tslint:disable-next-line void-return
|
|
169
|
-
function setInterval(callback: (args: void) => void, ms?: number): NodeJS.
|
|
179
|
+
function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
|
|
170
180
|
namespace setInterval {
|
|
171
181
|
const __promisify__: typeof setIntervalPromise;
|
|
172
182
|
}
|