Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#53669 feat(node): v16 by @SimonSchick
Browse files Browse the repository at this point in the history
* feat(node): v16

* chore(node): remove NodeJS.Global

* chore(node) remove domain and console NodeJS namespace globals

* chore(node): reduce usage of `any`

* fix(node): fix formatting
  • Loading branch information
SimonSchick authored Jul 3, 2021
1 parent 7c1d9b2 commit 9d59b7a
Show file tree
Hide file tree
Showing 176 changed files with 26,250 additions and 1,390 deletions.
6 changes: 0 additions & 6 deletions types/amqp/amqp-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,4 @@ async function start() {
}
}

async function wait(ms: number) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}

start();
4 changes: 2 additions & 2 deletions types/cluster-hub/cluster-hub-tests.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import cluster = require('cluster');
import cluster from 'cluster';
import Hub = require('cluster-hub');

const hub = new Hub();

if (cluster.isMaster) {
if (cluster.isPrimary) {
const worker = cluster.fork();

hub.on('master-to-master', (data) => {
Expand Down
6 changes: 3 additions & 3 deletions types/cluster-hub/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

/// <reference types="node" />

import cluster = require('cluster');
import { Worker } from 'cluster';

export = Hub;

declare class Hub {
constructor(messageKey?: string);
on(type: string, listener: (...args: any[]) => void): this;
sendToMaster(type: string, data?: any): boolean;
sendToWorker(worker: cluster.Worker, type: string, data?: any): boolean;
sendToWorker(worker: Worker, type: string, data?: any): boolean;
sendToRandomWorker(type: string, data?: any): boolean;
sendToWorkers(type: string, data?: any): boolean;
requestMaster(type: string, data?: any, callback?: Hub.Callback): boolean;
requestWorker(worker: cluster.Worker, type: string, data?: any, callback?: Hub.Callback): boolean;
requestWorker(worker: Worker, type: string, data?: any, callback?: Hub.Callback): boolean;
requestAllWorkers(type: string, data?: any, callback?: Hub.Callback): boolean;
requestRandomWorker(type: string, data?: any, callback?: Hub.Callback): boolean;
lock(lockKey: string, callback?: (unlock: () => void) => void): boolean;
Expand Down
2 changes: 1 addition & 1 deletion types/fs-extra/fs-extra-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,5 @@ async function rmDirTest() {
// $ExpectType void
await fs.rmdir('dir');
// $ExpectType void
await fs.rmdir('dir', { maxRetries: 1, recursive: true, retryDelay: 200 });
await fs.rmdir('dir', { maxRetries: 1, retryDelay: 200 });
}
2 changes: 0 additions & 2 deletions types/jest-in-case/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
/// <reference types="jest" />
/// <reference types="node" />

declare const global: NodeJS.Global;

interface Config {
name?: string;
only?: boolean;
Expand Down
1 change: 0 additions & 1 deletion types/libpq/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
/// <reference types="node" />

import { EventEmitter } from 'events';
import { Buffer } from 'buffer';

declare namespace Libpq {
interface NotifyMsg {
Expand Down
14 changes: 0 additions & 14 deletions types/libpq/libpq-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Buffer } from 'buffer';
import assert = require('assert');
import * as async from 'async';
import PQ = require('libpq');
Expand Down Expand Up @@ -97,19 +96,6 @@ describe('async connection', () => {
done();
});
});

it('respects the active domain', (done) => {
const pq = new PQ();
const domain = require('domain').create();
domain.run(() => {
const activeDomain = process.domain;
assert(activeDomain, 'Should have an active domain');
pq.connect(() => {
assert.strictEqual(process.domain, activeDomain, 'Active domain is lost');
done();
});
});
});
});

const consume = (pq: PQ, cb: Function) => {
Expand Down
5 changes: 2 additions & 3 deletions types/node-resque/node-resque-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ class AddJob implements Job<number> {
JobLock: {}
};

perform(...args: number[]): Promise<number> {
async perform(...args: number[]): Promise<number> {
const answer = args[0] + args[1];
return new Promise((resolve) => { setTimeout(resolve, 1000); })
.then(() => answer);
return 42;
}
}

Expand Down
59 changes: 32 additions & 27 deletions types/node/assert.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
declare module 'assert' {
/** An alias of `assert.ok()`. */
function assert(value: any, message?: string | Error): asserts value;
function assert(value: unknown, message?: string | Error): asserts value;
namespace assert {
class AssertionError extends Error {
actual: any;
expected: any;
actual: unknown;
expected: unknown;
operator: string;
generatedMessage: boolean;
code: 'ERR_ASSERTION';
Expand All @@ -13,9 +13,9 @@ declare module 'assert' {
/** If provided, the error message is set to this value. */
message?: string;
/** The `actual` property on the error instance. */
actual?: any;
actual?: unknown;
/** The `expected` property on the error instance. */
expected?: any;
expected?: unknown;
/** The `operator` property on the error instance. */
operator?: string;
/** If provided, the generated stack trace omits frames before this function. */
Expand All @@ -42,48 +42,48 @@ declare module 'assert' {
stack: object;
}

type AssertPredicate = RegExp | (new () => object) | ((thrown: any) => boolean) | object | Error;
type AssertPredicate = RegExp | (new () => object) | ((thrown: unknown) => boolean) | object | Error;

function fail(message?: string | Error): never;
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
function fail(
actual: any,
expected: any,
actual: unknown,
expected: unknown,
message?: string | Error,
operator?: string,
// tslint:disable-next-line:ban-types
stackStartFn?: Function,
): never;
function ok(value: any, message?: string | Error): asserts value;
function ok(value: unknown, message?: string | Error): asserts value;
/** @deprecated since v9.9.0 - use strictEqual() instead. */
function equal(actual: any, expected: any, message?: string | Error): void;
function equal(actual: unknown, expected: unknown, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
function notEqual(actual: any, expected: any, message?: string | Error): void;
function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
function deepEqual(actual: any, expected: any, message?: string | Error): void;
function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
function strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
function deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
function deepStrictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;

function throws(block: () => any, message?: string | Error): void;
function throws(block: () => any, error: AssertPredicate, message?: string | Error): void;
function doesNotThrow(block: () => any, message?: string | Error): void;
function doesNotThrow(block: () => any, error: AssertPredicate, message?: string | Error): void;
function throws(block: () => unknown, message?: string | Error): void;
function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
function doesNotThrow(block: () => unknown, message?: string | Error): void;
function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;

function ifError(value: any): asserts value is null | undefined;
function ifError(value: unknown): asserts value is null | undefined;

function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
function rejects(
block: (() => Promise<any>) | Promise<any>,
block: (() => Promise<unknown>) | Promise<unknown>,
error: AssertPredicate,
message?: string | Error,
): Promise<void>;
function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
function doesNotReject(
block: (() => Promise<any>) | Promise<any>,
block: (() => Promise<unknown>) | Promise<unknown>,
error: AssertPredicate,
message?: string | Error,
): Promise<void>;
Expand All @@ -103,7 +103,7 @@ declare module 'assert' {
| 'ifError'
| 'strict'
> & {
(value: any, message?: string | Error): asserts value;
(value: unknown, message?: string | Error): asserts value;
equal: typeof strictEqual;
notEqual: typeof notStrictEqual;
deepEqual: typeof deepStrictEqual;
Expand All @@ -122,3 +122,8 @@ declare module 'assert' {

export = assert;
}

declare module 'node:assert' {
import assert = require('assert');
export = assert;
}
5 changes: 5 additions & 0 deletions types/node/assert/strict.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ declare module 'assert/strict' {
import { strict } from 'assert';
export = strict;
}

declare module 'node:assert/strict' {
import * as assert from 'assert/strict';
export = assert;
}
6 changes: 5 additions & 1 deletion types/node/async_hooks.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ declare module 'async_hooks' {
* @param fn The function to bind to the current execution context.
* @param type An optional name to associate with the underlying `AsyncResource`.
*/
static bind<Func extends (...args: any[]) => any>(fn: Func, type?: string): Func & { asyncResource: AsyncResource };
static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(fn: Func, type?: string, thisArg?: ThisArg): Func & { asyncResource: AsyncResource };

/**
* Binds the given function to execute to this `AsyncResource`'s scope.
Expand Down Expand Up @@ -224,3 +224,7 @@ declare module 'async_hooks' {
enterWith(store: T): void;
}
}

declare module 'node:async_hooks' {
export * from 'async_hooks';
}
Loading

0 comments on commit 9d59b7a

Please sign in to comment.