diff --git a/verror/index.d.ts b/verror/index.d.ts index 35e11f17aa..96f711c9f7 100644 --- a/verror/index.d.ts +++ b/verror/index.d.ts @@ -1,16 +1,19 @@ -// Type definitions for verror v1.9.0 +// Type definitions for verror 1.9 // Project: https://github.com/davepacheco/node-verror -// Definitions by: Sven Reglitzki +// Definitions by: Sven Reglitzki , Maxime Toumi-M // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -type VErrorInfo = { [key: string]: any }; +// tslint:disable-next-line:functional-interfaces +interface VErrorInfo { + [key: string]: any; +} declare interface VErrorOptions { - cause: Error; + cause?: Error | null | undefined; name?: string; strict?: boolean; - constructorOpt?: Function; + constructorOpt?: (...args: any[]) => void; info?: VErrorInfo; } @@ -70,10 +73,7 @@ declare class MultiError extends VError { * is wrapped, not "folded in" as with VError. Accepts a printf-style message. * The cause argument can be null. */ -declare class WError extends Error { - cause(): Error; - constructor(cause: Error, message: string, ...params: any[]); - constructor(message: string, ...params: any[]); +declare class WError extends VError { } export = VError; diff --git a/verror/tsconfig.json b/verror/tsconfig.json index bda043af17..1c5ea42467 100644 --- a/verror/tsconfig.json +++ b/verror/tsconfig.json @@ -4,7 +4,7 @@ "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -17,4 +17,4 @@ "index.d.ts", "verror-tests.ts" ] -} \ No newline at end of file +} diff --git a/verror/verror-tests.ts b/verror/verror-tests.ts index 0c386987c1..de1838ee9b 100644 --- a/verror/verror-tests.ts +++ b/verror/verror-tests.ts @@ -21,8 +21,10 @@ var verror3 = new VError({ } }, "bar"); -var cause1: Error = verror1.cause(); -var cause2: Error = werror.cause(); +var verror4 = new VError({ cause: null }, "bar"); + +var cause1: Error | undefined = verror1.cause(); +var cause2: Error | undefined = werror.cause(); const info: { [k: string]: any } = VError.info(verror3); const namedCause: Error | null = VError.findCauseByName(verror3, "fooError");