mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[node] Allow augmentation of module (#19612)
* [node] Allow augmentation of module - move class Module into NodeJS namespace - add Module.Module * update according to review findings
This commit is contained in:
parent
b33e2349e2
commit
616c84c0e7
36
types/node/index.d.ts
vendored
36
types/node/index.d.ts
vendored
@ -679,6 +679,24 @@ declare namespace NodeJS {
|
||||
ref(): void;
|
||||
unref(): void;
|
||||
}
|
||||
|
||||
class Module {
|
||||
static runMain(): void;
|
||||
static wrap(code: string): string;
|
||||
|
||||
static Module: typeof Module;
|
||||
|
||||
exports: any;
|
||||
require: NodeRequireFunction;
|
||||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
parent: Module | null;
|
||||
children: Module[];
|
||||
paths: string[];
|
||||
|
||||
constructor(id: string, parent?: Module);
|
||||
}
|
||||
}
|
||||
|
||||
interface IterableIterator<T> { }
|
||||
@ -5627,23 +5645,7 @@ declare module "constants" {
|
||||
}
|
||||
|
||||
declare module "module" {
|
||||
class Module implements NodeModule {
|
||||
static runMain(): void;
|
||||
static wrap(code: string): string;
|
||||
|
||||
exports: any;
|
||||
require: NodeRequireFunction;
|
||||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
parent: NodeModule | null;
|
||||
children: NodeModule[];
|
||||
paths: string[];
|
||||
|
||||
constructor(id: string, parent?: Module);
|
||||
}
|
||||
|
||||
export = Module;
|
||||
export = NodeJS.Module;
|
||||
}
|
||||
|
||||
declare module "process" {
|
||||
|
||||
@ -3466,7 +3466,8 @@ namespace module_tests {
|
||||
require.extensions[".ts"] = () => "";
|
||||
|
||||
Module.runMain();
|
||||
Module.wrap("some code");
|
||||
const s: string = Module.wrap("some code");
|
||||
|
||||
const m1 = new Module("moduleId");
|
||||
const m1: Module = new Module("moduleId");
|
||||
const m2: Module = new Module.Module("moduleId");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user