From dea21dbe47e6c874fd2c28ce974270939ea8deaf Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Fri, 11 Aug 2017 01:52:13 +0200 Subject: [PATCH] [extract-stack] add typings (#18804) --- types/extract-stack/extract-stack-tests.ts | 8 ++++++++ types/extract-stack/index.d.ts | 12 ++++++++++++ types/extract-stack/tsconfig.json | 22 ++++++++++++++++++++++ types/extract-stack/tslint.json | 1 + 4 files changed, 43 insertions(+) create mode 100644 types/extract-stack/extract-stack-tests.ts create mode 100644 types/extract-stack/index.d.ts create mode 100644 types/extract-stack/tsconfig.json create mode 100644 types/extract-stack/tslint.json diff --git a/types/extract-stack/extract-stack-tests.ts b/types/extract-stack/extract-stack-tests.ts new file mode 100644 index 0000000000..927cd995ca --- /dev/null +++ b/types/extract-stack/extract-stack-tests.ts @@ -0,0 +1,8 @@ +import extractStack = require('extract-stack'); + +const error = new Error('Missing unicorn'); + +extractStack(error); // $ExpectType string +extractStack(error.stack); // $ExpectType string +extractStack.lines(error); // $ExpectType string[] +extractStack.lines(error.stack); // $ExpectType string[] diff --git a/types/extract-stack/index.d.ts b/types/extract-stack/index.d.ts new file mode 100644 index 0000000000..071a147e59 --- /dev/null +++ b/types/extract-stack/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for extract-stack 1.0 +// Project: https://github.com/sindresorhus/extract-stack#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = extractStack; + +declare function extractStack(input: Error | string | undefined): string; + +declare namespace extractStack { + function lines(input: Error | string | undefined): string[]; +} diff --git a/types/extract-stack/tsconfig.json b/types/extract-stack/tsconfig.json new file mode 100644 index 0000000000..ea1f60704b --- /dev/null +++ b/types/extract-stack/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "extract-stack-tests.ts" + ] +} diff --git a/types/extract-stack/tslint.json b/types/extract-stack/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/extract-stack/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }