From 68721e9fb749977bc6a213de89eaa51117e640cb Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Tue, 24 Sep 2019 22:29:51 +0100 Subject: [PATCH] Add types for intercept-stdout (#38373) --- types/intercept-stdout/index.d.ts | 14 +++++++++++ .../intercept-stdout-tests.ts | 9 ++++++++ types/intercept-stdout/tsconfig.json | 23 +++++++++++++++++++ types/intercept-stdout/tslint.json | 1 + 4 files changed, 47 insertions(+) create mode 100644 types/intercept-stdout/index.d.ts create mode 100644 types/intercept-stdout/intercept-stdout-tests.ts create mode 100644 types/intercept-stdout/tsconfig.json create mode 100644 types/intercept-stdout/tslint.json diff --git a/types/intercept-stdout/index.d.ts b/types/intercept-stdout/index.d.ts new file mode 100644 index 0000000000..8e66444bac --- /dev/null +++ b/types/intercept-stdout/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for intercept-stdout 0.1 +// Project: https://github.com/sfarthin/intercept-stdout +// Definitions by: Paulo Castro +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type hookFunction = (txt: string) => string | void; +type unhookFunction = () => void; + +declare function intercept( + stdoutIntercept: hookFunction, + stderrIntercept?: hookFunction, +): unhookFunction; + +export = intercept; diff --git a/types/intercept-stdout/intercept-stdout-tests.ts b/types/intercept-stdout/intercept-stdout-tests.ts new file mode 100644 index 0000000000..f94e421897 --- /dev/null +++ b/types/intercept-stdout/intercept-stdout-tests.ts @@ -0,0 +1,9 @@ +import intercept = require('intercept-stdout'); + +const stdoutHook = (data: string) => { + return data; +}; + +const unhookIntercept = intercept(stdoutHook); + +unhookIntercept(); diff --git a/types/intercept-stdout/tsconfig.json b/types/intercept-stdout/tsconfig.json new file mode 100644 index 0000000000..7c36d572dd --- /dev/null +++ b/types/intercept-stdout/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "intercept-stdout-tests.ts" + ] +} diff --git a/types/intercept-stdout/tslint.json b/types/intercept-stdout/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/intercept-stdout/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }