mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
feat(node): 10.12 (#29689)
This commit is contained in:
Vendored
+131
-4
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Node.js 10.11
|
||||
// Type definitions for Node.js 10.12
|
||||
// Project: http://nodejs.org/
|
||||
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
|
||||
// DefinitelyTyped <https://github.com/DefinitelyTyped>
|
||||
@@ -493,6 +493,7 @@ declare namespace NodeJS {
|
||||
maxArrayLength?: number | null;
|
||||
breakLength?: number;
|
||||
compact?: boolean;
|
||||
sorted?: boolean | ((a: string, b: string) => number);
|
||||
}
|
||||
|
||||
interface ConsoleConstructor {
|
||||
@@ -691,6 +692,8 @@ declare namespace NodeJS {
|
||||
"SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" |
|
||||
"SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO";
|
||||
|
||||
type MultipleResolveType = 'resolve' | 'reject';
|
||||
|
||||
type BeforeExitListener = (code: number) => void;
|
||||
type DisconnectListener = () => void;
|
||||
type ExitListener = (code: number) => void;
|
||||
@@ -702,6 +705,7 @@ declare namespace NodeJS {
|
||||
type SignalsListener = (signal: Signals) => void;
|
||||
type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
|
||||
type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
|
||||
type MultipleResolveListener = (type: MultipleResolveType, promise: Promise<any>, value: any) => void;
|
||||
|
||||
interface Socket extends ReadWriteStream {
|
||||
isTTY?: true;
|
||||
@@ -845,6 +849,7 @@ declare namespace NodeJS {
|
||||
addListener(event: Signals, listener: SignalsListener): this;
|
||||
addListener(event: "newListener", listener: NewListenerListener): this;
|
||||
addListener(event: "removeListener", listener: RemoveListenerListener): this;
|
||||
addListener(event: "multipleResolves", listener: MultipleResolveListener): this;
|
||||
|
||||
emit(event: "beforeExit", code: number): boolean;
|
||||
emit(event: "disconnect"): boolean;
|
||||
@@ -857,6 +862,7 @@ declare namespace NodeJS {
|
||||
emit(event: Signals, signal: Signals): boolean;
|
||||
emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this;
|
||||
emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this;
|
||||
emit(event: "multipleResolves", listener: MultipleResolveListener): this;
|
||||
|
||||
on(event: "beforeExit", listener: BeforeExitListener): this;
|
||||
on(event: "disconnect", listener: DisconnectListener): this;
|
||||
@@ -869,6 +875,7 @@ declare namespace NodeJS {
|
||||
on(event: Signals, listener: SignalsListener): this;
|
||||
on(event: "newListener", listener: NewListenerListener): this;
|
||||
on(event: "removeListener", listener: RemoveListenerListener): this;
|
||||
on(event: "multipleResolves", listener: MultipleResolveListener): this;
|
||||
|
||||
once(event: "beforeExit", listener: BeforeExitListener): this;
|
||||
once(event: "disconnect", listener: DisconnectListener): this;
|
||||
@@ -881,6 +888,7 @@ declare namespace NodeJS {
|
||||
once(event: Signals, listener: SignalsListener): this;
|
||||
once(event: "newListener", listener: NewListenerListener): this;
|
||||
once(event: "removeListener", listener: RemoveListenerListener): this;
|
||||
once(event: "multipleResolves", listener: MultipleResolveListener): this;
|
||||
|
||||
prependListener(event: "beforeExit", listener: BeforeExitListener): this;
|
||||
prependListener(event: "disconnect", listener: DisconnectListener): this;
|
||||
@@ -893,6 +901,7 @@ declare namespace NodeJS {
|
||||
prependListener(event: Signals, listener: SignalsListener): this;
|
||||
prependListener(event: "newListener", listener: NewListenerListener): this;
|
||||
prependListener(event: "removeListener", listener: RemoveListenerListener): this;
|
||||
prependListener(event: "multipleResolves", listener: MultipleResolveListener): this;
|
||||
|
||||
prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this;
|
||||
prependOnceListener(event: "disconnect", listener: DisconnectListener): this;
|
||||
@@ -905,6 +914,7 @@ declare namespace NodeJS {
|
||||
prependOnceListener(event: Signals, listener: SignalsListener): this;
|
||||
prependOnceListener(event: "newListener", listener: NewListenerListener): this;
|
||||
prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this;
|
||||
prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this;
|
||||
|
||||
listeners(event: "beforeExit"): BeforeExitListener[];
|
||||
listeners(event: "disconnect"): DisconnectListener[];
|
||||
@@ -917,6 +927,7 @@ declare namespace NodeJS {
|
||||
listeners(event: Signals): SignalsListener[];
|
||||
listeners(event: "newListener"): NewListenerListener[];
|
||||
listeners(event: "removeListener"): RemoveListenerListener[];
|
||||
listeners(event: "multipleResolves"): MultipleResolveListener[];
|
||||
}
|
||||
|
||||
interface Global {
|
||||
@@ -1006,6 +1017,7 @@ declare namespace NodeJS {
|
||||
class Module {
|
||||
static runMain(): void;
|
||||
static wrap(code: string): string;
|
||||
static createRequireFromPath(path: string): (path: string) => any;
|
||||
static builtinModules: string[];
|
||||
|
||||
static Module: typeof Module;
|
||||
@@ -2618,6 +2630,20 @@ declare module "url" {
|
||||
function domainToASCII(domain: string): string;
|
||||
function domainToUnicode(domain: string): string;
|
||||
|
||||
/**
|
||||
* This function ensures the correct decodings of percent-encoded characters as
|
||||
* well as ensuring a cross-platform valid absolute path string.
|
||||
* @param url The file URL string or URL object to convert to a path.
|
||||
*/
|
||||
function fileURLToPath(url: string | URL): string;
|
||||
|
||||
/**
|
||||
* This function ensures that path is resolved absolutely, and that the URL
|
||||
* control characters are correctly encoded when converting into a File URL.
|
||||
* @param url The path to convert to a File URL.
|
||||
*/
|
||||
function pathToFileURL(url: string): URL;
|
||||
|
||||
interface URLFormatOptions {
|
||||
auth?: boolean;
|
||||
fragment?: boolean;
|
||||
@@ -3994,12 +4020,25 @@ declare module "fs" {
|
||||
*/
|
||||
function rmdirSync(path: PathLike): void;
|
||||
|
||||
export interface MakeDirectoryOptions {
|
||||
/**
|
||||
* Indicates whether parent folders should be created.
|
||||
* @default false
|
||||
*/
|
||||
recursive?: boolean;
|
||||
/**
|
||||
* A file mode. If a string is passed, it is parsed as an octal integer. If not specified
|
||||
* @default 0o777.
|
||||
*/
|
||||
mode?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronous mkdir(2) - create a directory.
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
||||
*/
|
||||
function mkdir(path: PathLike, mode: number | string | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
|
||||
function mkdir(path: PathLike, mode: number | string | MakeDirectoryOptions | undefined | null, callback: (err: NodeJS.ErrnoException) => void): void;
|
||||
|
||||
/**
|
||||
* Asynchronous mkdir(2) - create a directory with a mode of `0o777`.
|
||||
@@ -4014,7 +4053,7 @@ declare module "fs" {
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
||||
*/
|
||||
function __promisify__(path: PathLike, mode?: number | string | null): Promise<void>;
|
||||
function __promisify__(path: PathLike, mode?: number | string | MakeDirectoryOptions | null): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4022,7 +4061,7 @@ declare module "fs" {
|
||||
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
||||
* @param mode A file mode. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
||||
*/
|
||||
function mkdirSync(path: PathLike, mode?: number | string | null): void;
|
||||
function mkdirSync(path: PathLike, mode?: number | string | MakeDirectoryOptions | null): void;
|
||||
|
||||
/**
|
||||
* Asynchronously creates a unique temporary directory.
|
||||
@@ -6349,6 +6388,88 @@ declare module "crypto" {
|
||||
function timingSafeEqual(a: Buffer | NodeJS.TypedArray | DataView, b: Buffer | NodeJS.TypedArray | DataView): boolean;
|
||||
/** @deprecated since v10.0.0 */
|
||||
const DEFAULT_ENCODING: string;
|
||||
|
||||
export type KeyType = 'rsa' | 'dsa' | 'ec';
|
||||
export type KeyFormat = 'pem' | 'der';
|
||||
|
||||
interface BasePrivateKeyEncodingOptions<T extends KeyFormat> {
|
||||
format: T;
|
||||
ciper: string;
|
||||
passphrase: string;
|
||||
}
|
||||
|
||||
interface RSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
||||
/**
|
||||
* Key size in bits
|
||||
*/
|
||||
modulusLength: number;
|
||||
/**
|
||||
* @default 0x10001
|
||||
*/
|
||||
publicExponent?: number;
|
||||
|
||||
publicKeyEncoding: {
|
||||
type: 'pkcs1' | 'spki';
|
||||
format: PubF;
|
||||
};
|
||||
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
||||
type: 'pkcs1' | 'pkcs8';
|
||||
};
|
||||
}
|
||||
|
||||
interface DSAKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
||||
/**
|
||||
* Key size in bits
|
||||
*/
|
||||
modulusLength: number;
|
||||
/**
|
||||
* Size of q in bits
|
||||
*/
|
||||
divisorLength: number;
|
||||
|
||||
publicKeyEncoding: {
|
||||
type: 'spki';
|
||||
format: PubF;
|
||||
};
|
||||
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
||||
type: 'pkcs8';
|
||||
};
|
||||
}
|
||||
|
||||
interface ECKeyPairOptions<PubF extends KeyFormat, PrivF extends KeyFormat> {
|
||||
/**
|
||||
* Name of the curve to use.
|
||||
*/
|
||||
namedCurve: string;
|
||||
|
||||
publicKeyEncoding: {
|
||||
type: 'pkcs1' | 'spki';
|
||||
format: PubF;
|
||||
};
|
||||
privateKeyEncoding: BasePrivateKeyEncodingOptions<PrivF> & {
|
||||
type: 'sec1' | 'pkcs8';
|
||||
};
|
||||
}
|
||||
|
||||
interface KeyPairSyncResult<T1 extends string | Buffer, T2 extends string | Buffer> {
|
||||
publicKey: T1;
|
||||
privateKey: T2;
|
||||
}
|
||||
|
||||
function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
|
||||
function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
|
||||
function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
|
||||
function generateKeyPairSync(type: 'rsa', options: RSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
|
||||
|
||||
function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
|
||||
function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
|
||||
function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
|
||||
function generateKeyPairSync(type: 'dsa', options: DSAKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
|
||||
|
||||
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'pem'>): KeyPairSyncResult<string, string>;
|
||||
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'pem', 'der'>): KeyPairSyncResult<string, Buffer>;
|
||||
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'pem'>): KeyPairSyncResult<Buffer, string>;
|
||||
function generateKeyPairSync(type: 'ec', options: ECKeyPairOptions<'der', 'der'>): KeyPairSyncResult<Buffer, Buffer>;
|
||||
}
|
||||
|
||||
declare module "stream" {
|
||||
@@ -7665,6 +7786,7 @@ declare module "http2" {
|
||||
addListener(event: "localSettings", listener: (settings: Settings) => void): this;
|
||||
addListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
|
||||
addListener(event: "timeout", listener: () => void): this;
|
||||
addListener(event: "ping", listener: () => void): this;
|
||||
|
||||
emit(event: string | symbol, ...args: any[]): boolean;
|
||||
emit(event: "close"): boolean;
|
||||
@@ -7674,6 +7796,7 @@ declare module "http2" {
|
||||
emit(event: "localSettings", settings: Settings): boolean;
|
||||
emit(event: "remoteSettings", settings: Settings): boolean;
|
||||
emit(event: "timeout"): boolean;
|
||||
emit(event: "ping"): boolean;
|
||||
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
@@ -7683,6 +7806,7 @@ declare module "http2" {
|
||||
on(event: "localSettings", listener: (settings: Settings) => void): this;
|
||||
on(event: "remoteSettings", listener: (settings: Settings) => void): this;
|
||||
on(event: "timeout", listener: () => void): this;
|
||||
on(event: "ping", listener: () => void): this;
|
||||
|
||||
once(event: string, listener: (...args: any[]) => void): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
@@ -7692,6 +7816,7 @@ declare module "http2" {
|
||||
once(event: "localSettings", listener: (settings: Settings) => void): this;
|
||||
once(event: "remoteSettings", listener: (settings: Settings) => void): this;
|
||||
once(event: "timeout", listener: () => void): this;
|
||||
once(event: "ping", listener: () => void): this;
|
||||
|
||||
prependListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
@@ -7701,6 +7826,7 @@ declare module "http2" {
|
||||
prependListener(event: "localSettings", listener: (settings: Settings) => void): this;
|
||||
prependListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
|
||||
prependListener(event: "timeout", listener: () => void): this;
|
||||
prependListener(event: "ping", listener: () => void): this;
|
||||
|
||||
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
@@ -7710,6 +7836,7 @@ declare module "http2" {
|
||||
prependOnceListener(event: "localSettings", listener: (settings: Settings) => void): this;
|
||||
prependOnceListener(event: "remoteSettings", listener: (settings: Settings) => void): this;
|
||||
prependOnceListener(event: "timeout", listener: () => void): this;
|
||||
prependOnceListener(event: "ping", listener: () => void): this;
|
||||
}
|
||||
|
||||
export interface ClientHttp2Session extends Http2Session {
|
||||
|
||||
@@ -414,6 +414,19 @@ import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer } from "buff
|
||||
const cf = util.promisify(fs.copyFile);
|
||||
cf('/path/to/src', '/path/to/dest', fs.constants.COPYFILE_EXCL).then(console.log);
|
||||
}
|
||||
|
||||
{
|
||||
fs.mkdir('some/test/path', {
|
||||
recursive: true,
|
||||
mode: 0o777,
|
||||
}, () => {
|
||||
});
|
||||
|
||||
fs.mkdirSync('some/test/path', {
|
||||
recursive: true,
|
||||
mode: 0o777,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
@@ -763,6 +776,15 @@ function bufferTests() {
|
||||
]);
|
||||
assert.equal(params.toString(), 'user=abc&query=first&query=second');
|
||||
}
|
||||
|
||||
{
|
||||
let path: string = url.fileURLToPath('file://test');
|
||||
path = url.fileURLToPath(new url.URL('file://test'));
|
||||
}
|
||||
|
||||
{
|
||||
const path: url.URL = url.pathToFileURL('file://test');
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
@@ -781,7 +803,10 @@ function bufferTests() {
|
||||
showProxy: true,
|
||||
maxArrayLength: 10,
|
||||
breakLength: 20,
|
||||
compact: true
|
||||
compact: true,
|
||||
sorted(a, b) {
|
||||
return b.localeCompare(a);
|
||||
},
|
||||
});
|
||||
util.inspect(["This is nice"], {
|
||||
colors: true,
|
||||
@@ -790,7 +815,8 @@ function bufferTests() {
|
||||
showProxy: true,
|
||||
maxArrayLength: null,
|
||||
breakLength: Infinity,
|
||||
compact: false
|
||||
compact: false,
|
||||
sorted: true,
|
||||
});
|
||||
assert(typeof util.inspect.custom === 'symbol');
|
||||
|
||||
@@ -1475,6 +1501,60 @@ async function asyncStreamPipelineFinished() {
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "compressed");
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "hybrid");
|
||||
}
|
||||
|
||||
{
|
||||
const rsaRes: {
|
||||
publicKey: Buffer;
|
||||
privateKey: string;
|
||||
} = crypto.generateKeyPairSync('rsa', {
|
||||
modulusLength: 123,
|
||||
publicKeyEncoding: {
|
||||
format: 'der',
|
||||
type: 'pkcs1',
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
ciper: 'some-cipher',
|
||||
format: 'pem',
|
||||
passphrase: 'secret',
|
||||
type: 'pkcs8',
|
||||
},
|
||||
});
|
||||
|
||||
const dsaRes: {
|
||||
publicKey: string;
|
||||
privateKey: Buffer;
|
||||
} = crypto.generateKeyPairSync('dsa', {
|
||||
modulusLength: 123,
|
||||
divisorLength: 123,
|
||||
publicKeyEncoding: {
|
||||
format: 'pem',
|
||||
type: 'spki',
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
ciper: 'some-cipher',
|
||||
format: 'der',
|
||||
passphrase: 'secret',
|
||||
type: 'pkcs8',
|
||||
},
|
||||
});
|
||||
|
||||
const ecRes: {
|
||||
publicKey: string;
|
||||
privateKey: string;
|
||||
} = crypto.generateKeyPairSync('ec', {
|
||||
namedCurve: 'curve',
|
||||
publicKeyEncoding: {
|
||||
format: 'pem',
|
||||
type: 'pkcs1',
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
ciper: 'some-cipher',
|
||||
format: 'pem',
|
||||
passphrase: 'secret',
|
||||
type: 'pkcs8',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
@@ -3087,6 +3167,7 @@ import * as p from "process";
|
||||
process.prependOnceListener("SIGBREAK", () => { });
|
||||
process.on("newListener", (event: string | symbol, listener: Function) => { });
|
||||
process.once("removeListener", (event: string | symbol, listener: Function) => { });
|
||||
process.on("multipleResolves", (type: NodeJS.MultipleResolveType, prom: Promise<any>, value: any) => {});
|
||||
|
||||
const listeners = process.listeners('uncaughtException');
|
||||
const oldHandler = listeners[listeners.length - 1];
|
||||
@@ -3863,6 +3944,7 @@ import * as constants from 'constants';
|
||||
http2Session.on('remoteSettings', (settings: http2.Settings) => {});
|
||||
http2Session.on('stream', (stream: http2.Http2Stream, headers: http2.IncomingHttpHeaders, flags: number) => {});
|
||||
http2Session.on('timeout', () => {});
|
||||
http2Session.on('ping', () => {});
|
||||
|
||||
http2Session.destroy();
|
||||
|
||||
@@ -4440,6 +4522,7 @@ import * as constants from 'constants';
|
||||
////////////////////////////////////////////////////
|
||||
/// module tests : http://nodejs.org/api/modules.html
|
||||
////////////////////////////////////////////////////
|
||||
import moduleModule = require('module');
|
||||
|
||||
{
|
||||
require.extensions[".ts"] = () => "";
|
||||
@@ -4452,6 +4535,8 @@ import * as constants from 'constants';
|
||||
const b: string[] = Module.builtinModules;
|
||||
let paths: string[] = module.paths;
|
||||
paths = m1.paths;
|
||||
|
||||
moduleModule.createRequireFromPath('./test')('test');
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user