From fb18e56681e858cef1fa0667e4c23db5f762b008 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Fri, 11 Aug 2017 01:54:57 +0200 Subject: [PATCH] [temp-write] add typings (#18853) --- types/temp-write/index.d.ts | 13 +++++++++++++ types/temp-write/temp-write-tests.ts | 12 ++++++++++++ types/temp-write/tsconfig.json | 22 ++++++++++++++++++++++ types/temp-write/tslint.json | 1 + 4 files changed, 48 insertions(+) create mode 100644 types/temp-write/index.d.ts create mode 100644 types/temp-write/temp-write-tests.ts create mode 100644 types/temp-write/tsconfig.json create mode 100644 types/temp-write/tslint.json diff --git a/types/temp-write/index.d.ts b/types/temp-write/index.d.ts new file mode 100644 index 0000000000..b7cebd443a --- /dev/null +++ b/types/temp-write/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for temp-write 3.3 +// Project: https://github.com/sindresorhus/temp-write#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +export = tempWrite; + +declare function tempWrite(input: string | Buffer | NodeJS.ReadableStream, filepath?: string): Promise; + +declare namespace tempWrite { + function sync(input: string | Buffer, filepath?: string): string; +} diff --git a/types/temp-write/temp-write-tests.ts b/types/temp-write/temp-write-tests.ts new file mode 100644 index 0000000000..37035e08f0 --- /dev/null +++ b/types/temp-write/temp-write-tests.ts @@ -0,0 +1,12 @@ +import tempWrite = require('temp-write'); + +tempWrite('unicorn').then(path => { + path; // $ExpectType string +}); +tempWrite('unicorn', 'pony.png'); // $ExpectType Promise +tempWrite(process.stdin, 'pony.png'); +tempWrite(new Buffer('pony'), 'pony.png'); + +tempWrite.sync('unicorn'); // $ExpectType string +tempWrite.sync(new Buffer('unicorn')); +tempWrite.sync('unicorn', 'pony.png'); diff --git a/types/temp-write/tsconfig.json b/types/temp-write/tsconfig.json new file mode 100644 index 0000000000..9d33c2c4b2 --- /dev/null +++ b/types/temp-write/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", + "temp-write-tests.ts" + ] +} diff --git a/types/temp-write/tslint.json b/types/temp-write/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/temp-write/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }