From e3d0539fcaa81cd7bc8fedb85e7de4003d50a1a1 Mon Sep 17 00:00:00 2001 From: Thomas Thiebaud Date: Tue, 5 Jun 2018 18:36:38 +0200 Subject: [PATCH] Add type definition for serialize-error --- types/serialize-error/index.d.ts | 17 ++++++++++++++ .../serialize-error/serialize-error-tests.ts | 5 ++++ types/serialize-error/tsconfig.json | 23 +++++++++++++++++++ types/serialize-error/tslint.json | 1 + 4 files changed, 46 insertions(+) create mode 100644 types/serialize-error/index.d.ts create mode 100644 types/serialize-error/serialize-error-tests.ts create mode 100644 types/serialize-error/tsconfig.json create mode 100644 types/serialize-error/tslint.json diff --git a/types/serialize-error/index.d.ts b/types/serialize-error/index.d.ts new file mode 100644 index 0000000000..56ae34df60 --- /dev/null +++ b/types/serialize-error/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for serialize-error 2.1 +// Project: https://github.com/sindresorhus/serialize-error +// Definitions by: Thomas Thiebaud +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function SerializeError(error: any): SerializeError.ErrorObject; + +declare namespace SerializeError { + interface ErrorObject { + name: string; + stack: string; + message: string; + [keyof: string]: string; + } +} + +export = SerializeError; diff --git a/types/serialize-error/serialize-error-tests.ts b/types/serialize-error/serialize-error-tests.ts new file mode 100644 index 0000000000..721fae45f4 --- /dev/null +++ b/types/serialize-error/serialize-error-tests.ts @@ -0,0 +1,5 @@ +import serializeError = require('serialize-error'); + +const error = new Error('unicorn'); + +const serializedError = serializeError(error); diff --git a/types/serialize-error/tsconfig.json b/types/serialize-error/tsconfig.json new file mode 100644 index 0000000000..83731d0922 --- /dev/null +++ b/types/serialize-error/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "serialize-error-tests.ts" + ] +} diff --git a/types/serialize-error/tslint.json b/types/serialize-error/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/serialize-error/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }