From e0ba98cf88505c01aa235e29c05d5407e8aa5f93 Mon Sep 17 00:00:00 2001 From: Howard Mak Date: Mon, 4 Dec 2017 23:36:28 -0500 Subject: [PATCH 1/7] Add signature for Error.prepareStackTrace() as per https://github.com/v8/v8/wiki/Stack%20Trace%20API --- types/node/index.d.ts | 21 +++++++++++++++++++++ types/node/node-tests.ts | 4 ++++ types/node/v4/index.d.ts | 21 +++++++++++++++++++++ types/node/v4/node-tests.ts | 4 ++++ types/node/v6/index.d.ts | 21 +++++++++++++++++++++ types/node/v6/node-tests.ts | 4 ++++ types/node/v7/index.d.ts | 21 +++++++++++++++++++++ types/node/v7/node-tests.ts | 4 ++++ 8 files changed, 100 insertions(+) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 1d79e782d2..814de3dc48 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -45,8 +45,13 @@ interface Error { stack?: string; } +// Declare "static" methods in Error interface ErrorConstructor { captureStackTrace(targetObject: Object, constructorOpt?: Function): void; + + // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + prepareStackTrace?: (err: Error, stackTraces: NodeJS.StackFrame[]) => any; + stackTraceLimit: number; } @@ -311,6 +316,22 @@ declare namespace NodeJS { new(stdout: WritableStream, stderr?: WritableStream): Console; } + export interface StackFrame { + getThis: Function; // returns the value of this + getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. + getFunction: Function; // returns the current function + getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. + getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function + getFileName: Function; // if this function was defined in a script returns the name of the script + getLineNumber: Function; // if this function was defined in a script returns the current line number + getColumnNumber: Function; // if this function was defined in a script returns the current column number + getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called + isToplevel: boolean; // is this a toplevel invocation, that is, is this the global object? + isEval: boolean; // does this call take place in code defined by a call to eval? + isNative: boolean; // is this call in native V8 code? + isConstructor: boolean; // is this a constructor call? + } + export interface ErrnoException extends Error { errno?: number; code?: string; diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index d85a2574db..c61b581b0b 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -2425,6 +2425,10 @@ namespace errors_tests { const myObject = {}; Error.captureStackTrace(myObject); } + { + let frames: NodeJS.StackFrame[] = []; + Error.prepareStackTrace(new Error(), frames); + } } /////////////////////////////////////////////////////////// diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 797bc455b8..92dcfb1313 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -34,8 +34,13 @@ interface Error { stack?: string; } +// Declare "static" methods in Error interface ErrorConstructor { captureStackTrace(targetObject: Object, constructorOpt?: Function): void; + + // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + prepareStackTrace?: (err: Error, stackTraces: NodeJS.StackFrame[]) => any; + stackTraceLimit: number; } @@ -229,6 +234,22 @@ declare namespace NodeJS { customInspect?: boolean; } + export interface StackFrame { + getThis: Function; // returns the value of this + getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. + getFunction: Function; // returns the current function + getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. + getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function + getFileName: Function; // if this function was defined in a script returns the name of the script + getLineNumber: Function; // if this function was defined in a script returns the current line number + getColumnNumber: Function; // if this function was defined in a script returns the current column number + getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called + isToplevel: boolean; // is this a toplevel invocation, that is, is this the global object? + isEval: boolean; // does this call take place in code defined by a call to eval? + isNative: boolean; // is this call in native V8 code? + isConstructor: boolean; // is this a constructor call? + } + export interface ErrnoException extends Error { errno?: number; code?: string; diff --git a/types/node/v4/node-tests.ts b/types/node/v4/node-tests.ts index 8f005da455..cb16ae90d3 100644 --- a/types/node/v4/node-tests.ts +++ b/types/node/v4/node-tests.ts @@ -1008,6 +1008,10 @@ namespace errors_tests { const myObject = {}; Error.captureStackTrace(myObject); } + { + let frames: NodeJS.StackFrame[] = []; + Error.prepareStackTrace(new Error(), frames); + } } /////////////////////////////////////////////////////////// diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index e8931e43cf..888685c7ea 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -31,8 +31,13 @@ interface Error { stack?: string; } +// Declare "static" methods in Error interface ErrorConstructor { captureStackTrace(targetObject: Object, constructorOpt?: Function): void; + + // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + prepareStackTrace?: (err: Error, stackTraces: NodeJS.StackFrame[]) => any; + stackTraceLimit: number; } @@ -258,6 +263,22 @@ declare namespace NodeJS { new(stdout: WritableStream, stderr?: WritableStream): Console; } + export interface StackFrame { + getThis: Function; // returns the value of this + getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. + getFunction: Function; // returns the current function + getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. + getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function + getFileName: Function; // if this function was defined in a script returns the name of the script + getLineNumber: Function; // if this function was defined in a script returns the current line number + getColumnNumber: Function; // if this function was defined in a script returns the current column number + getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called + isToplevel: boolean; // is this a toplevel invocation, that is, is this the global object? + isEval: boolean; // does this call take place in code defined by a call to eval? + isNative: boolean; // is this call in native V8 code? + isConstructor: boolean; // is this a constructor call? + } + export interface ErrnoException extends Error { errno?: number; code?: string; diff --git a/types/node/v6/node-tests.ts b/types/node/v6/node-tests.ts index 1a6b87db05..88b09a98d3 100644 --- a/types/node/v6/node-tests.ts +++ b/types/node/v6/node-tests.ts @@ -1829,6 +1829,10 @@ namespace errors_tests { const myObject = {}; Error.captureStackTrace(myObject); } + { + let frames: NodeJS.StackFrame[] = []; + Error.prepareStackTrace(new Error(), frames); + } } /////////////////////////////////////////////////////////// diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index cc87fadd7c..62dee8ab50 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -32,8 +32,13 @@ interface Error { stack?: string; } +// Declare "static" methods in Error interface ErrorConstructor { captureStackTrace(targetObject: Object, constructorOpt?: Function): void; + + // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + prepareStackTrace?: (err: Error, stackTraces: NodeJS.StackFrame[]) => any; + stackTraceLimit: number; } @@ -270,6 +275,22 @@ declare namespace NodeJS { new(stdout: WritableStream, stderr?: WritableStream): Console; } + export interface StackFrame { + getThis: Function; // returns the value of this + getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. + getFunction: Function; // returns the current function + getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. + getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function + getFileName: Function; // if this function was defined in a script returns the name of the script + getLineNumber: Function; // if this function was defined in a script returns the current line number + getColumnNumber: Function; // if this function was defined in a script returns the current column number + getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called + isToplevel: boolean; // is this a toplevel invocation, that is, is this the global object? + isEval: boolean; // does this call take place in code defined by a call to eval? + isNative: boolean; // is this call in native V8 code? + isConstructor: boolean; // is this a constructor call? + } + export interface ErrnoException extends Error { errno?: number; code?: string; diff --git a/types/node/v7/node-tests.ts b/types/node/v7/node-tests.ts index 9bbf6a9300..db0fb4c544 100644 --- a/types/node/v7/node-tests.ts +++ b/types/node/v7/node-tests.ts @@ -1931,6 +1931,10 @@ namespace errors_tests { const myObject = {}; Error.captureStackTrace(myObject); } + { + let frames: NodeJS.StackFrame[] = []; + Error.prepareStackTrace(new Error(), frames); + } } /////////////////////////////////////////////////////////// From 658b8af52211d0a4ef345cdd82785c982692c13a Mon Sep 17 00:00:00 2001 From: Howard Mak Date: Tue, 5 Dec 2017 14:33:37 -0500 Subject: [PATCH 2/7] Rename NodeJS.StackFrame -> CallSite to match documentation --- types/node/index.d.ts | 4 ++-- types/node/node-tests.ts | 2 +- types/node/v4/index.d.ts | 4 ++-- types/node/v4/node-tests.ts | 2 +- types/node/v6/index.d.ts | 4 ++-- types/node/v6/node-tests.ts | 2 +- types/node/v7/index.d.ts | 4 ++-- types/node/v7/node-tests.ts | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 814de3dc48..54ada1a5d4 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -50,7 +50,7 @@ interface ErrorConstructor { captureStackTrace(targetObject: Object, constructorOpt?: Function): void; // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces - prepareStackTrace?: (err: Error, stackTraces: NodeJS.StackFrame[]) => any; + prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any; stackTraceLimit: number; } @@ -316,7 +316,7 @@ declare namespace NodeJS { new(stdout: WritableStream, stderr?: WritableStream): Console; } - export interface StackFrame { + export interface CallSite { getThis: Function; // returns the value of this getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. getFunction: Function; // returns the current function diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index c61b581b0b..7b403489db 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -2426,7 +2426,7 @@ namespace errors_tests { Error.captureStackTrace(myObject); } { - let frames: NodeJS.StackFrame[] = []; + let frames: NodeJS.CallSite[] = []; Error.prepareStackTrace(new Error(), frames); } } diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 92dcfb1313..3959bd2d33 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -39,7 +39,7 @@ interface ErrorConstructor { captureStackTrace(targetObject: Object, constructorOpt?: Function): void; // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces - prepareStackTrace?: (err: Error, stackTraces: NodeJS.StackFrame[]) => any; + prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any; stackTraceLimit: number; } @@ -234,7 +234,7 @@ declare namespace NodeJS { customInspect?: boolean; } - export interface StackFrame { + export interface CallSite { getThis: Function; // returns the value of this getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. getFunction: Function; // returns the current function diff --git a/types/node/v4/node-tests.ts b/types/node/v4/node-tests.ts index cb16ae90d3..45e5dc3f7d 100644 --- a/types/node/v4/node-tests.ts +++ b/types/node/v4/node-tests.ts @@ -1009,7 +1009,7 @@ namespace errors_tests { Error.captureStackTrace(myObject); } { - let frames: NodeJS.StackFrame[] = []; + let frames: NodeJS.CallSite[] = []; Error.prepareStackTrace(new Error(), frames); } } diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 888685c7ea..0b36f2cc7b 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -36,7 +36,7 @@ interface ErrorConstructor { captureStackTrace(targetObject: Object, constructorOpt?: Function): void; // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces - prepareStackTrace?: (err: Error, stackTraces: NodeJS.StackFrame[]) => any; + prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any; stackTraceLimit: number; } @@ -263,7 +263,7 @@ declare namespace NodeJS { new(stdout: WritableStream, stderr?: WritableStream): Console; } - export interface StackFrame { + export interface CallSite { getThis: Function; // returns the value of this getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. getFunction: Function; // returns the current function diff --git a/types/node/v6/node-tests.ts b/types/node/v6/node-tests.ts index 88b09a98d3..646e34f348 100644 --- a/types/node/v6/node-tests.ts +++ b/types/node/v6/node-tests.ts @@ -1830,7 +1830,7 @@ namespace errors_tests { Error.captureStackTrace(myObject); } { - let frames: NodeJS.StackFrame[] = []; + let frames: NodeJS.CallSite[] = []; Error.prepareStackTrace(new Error(), frames); } } diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index 62dee8ab50..55bbe84bd8 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -37,7 +37,7 @@ interface ErrorConstructor { captureStackTrace(targetObject: Object, constructorOpt?: Function): void; // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces - prepareStackTrace?: (err: Error, stackTraces: NodeJS.StackFrame[]) => any; + prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any; stackTraceLimit: number; } @@ -275,7 +275,7 @@ declare namespace NodeJS { new(stdout: WritableStream, stderr?: WritableStream): Console; } - export interface StackFrame { + export interface CallSite { getThis: Function; // returns the value of this getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. getFunction: Function; // returns the current function diff --git a/types/node/v7/node-tests.ts b/types/node/v7/node-tests.ts index db0fb4c544..8985a2065e 100644 --- a/types/node/v7/node-tests.ts +++ b/types/node/v7/node-tests.ts @@ -1932,7 +1932,7 @@ namespace errors_tests { Error.captureStackTrace(myObject); } { - let frames: NodeJS.StackFrame[] = []; + let frames: NodeJS.CallSite[] = []; Error.prepareStackTrace(new Error(), frames); } } From 75dabcb90f6ab38c49e9524e91fd1f85d9d304be Mon Sep 17 00:00:00 2001 From: Howard Mak Date: Tue, 5 Dec 2017 14:43:26 -0500 Subject: [PATCH 3/7] Fix some CallSite properties to be functions not boolean values --- types/node/index.d.ts | 8 ++++---- types/node/v4/index.d.ts | 8 ++++---- types/node/v6/index.d.ts | 8 ++++---- types/node/v7/index.d.ts | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 54ada1a5d4..9daa447bef 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -326,10 +326,10 @@ declare namespace NodeJS { getLineNumber: Function; // if this function was defined in a script returns the current line number getColumnNumber: Function; // if this function was defined in a script returns the current column number getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called - isToplevel: boolean; // is this a toplevel invocation, that is, is this the global object? - isEval: boolean; // does this call take place in code defined by a call to eval? - isNative: boolean; // is this call in native V8 code? - isConstructor: boolean; // is this a constructor call? + isToplevel: Function; // is this a toplevel invocation, that is, is this the global object? + isEval: Function; // does this call take place in code defined by a call to eval? + isNative: Function; // is this call in native V8 code? + isConstructor: Function; // is this a constructor call? } export interface ErrnoException extends Error { diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 3959bd2d33..55d1b55376 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -244,10 +244,10 @@ declare namespace NodeJS { getLineNumber: Function; // if this function was defined in a script returns the current line number getColumnNumber: Function; // if this function was defined in a script returns the current column number getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called - isToplevel: boolean; // is this a toplevel invocation, that is, is this the global object? - isEval: boolean; // does this call take place in code defined by a call to eval? - isNative: boolean; // is this call in native V8 code? - isConstructor: boolean; // is this a constructor call? + isToplevel: Function; // is this a toplevel invocation, that is, is this the global object? + isEval: Function; // does this call take place in code defined by a call to eval? + isNative: Function; // is this call in native V8 code? + isConstructor: Function; // is this a constructor call? } export interface ErrnoException extends Error { diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 0b36f2cc7b..54a77a4044 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -273,10 +273,10 @@ declare namespace NodeJS { getLineNumber: Function; // if this function was defined in a script returns the current line number getColumnNumber: Function; // if this function was defined in a script returns the current column number getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called - isToplevel: boolean; // is this a toplevel invocation, that is, is this the global object? - isEval: boolean; // does this call take place in code defined by a call to eval? - isNative: boolean; // is this call in native V8 code? - isConstructor: boolean; // is this a constructor call? + isToplevel: Function; // is this a toplevel invocation, that is, is this the global object? + isEval: Function; // does this call take place in code defined by a call to eval? + isNative: Function; // is this call in native V8 code? + isConstructor: Function; // is this a constructor call? } export interface ErrnoException extends Error { diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index 55bbe84bd8..4bf98adf5e 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -285,10 +285,10 @@ declare namespace NodeJS { getLineNumber: Function; // if this function was defined in a script returns the current line number getColumnNumber: Function; // if this function was defined in a script returns the current column number getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called - isToplevel: boolean; // is this a toplevel invocation, that is, is this the global object? - isEval: boolean; // does this call take place in code defined by a call to eval? - isNative: boolean; // is this call in native V8 code? - isConstructor: boolean; // is this a constructor call? + isToplevel: Function; // is this a toplevel invocation, that is, is this the global object? + isEval: Function; // does this call take place in code defined by a call to eval? + isNative: Function; // is this call in native V8 code? + isConstructor: Function; // is this a constructor call? } export interface ErrnoException extends Error { From a30bc16f3c76441f6da51d147cd4b691662dc94f Mon Sep 17 00:00:00 2001 From: Howard Mak Date: Tue, 5 Dec 2017 14:54:29 -0500 Subject: [PATCH 4/7] Tighten signature for CallSite.getTypeName() --- types/node/index.d.ts | 2 +- types/node/node-tests.ts | 4 ++++ types/node/v4/index.d.ts | 2 +- types/node/v4/node-tests.ts | 4 ++++ types/node/v6/index.d.ts | 2 +- types/node/v6/node-tests.ts | 4 ++++ types/node/v7/index.d.ts | 2 +- types/node/v7/node-tests.ts | 4 ++++ 8 files changed, 20 insertions(+), 4 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 9daa447bef..c6fff0745a 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -318,7 +318,7 @@ declare namespace NodeJS { export interface CallSite { getThis: Function; // returns the value of this - getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. + getTypeName(): string; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. getFunction: Function; // returns the current function getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 7b403489db..59be8e5626 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -2429,6 +2429,10 @@ namespace errors_tests { let frames: NodeJS.CallSite[] = []; Error.prepareStackTrace(new Error(), frames); } + { + let frame: NodeJS.CallSite = null; + let typeName: string = frame.getTypeName(); + } } /////////////////////////////////////////////////////////// diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 55d1b55376..27809342c0 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -236,7 +236,7 @@ declare namespace NodeJS { export interface CallSite { getThis: Function; // returns the value of this - getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. + getTypeName(): string; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. getFunction: Function; // returns the current function getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function diff --git a/types/node/v4/node-tests.ts b/types/node/v4/node-tests.ts index 45e5dc3f7d..4d91d1536b 100644 --- a/types/node/v4/node-tests.ts +++ b/types/node/v4/node-tests.ts @@ -1012,6 +1012,10 @@ namespace errors_tests { let frames: NodeJS.CallSite[] = []; Error.prepareStackTrace(new Error(), frames); } + { + let frame: NodeJS.CallSite = null; + let typeName: string = frame.getTypeName(); + } } /////////////////////////////////////////////////////////// diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 54a77a4044..948fc7623f 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -265,7 +265,7 @@ declare namespace NodeJS { export interface CallSite { getThis: Function; // returns the value of this - getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. + getTypeName(): string; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. getFunction: Function; // returns the current function getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function diff --git a/types/node/v6/node-tests.ts b/types/node/v6/node-tests.ts index 646e34f348..d59de9b8cb 100644 --- a/types/node/v6/node-tests.ts +++ b/types/node/v6/node-tests.ts @@ -1833,6 +1833,10 @@ namespace errors_tests { let frames: NodeJS.CallSite[] = []; Error.prepareStackTrace(new Error(), frames); } + { + let frame: NodeJS.CallSite = null; + let typeName: string = frame.getTypeName(); + } } /////////////////////////////////////////////////////////// diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index 4bf98adf5e..c2f723d7df 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -277,7 +277,7 @@ declare namespace NodeJS { export interface CallSite { getThis: Function; // returns the value of this - getTypeName: Function; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. + getTypeName(): string; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. getFunction: Function; // returns the current function getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function diff --git a/types/node/v7/node-tests.ts b/types/node/v7/node-tests.ts index 8985a2065e..07d9e4b51e 100644 --- a/types/node/v7/node-tests.ts +++ b/types/node/v7/node-tests.ts @@ -1935,6 +1935,10 @@ namespace errors_tests { let frames: NodeJS.CallSite[] = []; Error.prepareStackTrace(new Error(), frames); } + { + let frame: NodeJS.CallSite = null; + let typeName: string = frame.getTypeName(); + } } /////////////////////////////////////////////////////////// From 4950326dd48bbc9da62d47b80f20e288e140856f Mon Sep 17 00:00:00 2001 From: Howard Mak Date: Thu, 7 Dec 2017 12:56:37 -0500 Subject: [PATCH 5/7] PR feedback: Add test for tighter CallSite signatures --- types/node/node-tests.ts | 12 ++++++++++++ types/node/v4/node-tests.ts | 12 ++++++++++++ types/node/v6/node-tests.ts | 12 ++++++++++++ types/node/v7/node-tests.ts | 12 ++++++++++++ 4 files changed, 48 insertions(+) diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 59be8e5626..b7c49f05d4 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -2431,7 +2431,19 @@ namespace errors_tests { } { let frame: NodeJS.CallSite = null; + let frameThis: any = frame.getThis(); let typeName: string = frame.getTypeName(); + let func: Function = frame.getFunction(); + let funcName: string = frame.getFunctionName(); + let meth: string = frame.getMethodName(); + let fname: string = frame.getFileName(); + let lineno: number = frame.getLineNumber(); + let colno: number = frame.getColumnNumber(); + let evalOrigin: string = frame.getEvalOrigin(); + let isTop: boolean = frame.isToplevel(); + let isEval: boolean = frame.isEval(); + let isNative: boolean = frame.isNative(); + let isConstr: boolean = frame.isConstructor(); } } diff --git a/types/node/v4/node-tests.ts b/types/node/v4/node-tests.ts index 4d91d1536b..16ef511186 100644 --- a/types/node/v4/node-tests.ts +++ b/types/node/v4/node-tests.ts @@ -1014,7 +1014,19 @@ namespace errors_tests { } { let frame: NodeJS.CallSite = null; + let frameThis: any = frame.getThis(); let typeName: string = frame.getTypeName(); + let func: Function = frame.getFunction(); + let funcName: string = frame.getFunctionName(); + let meth: string = frame.getMethodName(); + let fname: string = frame.getFileName(); + let lineno: number = frame.getLineNumber(); + let colno: number = frame.getColumnNumber(); + let evalOrigin: string = frame.getEvalOrigin(); + let isTop: boolean = frame.isToplevel(); + let isEval: boolean = frame.isEval(); + let isNative: boolean = frame.isNative(); + let isConstr: boolean = frame.isConstructor(); } } diff --git a/types/node/v6/node-tests.ts b/types/node/v6/node-tests.ts index d59de9b8cb..0f9a553e67 100644 --- a/types/node/v6/node-tests.ts +++ b/types/node/v6/node-tests.ts @@ -1835,7 +1835,19 @@ namespace errors_tests { } { let frame: NodeJS.CallSite = null; + let frameThis: any = frame.getThis(); let typeName: string = frame.getTypeName(); + let func: Function = frame.getFunction(); + let funcName: string = frame.getFunctionName(); + let meth: string = frame.getMethodName(); + let fname: string = frame.getFileName(); + let lineno: number = frame.getLineNumber(); + let colno: number = frame.getColumnNumber(); + let evalOrigin: string = frame.getEvalOrigin(); + let isTop: boolean = frame.isToplevel(); + let isEval: boolean = frame.isEval(); + let isNative: boolean = frame.isNative(); + let isConstr: boolean = frame.isConstructor(); } } diff --git a/types/node/v7/node-tests.ts b/types/node/v7/node-tests.ts index 07d9e4b51e..a65e032fb3 100644 --- a/types/node/v7/node-tests.ts +++ b/types/node/v7/node-tests.ts @@ -1937,7 +1937,19 @@ namespace errors_tests { } { let frame: NodeJS.CallSite = null; + let frameThis: any = frame.getThis(); let typeName: string = frame.getTypeName(); + let func: Function = frame.getFunction(); + let funcName: string = frame.getFunctionName(); + let meth: string = frame.getMethodName(); + let fname: string = frame.getFileName(); + let lineno: number = frame.getLineNumber(); + let colno: number = frame.getColumnNumber(); + let evalOrigin: string = frame.getEvalOrigin(); + let isTop: boolean = frame.isToplevel(); + let isEval: boolean = frame.isEval(); + let isNative: boolean = frame.isNative(); + let isConstr: boolean = frame.isConstructor(); } } From 4d1ff2f02e6f90964fe8768063d52c205454c34f Mon Sep 17 00:00:00 2001 From: Howard Mak Date: Thu, 7 Dec 2017 12:57:11 -0500 Subject: [PATCH 6/7] PR feedback: Tighten signatures for CallSite methods --- types/node/index.d.ts | 58 ++++++++++++++++++++++++++++++---------- types/node/v4/index.d.ts | 58 ++++++++++++++++++++++++++++++---------- types/node/v6/index.d.ts | 58 ++++++++++++++++++++++++++++++---------- types/node/v7/index.d.ts | 58 ++++++++++++++++++++++++++++++---------- 4 files changed, 176 insertions(+), 56 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index c6fff0745a..ec3ddb2864 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -47,9 +47,14 @@ interface Error { // Declare "static" methods in Error interface ErrorConstructor { + /** Create .stack property on a target object */ captureStackTrace(targetObject: Object, constructorOpt?: Function): void; - // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + /** + * Optional override for formatting stack traces + * + * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + */ prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any; stackTraceLimit: number; @@ -317,19 +322,44 @@ declare namespace NodeJS { } export interface CallSite { - getThis: Function; // returns the value of this - getTypeName(): string; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. - getFunction: Function; // returns the current function - getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. - getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function - getFileName: Function; // if this function was defined in a script returns the name of the script - getLineNumber: Function; // if this function was defined in a script returns the current line number - getColumnNumber: Function; // if this function was defined in a script returns the current column number - getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called - isToplevel: Function; // is this a toplevel invocation, that is, is this the global object? - isEval: Function; // does this call take place in code defined by a call to eval? - isNative: Function; // is this call in native V8 code? - isConstructor: Function; // is this a constructor call? + /** Value of this */ + getThis(): any; + + /** Type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. */ + getTypeName(): string | null; + + /** Current function */ + getFunction(): Function | undefined; + + /** Name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. */ + getFunctionName(): string | null; + + /** Name of the property [of this or one of its prototypes] that holds the current function */ + getMethodName(): string | null; + + /** Name of the script [if this function was defined in a script] */ + getFileName(): string | null; + + /** Current line number [if this function was defined in a script] */ + getLineNumber(): number | null; + + /** Current column number [if this function was defined in a script] */ + getColumnNumber(): number | null; + + /** A call site object representing the location where eval was called [if this function was created using a call to eval] */ + getEvalOrigin(): string | undefined; + + /** Is this a toplevel invocation, that is, is this the global object? */ + isToplevel(): boolean; + + /** Does this call take place in code defined by a call to eval? */ + isEval(): boolean; + + /** Is this call in native V8 code? */ + isNative(): boolean; + + /** Is this a constructor call? */ + isConstructor(): boolean; } export interface ErrnoException extends Error { diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 27809342c0..30e5c16d9b 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -36,9 +36,14 @@ interface Error { // Declare "static" methods in Error interface ErrorConstructor { + /** Create .stack property on a target object */ captureStackTrace(targetObject: Object, constructorOpt?: Function): void; - // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + /** + * Optional override for formatting stack traces + * + * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + */ prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any; stackTraceLimit: number; @@ -235,19 +240,44 @@ declare namespace NodeJS { } export interface CallSite { - getThis: Function; // returns the value of this - getTypeName(): string; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. - getFunction: Function; // returns the current function - getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. - getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function - getFileName: Function; // if this function was defined in a script returns the name of the script - getLineNumber: Function; // if this function was defined in a script returns the current line number - getColumnNumber: Function; // if this function was defined in a script returns the current column number - getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called - isToplevel: Function; // is this a toplevel invocation, that is, is this the global object? - isEval: Function; // does this call take place in code defined by a call to eval? - isNative: Function; // is this call in native V8 code? - isConstructor: Function; // is this a constructor call? + /** Value of this */ + getThis(): any; + + /** Type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. */ + getTypeName(): string | null; + + /** Current function */ + getFunction(): Function | undefined; + + /** Name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. */ + getFunctionName(): string | null; + + /** Name of the property [of this or one of its prototypes] that holds the current function */ + getMethodName(): string | null; + + /** Name of the script [if this function was defined in a script] */ + getFileName(): string | null; + + /** Current line number [if this function was defined in a script] */ + getLineNumber(): number | null; + + /** Current column number [if this function was defined in a script] */ + getColumnNumber(): number | null; + + /** A call site object representing the location where eval was called [if this function was created using a call to eval] */ + getEvalOrigin(): string | undefined; + + /** Is this a toplevel invocation, that is, is this the global object? */ + isToplevel(): boolean; + + /** Does this call take place in code defined by a call to eval? */ + isEval(): boolean; + + /** Is this call in native V8 code? */ + isNative(): boolean; + + /** Is this a constructor call? */ + isConstructor(): boolean; } export interface ErrnoException extends Error { diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 948fc7623f..dc8d02174b 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -33,9 +33,14 @@ interface Error { // Declare "static" methods in Error interface ErrorConstructor { + /** Create .stack property on a target object */ captureStackTrace(targetObject: Object, constructorOpt?: Function): void; - // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + /** + * Optional override for formatting stack traces + * + * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + */ prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any; stackTraceLimit: number; @@ -264,19 +269,44 @@ declare namespace NodeJS { } export interface CallSite { - getThis: Function; // returns the value of this - getTypeName(): string; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. - getFunction: Function; // returns the current function - getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. - getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function - getFileName: Function; // if this function was defined in a script returns the name of the script - getLineNumber: Function; // if this function was defined in a script returns the current line number - getColumnNumber: Function; // if this function was defined in a script returns the current column number - getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called - isToplevel: Function; // is this a toplevel invocation, that is, is this the global object? - isEval: Function; // does this call take place in code defined by a call to eval? - isNative: Function; // is this call in native V8 code? - isConstructor: Function; // is this a constructor call? + /** Value of this */ + getThis(): any; + + /** Type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. */ + getTypeName(): string | null; + + /** Current function */ + getFunction(): Function | undefined; + + /** Name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. */ + getFunctionName(): string | null; + + /** Name of the property [of this or one of its prototypes] that holds the current function */ + getMethodName(): string | null; + + /** Name of the script [if this function was defined in a script] */ + getFileName(): string | null; + + /** Current line number [if this function was defined in a script] */ + getLineNumber(): number | null; + + /** Current column number [if this function was defined in a script] */ + getColumnNumber(): number | null; + + /** A call site object representing the location where eval was called [if this function was created using a call to eval] */ + getEvalOrigin(): string | undefined; + + /** Is this a toplevel invocation, that is, is this the global object? */ + isToplevel(): boolean; + + /** Does this call take place in code defined by a call to eval? */ + isEval(): boolean; + + /** Is this call in native V8 code? */ + isNative(): boolean; + + /** Is this a constructor call? */ + isConstructor(): boolean; } export interface ErrnoException extends Error { diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index c2f723d7df..d4f621e613 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -34,9 +34,14 @@ interface Error { // Declare "static" methods in Error interface ErrorConstructor { + /** Create .stack property on a target object */ captureStackTrace(targetObject: Object, constructorOpt?: Function): void; - // See https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + /** + * Optional override for formatting stack traces + * + * @see https://github.com/v8/v8/wiki/Stack%20Trace%20API#customizing-stack-traces + */ prepareStackTrace?: (err: Error, stackTraces: NodeJS.CallSite[]) => any; stackTraceLimit: number; @@ -276,19 +281,44 @@ declare namespace NodeJS { } export interface CallSite { - getThis: Function; // returns the value of this - getTypeName(): string; // returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. - getFunction: Function; // returns the current function - getFunctionName: Function; // returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. - getMethodName: Function; // returns the name of the property of this or one of its prototypes that holds the current function - getFileName: Function; // if this function was defined in a script returns the name of the script - getLineNumber: Function; // if this function was defined in a script returns the current line number - getColumnNumber: Function; // if this function was defined in a script returns the current column number - getEvalOrigin: Function; // if this function was created using a call to eval returns a CallSite object representing the location where eval was called - isToplevel: Function; // is this a toplevel invocation, that is, is this the global object? - isEval: Function; // does this call take place in code defined by a call to eval? - isNative: Function; // is this call in native V8 code? - isConstructor: Function; // is this a constructor call? + /** Value of this */ + getThis(): any; + + /** Type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. */ + getTypeName(): string | null; + + /** Current function */ + getFunction(): Function | undefined; + + /** Name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. */ + getFunctionName(): string | null; + + /** Name of the property [of this or one of its prototypes] that holds the current function */ + getMethodName(): string | null; + + /** Name of the script [if this function was defined in a script] */ + getFileName(): string | null; + + /** Current line number [if this function was defined in a script] */ + getLineNumber(): number | null; + + /** Current column number [if this function was defined in a script] */ + getColumnNumber(): number | null; + + /** A call site object representing the location where eval was called [if this function was created using a call to eval] */ + getEvalOrigin(): string | undefined; + + /** Is this a toplevel invocation, that is, is this the global object? */ + isToplevel(): boolean; + + /** Does this call take place in code defined by a call to eval? */ + isEval(): boolean; + + /** Is this call in native V8 code? */ + isNative(): boolean; + + /** Is this a constructor call? */ + isConstructor(): boolean; } export interface ErrnoException extends Error { From 95b94efe8df95f26013101c125ed2062a4e2fa7c Mon Sep 17 00:00:00 2001 From: Howard Mak Date: Thu, 7 Dec 2017 13:46:40 -0500 Subject: [PATCH 7/7] Clean up comments for NodeJS.CallSite methods. Make "this" references clearer. --- types/node/index.d.ts | 59 +++++++++++++++++++++++++++++++--------- types/node/v4/index.d.ts | 59 +++++++++++++++++++++++++++++++--------- types/node/v6/index.d.ts | 59 +++++++++++++++++++++++++++++++--------- types/node/v7/index.d.ts | 59 +++++++++++++++++++++++++++++++--------- 4 files changed, 184 insertions(+), 52 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index ec3ddb2864..05c27adef1 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -322,43 +322,76 @@ declare namespace NodeJS { } export interface CallSite { - /** Value of this */ + /** + * Value of "this" + */ getThis(): any; - /** Type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. */ + /** + * Type of "this" as a string. + * This is the name of the function stored in the constructor field of + * "this", if available. Otherwise the object's [[Class]] internal + * property. + */ getTypeName(): string | null; - /** Current function */ + /** + * Current function + */ getFunction(): Function | undefined; - /** Name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. */ + /** + * Name of the current function, typically its name property. + * If a name property is not available an attempt will be made to try + * to infer a name from the function's context. + */ getFunctionName(): string | null; - /** Name of the property [of this or one of its prototypes] that holds the current function */ + /** + * Name of the property [of "this" or one of its prototypes] that holds + * the current function + */ getMethodName(): string | null; - /** Name of the script [if this function was defined in a script] */ + /** + * Name of the script [if this function was defined in a script] + */ getFileName(): string | null; - /** Current line number [if this function was defined in a script] */ + /** + * Current line number [if this function was defined in a script] + */ getLineNumber(): number | null; - /** Current column number [if this function was defined in a script] */ + /** + * Current column number [if this function was defined in a script] + */ getColumnNumber(): number | null; - /** A call site object representing the location where eval was called [if this function was created using a call to eval] */ + /** + * A call site object representing the location where eval was called + * [if this function was created using a call to eval] + */ getEvalOrigin(): string | undefined; - /** Is this a toplevel invocation, that is, is this the global object? */ + /** + * Is this a toplevel invocation, that is, is "this" the global object? + */ isToplevel(): boolean; - /** Does this call take place in code defined by a call to eval? */ + /** + * Does this call take place in code defined by a call to eval? + */ isEval(): boolean; - /** Is this call in native V8 code? */ + /** + * Is this call in native V8 code? + */ isNative(): boolean; - /** Is this a constructor call? */ + /** + * Is this a constructor call? + */ isConstructor(): boolean; } diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 30e5c16d9b..5854d59c6c 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -240,43 +240,76 @@ declare namespace NodeJS { } export interface CallSite { - /** Value of this */ + /** + * Value of "this" + */ getThis(): any; - /** Type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. */ + /** + * Type of "this" as a string. + * This is the name of the function stored in the constructor field of + * "this", if available. Otherwise the object's [[Class]] internal + * property. + */ getTypeName(): string | null; - /** Current function */ + /** + * Current function + */ getFunction(): Function | undefined; - /** Name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. */ + /** + * Name of the current function, typically its name property. + * If a name property is not available an attempt will be made to try + * to infer a name from the function's context. + */ getFunctionName(): string | null; - /** Name of the property [of this or one of its prototypes] that holds the current function */ + /** + * Name of the property [of "this" or one of its prototypes] that holds + * the current function + */ getMethodName(): string | null; - /** Name of the script [if this function was defined in a script] */ + /** + * Name of the script [if this function was defined in a script] + */ getFileName(): string | null; - /** Current line number [if this function was defined in a script] */ + /** + * Current line number [if this function was defined in a script] + */ getLineNumber(): number | null; - /** Current column number [if this function was defined in a script] */ + /** + * Current column number [if this function was defined in a script] + */ getColumnNumber(): number | null; - /** A call site object representing the location where eval was called [if this function was created using a call to eval] */ + /** + * A call site object representing the location where eval was called + * [if this function was created using a call to eval] + */ getEvalOrigin(): string | undefined; - /** Is this a toplevel invocation, that is, is this the global object? */ + /** + * Is this a toplevel invocation, that is, is "this" the global object? + */ isToplevel(): boolean; - /** Does this call take place in code defined by a call to eval? */ + /** + * Does this call take place in code defined by a call to eval? + */ isEval(): boolean; - /** Is this call in native V8 code? */ + /** + * Is this call in native V8 code? + */ isNative(): boolean; - /** Is this a constructor call? */ + /** + * Is this a constructor call? + */ isConstructor(): boolean; } diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index dc8d02174b..bad3de25ad 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -269,43 +269,76 @@ declare namespace NodeJS { } export interface CallSite { - /** Value of this */ + /** + * Value of "this" + */ getThis(): any; - /** Type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. */ + /** + * Type of "this" as a string. + * This is the name of the function stored in the constructor field of + * "this", if available. Otherwise the object's [[Class]] internal + * property. + */ getTypeName(): string | null; - /** Current function */ + /** + * Current function + */ getFunction(): Function | undefined; - /** Name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. */ + /** + * Name of the current function, typically its name property. + * If a name property is not available an attempt will be made to try + * to infer a name from the function's context. + */ getFunctionName(): string | null; - /** Name of the property [of this or one of its prototypes] that holds the current function */ + /** + * Name of the property [of "this" or one of its prototypes] that holds + * the current function + */ getMethodName(): string | null; - /** Name of the script [if this function was defined in a script] */ + /** + * Name of the script [if this function was defined in a script] + */ getFileName(): string | null; - /** Current line number [if this function was defined in a script] */ + /** + * Current line number [if this function was defined in a script] + */ getLineNumber(): number | null; - /** Current column number [if this function was defined in a script] */ + /** + * Current column number [if this function was defined in a script] + */ getColumnNumber(): number | null; - /** A call site object representing the location where eval was called [if this function was created using a call to eval] */ + /** + * A call site object representing the location where eval was called + * [if this function was created using a call to eval] + */ getEvalOrigin(): string | undefined; - /** Is this a toplevel invocation, that is, is this the global object? */ + /** + * Is this a toplevel invocation, that is, is "this" the global object? + */ isToplevel(): boolean; - /** Does this call take place in code defined by a call to eval? */ + /** + * Does this call take place in code defined by a call to eval? + */ isEval(): boolean; - /** Is this call in native V8 code? */ + /** + * Is this call in native V8 code? + */ isNative(): boolean; - /** Is this a constructor call? */ + /** + * Is this a constructor call? + */ isConstructor(): boolean; } diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index d4f621e613..44013f2e6e 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -281,43 +281,76 @@ declare namespace NodeJS { } export interface CallSite { - /** Value of this */ + /** + * Value of "this" + */ getThis(): any; - /** Type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property. */ + /** + * Type of "this" as a string. + * This is the name of the function stored in the constructor field of + * "this", if available. Otherwise the object's [[Class]] internal + * property. + */ getTypeName(): string | null; - /** Current function */ + /** + * Current function + */ getFunction(): Function | undefined; - /** Name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context. */ + /** + * Name of the current function, typically its name property. + * If a name property is not available an attempt will be made to try + * to infer a name from the function's context. + */ getFunctionName(): string | null; - /** Name of the property [of this or one of its prototypes] that holds the current function */ + /** + * Name of the property [of "this" or one of its prototypes] that holds + * the current function + */ getMethodName(): string | null; - /** Name of the script [if this function was defined in a script] */ + /** + * Name of the script [if this function was defined in a script] + */ getFileName(): string | null; - /** Current line number [if this function was defined in a script] */ + /** + * Current line number [if this function was defined in a script] + */ getLineNumber(): number | null; - /** Current column number [if this function was defined in a script] */ + /** + * Current column number [if this function was defined in a script] + */ getColumnNumber(): number | null; - /** A call site object representing the location where eval was called [if this function was created using a call to eval] */ + /** + * A call site object representing the location where eval was called + * [if this function was created using a call to eval] + */ getEvalOrigin(): string | undefined; - /** Is this a toplevel invocation, that is, is this the global object? */ + /** + * Is this a toplevel invocation, that is, is "this" the global object? + */ isToplevel(): boolean; - /** Does this call take place in code defined by a call to eval? */ + /** + * Does this call take place in code defined by a call to eval? + */ isEval(): boolean; - /** Is this call in native V8 code? */ + /** + * Is this call in native V8 code? + */ isNative(): boolean; - /** Is this a constructor call? */ + /** + * Is this a constructor call? + */ isConstructor(): boolean; }