From 8e8b569b347357f82108954cc4c241bda768e1c7 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Wed, 17 Jul 2019 10:22:10 +1200 Subject: [PATCH] [stdin] introduce typings (#36866) * [stdin] introduce typings * [stdin] use `any` instead of `unknown` --- types/stdin/index.d.ts | 8 ++++++++ types/stdin/stdin-tests.ts | 12 ++++++++++++ types/stdin/tsconfig.json | 23 +++++++++++++++++++++++ types/stdin/tslint.json | 1 + 4 files changed, 44 insertions(+) create mode 100644 types/stdin/index.d.ts create mode 100644 types/stdin/stdin-tests.ts create mode 100644 types/stdin/tsconfig.json create mode 100644 types/stdin/tslint.json diff --git a/types/stdin/index.d.ts b/types/stdin/index.d.ts new file mode 100644 index 0000000000..77167ef9c1 --- /dev/null +++ b/types/stdin/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for stdin 0.0 +// Project: https://www.npmjs.com/package/stdin +// Definitions by: Gareth Jones +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = stdin; + +declare function stdin(fn: (str: string) => any): void; diff --git a/types/stdin/stdin-tests.ts b/types/stdin/stdin-tests.ts new file mode 100644 index 0000000000..65911a6417 --- /dev/null +++ b/types/stdin/stdin-tests.ts @@ -0,0 +1,12 @@ +import stdin = require('stdin'); + +stdin(); // $ExpectError +stdin((num: number) => {}); // $ExpectError + +stdin(() => {}); // $ExpectType void +stdin(str => {}); // $ExpectType void +stdin(str => undefined); // $ExpectType void +stdin(str => 1); // $ExpectType void +stdin(str => str); // $ExpectType void +stdin(str => []); // $ExpectType void +stdin(str => ({})); // $ExpectType void diff --git a/types/stdin/tsconfig.json b/types/stdin/tsconfig.json new file mode 100644 index 0000000000..decef03a0f --- /dev/null +++ b/types/stdin/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", + "stdin-tests.ts" + ] +} diff --git a/types/stdin/tslint.json b/types/stdin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/stdin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }