From 5227ddf7d53c976ce6238535e26a5700fca01506 Mon Sep 17 00:00:00 2001 From: Aankhen Date: Wed, 18 Apr 2018 01:22:41 +0530 Subject: [PATCH] Add `write-file-atomically` types. (#25064) --- types/write-file-atomically/index.d.ts | 14 +++++++++++ types/write-file-atomically/tsconfig.json | 23 +++++++++++++++++++ types/write-file-atomically/tslint.json | 1 + .../write-file-atomically-tests.ts | 10 ++++++++ 4 files changed, 48 insertions(+) create mode 100644 types/write-file-atomically/index.d.ts create mode 100644 types/write-file-atomically/tsconfig.json create mode 100644 types/write-file-atomically/tslint.json create mode 100644 types/write-file-atomically/write-file-atomically-tests.ts diff --git a/types/write-file-atomically/index.d.ts b/types/write-file-atomically/index.d.ts new file mode 100644 index 0000000000..b4e3957a80 --- /dev/null +++ b/types/write-file-atomically/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for write-file-atomically 2.0 +// Project: https://github.com/shinnn/write-file-atomically#readme +// Definitions by: Aankhen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import writeFileAtomic = require("write-file-atomic"); + +export = WriteFileAtomically; + +declare function WriteFileAtomically(path: string, data: WriteFileAtomically.Data, options?: writeFileAtomic.Options): Promise; + +declare namespace WriteFileAtomically { + type Data = string | Buffer | Uint8Array; +} diff --git a/types/write-file-atomically/tsconfig.json b/types/write-file-atomically/tsconfig.json new file mode 100644 index 0000000000..eb3aedbee9 --- /dev/null +++ b/types/write-file-atomically/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "write-file-atomically-tests.ts" + ] +} diff --git a/types/write-file-atomically/tslint.json b/types/write-file-atomically/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/write-file-atomically/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/write-file-atomically/write-file-atomically-tests.ts b/types/write-file-atomically/write-file-atomically-tests.ts new file mode 100644 index 0000000000..a1654d6cb6 --- /dev/null +++ b/types/write-file-atomically/write-file-atomically-tests.ts @@ -0,0 +1,10 @@ +import writeFileAtomically = require('write-file-atomically'); + +writeFileAtomically(1, '_'); // $ExpectError + +import { readFileSync } from 'fs'; + +(() => { + writeFileAtomically('file.txt', 'Hi!'); + readFileSync('file.txt', 'utf8'); +})();