[stdin] introduce typings (#36866)

* [stdin] introduce typings

* [stdin] use `any` instead of `unknown`
This commit is contained in:
Gareth Jones 2019-07-17 10:22:10 +12:00 committed by Andrew Branch
parent 613e682831
commit 8e8b569b34
4 changed files with 44 additions and 0 deletions

8
types/stdin/index.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
// Type definitions for stdin 0.0
// Project: https://www.npmjs.com/package/stdin
// Definitions by: Gareth Jones <https://github.com/g-rath>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = stdin;
declare function stdin(fn: (str: string) => any): void;

View File

@ -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

23
types/stdin/tsconfig.json Normal file
View File

@ -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"
]
}

1
types/stdin/tslint.json Normal file
View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }