mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
Add process.mainModule, improve NodeModule (#12257)
* Add process.mainModule, improve NodeModule Add mainModule in process. See https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_process_mainmodule improve require.main see https://nodejs.org/dist/latest-v6.x/docs/api/modules.html#modules_accessing_the_main_module improve NodeModule see https://nodejs.org/dist/latest-v6.x/docs/api/modules.html#modules_module_children and https://nodejs.org/dist/latest-v6.x/docs/api/modules.html#modules_module_parent * Correct require.main and NodeModule
This commit is contained in:
@@ -24,6 +24,19 @@ import * as string_decoder from "string_decoder";
|
||||
// Specifically test buffer module regression.
|
||||
import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer";
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
/// Global Tests : https://nodejs.org/api/global.html ///
|
||||
//////////////////////////////////////////////////////////
|
||||
namespace global_tests {
|
||||
{
|
||||
let x: NodeModule;
|
||||
let y: NodeModule;
|
||||
x.children.push(y);
|
||||
x.parent = require.main;
|
||||
require.main = y;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
/// Assert Tests : https://nodejs.org/api/assert.html ///
|
||||
//////////////////////////////////////////////////////////
|
||||
@@ -922,6 +935,10 @@ namespace process_tests {
|
||||
var _p: NodeJS.Process = process;
|
||||
_p = p;
|
||||
}
|
||||
{
|
||||
var module: NodeModule;
|
||||
module = process.mainModule;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
Vendored
+4
-3
@@ -52,7 +52,7 @@ interface NodeRequire extends NodeRequireFunction {
|
||||
resolve(id:string): string;
|
||||
cache: any;
|
||||
extensions: any;
|
||||
main: any;
|
||||
main: NodeModule;
|
||||
}
|
||||
|
||||
declare var require: NodeRequire;
|
||||
@@ -63,8 +63,8 @@ interface NodeModule {
|
||||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
parent: any;
|
||||
children: any[];
|
||||
parent: NodeModule;
|
||||
children: NodeModule[];
|
||||
}
|
||||
|
||||
declare var module: NodeModule;
|
||||
@@ -339,6 +339,7 @@ declare namespace NodeJS {
|
||||
title: string;
|
||||
arch: string;
|
||||
platform: string;
|
||||
mainModule?: NodeModule;
|
||||
memoryUsage(): MemoryUsage;
|
||||
nextTick(callback: Function): void;
|
||||
umask(mask?: number): number;
|
||||
|
||||
@@ -27,6 +27,19 @@ import * as repl from "repl";
|
||||
// Specifically test buffer module regression.
|
||||
import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer";
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
/// Global Tests : https://nodejs.org/api/global.html ///
|
||||
//////////////////////////////////////////////////////////
|
||||
namespace global_tests {
|
||||
{
|
||||
let x: NodeModule;
|
||||
let y: NodeModule;
|
||||
x.children.push(y);
|
||||
x.parent = require.main;
|
||||
require.main = y;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
/// Assert Tests : https://nodejs.org/api/assert.html ///
|
||||
//////////////////////////////////////////////////////////
|
||||
@@ -1554,6 +1567,10 @@ namespace process_tests {
|
||||
{
|
||||
assert(process.argv[0] === process.argv0);
|
||||
}
|
||||
{
|
||||
var module: NodeModule;
|
||||
module = process.mainModule;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
Vendored
+4
-3
@@ -52,7 +52,7 @@ interface NodeRequire extends NodeRequireFunction {
|
||||
resolve(id: string): string;
|
||||
cache: any;
|
||||
extensions: any;
|
||||
main: any;
|
||||
main: NodeModule;
|
||||
}
|
||||
|
||||
declare var require: NodeRequire;
|
||||
@@ -63,8 +63,8 @@ interface NodeModule {
|
||||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
parent: any;
|
||||
children: any[];
|
||||
parent: NodeModule;
|
||||
children: NodeModule[];
|
||||
}
|
||||
|
||||
declare var module: NodeModule;
|
||||
@@ -372,6 +372,7 @@ declare namespace NodeJS {
|
||||
title: string;
|
||||
arch: string;
|
||||
platform: string;
|
||||
mainModule?: NodeModule;
|
||||
memoryUsage(): MemoryUsage;
|
||||
nextTick(callback: Function, ...args: any[]): void;
|
||||
umask(mask?: number): number;
|
||||
|
||||
Reference in New Issue
Block a user