mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
Extendable interfaces for require, module.require
Node's `require` should implement a new interface `NodeRequire` (rather than direct signature) for specialized extension by other libraries #4740
This commit is contained in:
17
node/node.d.ts
vendored
17
node/node.d.ts
vendored
@@ -27,23 +27,30 @@ declare function clearInterval(intervalId: NodeJS.Timer): void;
|
||||
declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
|
||||
declare function clearImmediate(immediateId: any): void;
|
||||
|
||||
declare var require: {
|
||||
interface NodeRequireFunction {
|
||||
(id: string): any;
|
||||
}
|
||||
|
||||
interface NodeRequire extends NodeRequireFunction {
|
||||
resolve(id:string): string;
|
||||
cache: any;
|
||||
extensions: any;
|
||||
main: any;
|
||||
};
|
||||
}
|
||||
|
||||
declare var module: {
|
||||
declare var require: NodeRequire;
|
||||
|
||||
interface NodeModule {
|
||||
exports: any;
|
||||
require(id: string): any;
|
||||
require: NodeRequireFunction;
|
||||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
parent: any;
|
||||
children: any[];
|
||||
};
|
||||
}
|
||||
|
||||
declare var module: NodeModule;
|
||||
|
||||
// Same as module.exports
|
||||
declare var exports: any;
|
||||
|
||||
Reference in New Issue
Block a user