Skip to content

Commit 89a6a4e

Browse files
committed
Update VM arguments with backward compatibility
1 parent 2cfdefc commit 89a6a4e

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

0.12/node.d.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -958,17 +958,26 @@ declare module "readline" {
958958
declare module "vm" {
959959
export interface Context {}
960960

961+
export interface ScriptOptions {
962+
filename?: string;
963+
displayErrors?: boolean;
964+
}
965+
966+
export interface RunInContextOptions extends ScriptOptions {
967+
timeout?: number;
968+
}
969+
961970
export class Script {
962-
constructor (code: string, filename?: string);
971+
constructor (code: string, options?: string | ScriptOptions);
963972
runInThisContext(): void;
964973
runInNewContext(sandbox?: Context): void;
965974
}
966975

967-
export function runInThisContext(code: string, filename?: string): void;
968-
export function runInNewContext(code: string, sandbox?: Context, filename?: string): void;
969-
export function runInContext(code: string, context: Context, filename?: string): any;
976+
export function runInThisContext(code: string, options?: string | RunInContextOptions): void;
977+
export function runInNewContext(code: string, sandbox?: Context, options?: string | RunInContextOptions): void;
978+
export function runInContext(code: string, context: Context, options?: string | RunInContextOptions): any;
970979
export function createContext(initSandbox?: Context): Context;
971-
export function createScript(code: string, filename?: string): Script;
980+
export function createScript(code: string, options?: string | ScriptOptions): Script;
972981
}
973982

974983
declare module "child_process" {

4.0/node.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,22 +1202,22 @@ declare module "vm" {
12021202
}
12031203

12041204
export class Script {
1205-
constructor(code: string, options?: ScriptOptions);
1206-
runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any;
1207-
runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any;
1208-
runInThisContext(options?: RunningScriptOptions): any;
1205+
constructor(code: string, options?: string | ScriptOptions);
1206+
runInContext(contextifiedSandbox: Context, options?: string | RunningScriptOptions): any;
1207+
runInNewContext(sandbox?: Context, options?: string | RunningScriptOptions): any;
1208+
runInThisContext(options?: string | RunningScriptOptions): any;
12091209
}
12101210

12111211
export function createContext(sandbox?: Context): Context;
12121212
export function isContext(sandbox: Context): boolean;
1213-
export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any;
1213+
export function runInContext(code: string, contextifiedSandbox: Context, options?: string | RunningScriptOptions): any;
12141214
export function runInDebugContext(code: string): any;
1215-
export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any;
1216-
export function runInThisContext(code: string, options?: RunningScriptOptions): any;
1215+
export function runInNewContext(code: string, sandbox?: Context, options?: string | RunningScriptOptions): any;
1216+
export function runInThisContext(code: string, options?: string | RunningScriptOptions): any;
12171217
/**
12181218
* @deprecated
12191219
*/
1220-
export function createScript(code: string, filename?: string): Script;
1220+
export function createScript(code: string, options?: string | ScriptOptions): Script;
12211221
}
12221222

12231223
declare module "child_process" {

6.0/node.d.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,22 +1229,22 @@ declare module "vm" {
12291229
}
12301230

12311231
export class Script {
1232-
constructor(code: string, options?: ScriptOptions);
1232+
constructor(code: string, options?: string | ScriptOptions);
12331233
runInContext(contextifiedSandbox: Context, options?: RunInContextOptions): any;
12341234
runInNewContext(sandbox?: Context, options?: RunInNewContextOptions): any;
12351235
runInThisContext(options?: RunInNewContextOptions): any;
12361236
}
12371237

12381238
export function createContext(sandbox?: Context): Context;
12391239
export function isContext(sandbox: Context): boolean;
1240-
export function runInContext(code: string, contextifiedSandbox: Context, options?: RunInNewContextOptions): any;
1240+
export function runInContext(code: string, contextifiedSandbox: Context, options?: string | RunInNewContextOptions): any;
12411241
export function runInDebugContext(code: string): any;
1242-
export function runInNewContext(code: string, sandbox?: Context, options?: RunInNewContextOptions): any;
1243-
export function runInThisContext(code: string, options?: RunInNewContextOptions): any;
1242+
export function runInNewContext(code: string, sandbox?: Context, options?: string | RunInNewContextOptions): any;
1243+
export function runInThisContext(code: string, options?: string | RunInNewContextOptions): any;
12441244
/**
12451245
* @deprecated
12461246
*/
1247-
export function createScript(code: string, filename?: string): Script;
1247+
export function createScript(code: string, options?: string | ScriptOptions): Script;
12481248
}
12491249

12501250
declare module "child_process" {

0 commit comments

Comments
 (0)