From 263a5e9e9a2d571f0f789d7d62999b0bd91a8a4f Mon Sep 17 00:00:00 2001 From: Wouter van Heeswijk Date: Mon, 27 Aug 2018 15:52:40 +0200 Subject: [PATCH 1/4] Added typings for nested-error-stacks --- types/nested-error-stacks/index.d.ts | 10 +++++++++ .../nested-error-stacks-tests.ts | 7 ++++++ types/nested-error-stacks/tsconfig.json | 22 +++++++++++++++++++ types/nested-error-stacks/tslint.json | 3 +++ 4 files changed, 42 insertions(+) create mode 100644 types/nested-error-stacks/index.d.ts create mode 100644 types/nested-error-stacks/nested-error-stacks-tests.ts create mode 100644 types/nested-error-stacks/tsconfig.json create mode 100644 types/nested-error-stacks/tslint.json diff --git a/types/nested-error-stacks/index.d.ts b/types/nested-error-stacks/index.d.ts new file mode 100644 index 0000000000..db65a9609d --- /dev/null +++ b/types/nested-error-stacks/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for nested-error-stacks 2.1.0 +// Project: https://github.com/mdlavin/nested-error-stacks +// Definitions by: Wouter van Heeswijk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'nested-error-stacks' { + export default class NestedError extends Error { + constructor(message?: any, nested?: Error); + } +} diff --git a/types/nested-error-stacks/nested-error-stacks-tests.ts b/types/nested-error-stacks/nested-error-stacks-tests.ts new file mode 100644 index 0000000000..54a755f713 --- /dev/null +++ b/types/nested-error-stacks/nested-error-stacks-tests.ts @@ -0,0 +1,7 @@ +import NestedErrorStacks from 'nested-error-stacks'; + +const error = new NestedErrorStacks('Top level error', new Error('Nested error')); +console.log(error); +console.log(error.message); +console.log(error.name); +console.log(error.stack); diff --git a/types/nested-error-stacks/tsconfig.json b/types/nested-error-stacks/tsconfig.json new file mode 100644 index 0000000000..9da4b3b65a --- /dev/null +++ b/types/nested-error-stacks/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strict": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": ["node"], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "nested-error-stacks-tests.ts" + ] +} \ No newline at end of file diff --git a/types/nested-error-stacks/tslint.json b/types/nested-error-stacks/tslint.json new file mode 100644 index 0000000000..b4b47a0378 --- /dev/null +++ b/types/nested-error-stacks/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From b5ca50ecd21b2ed2c115f87fcd43569bef9b8da0 Mon Sep 17 00:00:00 2001 From: Wouter van Heeswijk Date: Mon, 27 Aug 2018 15:56:27 +0200 Subject: [PATCH 2/4] Change strict flag into two separate flags --- types/nested-error-stacks/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/nested-error-stacks/tsconfig.json b/types/nested-error-stacks/tsconfig.json index 9da4b3b65a..5dbf471352 100644 --- a/types/nested-error-stacks/tsconfig.json +++ b/types/nested-error-stacks/tsconfig.json @@ -6,7 +6,8 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strict": true, + "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From b27d2aa5432da6ea2bc8c1257ca3ea4d53911a57 Mon Sep 17 00:00:00 2001 From: Wouter van Heeswijk Date: Mon, 27 Aug 2018 16:04:54 +0200 Subject: [PATCH 3/4] Change header and tests file --- types/nested-error-stacks/index.d.ts | 8 +++----- types/nested-error-stacks/nested-error-stacks-tests.ts | 7 +++---- types/nested-error-stacks/tsconfig.json | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/types/nested-error-stacks/index.d.ts b/types/nested-error-stacks/index.d.ts index db65a9609d..81cc4d52fd 100644 --- a/types/nested-error-stacks/index.d.ts +++ b/types/nested-error-stacks/index.d.ts @@ -1,10 +1,8 @@ -// Type definitions for nested-error-stacks 2.1.0 +// Type definitions for nested-error-stacks 2.1 // Project: https://github.com/mdlavin/nested-error-stacks // Definitions by: Wouter van Heeswijk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module 'nested-error-stacks' { - export default class NestedError extends Error { - constructor(message?: any, nested?: Error); - } +export default class NestedError extends Error { + constructor(message?: any, nested?: Error); } diff --git a/types/nested-error-stacks/nested-error-stacks-tests.ts b/types/nested-error-stacks/nested-error-stacks-tests.ts index 54a755f713..6706cd64fb 100644 --- a/types/nested-error-stacks/nested-error-stacks-tests.ts +++ b/types/nested-error-stacks/nested-error-stacks-tests.ts @@ -1,7 +1,6 @@ import NestedErrorStacks from 'nested-error-stacks'; const error = new NestedErrorStacks('Top level error', new Error('Nested error')); -console.log(error); -console.log(error.message); -console.log(error.name); -console.log(error.stack); +const message = error.message; +const name = error.name; +const stack = error.stack; diff --git a/types/nested-error-stacks/tsconfig.json b/types/nested-error-stacks/tsconfig.json index 5dbf471352..2954204b36 100644 --- a/types/nested-error-stacks/tsconfig.json +++ b/types/nested-error-stacks/tsconfig.json @@ -12,7 +12,7 @@ "typeRoots": [ "../" ], - "types": ["node"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, From f6501fff99c192fc346c555e30c18f605160abfb Mon Sep 17 00:00:00 2001 From: Wouter van Heeswijk Date: Tue, 28 Aug 2018 09:15:50 +0200 Subject: [PATCH 4/4] Change default export to module class --- types/nested-error-stacks/index.d.ts | 4 +++- types/nested-error-stacks/nested-error-stacks-tests.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/nested-error-stacks/index.d.ts b/types/nested-error-stacks/index.d.ts index 81cc4d52fd..29d629a50b 100644 --- a/types/nested-error-stacks/index.d.ts +++ b/types/nested-error-stacks/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: Wouter van Heeswijk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export default class NestedError extends Error { +declare class NestedError extends Error { constructor(message?: any, nested?: Error); } + +export = NestedError; diff --git a/types/nested-error-stacks/nested-error-stacks-tests.ts b/types/nested-error-stacks/nested-error-stacks-tests.ts index 6706cd64fb..52a9a55495 100644 --- a/types/nested-error-stacks/nested-error-stacks-tests.ts +++ b/types/nested-error-stacks/nested-error-stacks-tests.ts @@ -1,4 +1,4 @@ -import NestedErrorStacks from 'nested-error-stacks'; +import NestedErrorStacks = require('nested-error-stacks'); const error = new NestedErrorStacks('Top level error', new Error('Nested error')); const message = error.message;