From d60260c67d972722c23b652242caf93004033585 Mon Sep 17 00:00:00 2001 From: Aleh Zasypkin Date: Fri, 16 Feb 2018 15:04:37 +0100 Subject: [PATCH] write-pkg: add library definitions. --- types/write-pkg/index.d.ts | 15 +++++++++++++++ types/write-pkg/tsconfig.json | 23 +++++++++++++++++++++++ types/write-pkg/tslint.json | 1 + types/write-pkg/write-pkg-tests.ts | 6 ++++++ 4 files changed, 45 insertions(+) create mode 100644 types/write-pkg/index.d.ts create mode 100644 types/write-pkg/tsconfig.json create mode 100644 types/write-pkg/tslint.json create mode 100644 types/write-pkg/write-pkg-tests.ts diff --git a/types/write-pkg/index.d.ts b/types/write-pkg/index.d.ts new file mode 100644 index 0000000000..31fa96e346 --- /dev/null +++ b/types/write-pkg/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for write-pkg 3.1 +// Project: https://github.com/sindresorhus/write-pkg#readme +// Definitions by: Aleh Zasypkin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface WritePkg { + (path: string, data: { [k: string]: any }): Promise; + (data: { [k: string]: any }): Promise; + sync(path: string, data: { [k: string]: any }): void; + sync(data: { [k: string]: any }): void; +} + +declare const writePkg: WritePkg; + +export = writePkg; diff --git a/types/write-pkg/tsconfig.json b/types/write-pkg/tsconfig.json new file mode 100644 index 0000000000..b4ed969838 --- /dev/null +++ b/types/write-pkg/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", + "write-pkg-tests.ts" + ] +} diff --git a/types/write-pkg/tslint.json b/types/write-pkg/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/write-pkg/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/write-pkg/write-pkg-tests.ts b/types/write-pkg/write-pkg-tests.ts new file mode 100644 index 0000000000..46e2745cab --- /dev/null +++ b/types/write-pkg/write-pkg-tests.ts @@ -0,0 +1,6 @@ +import WritePkg = require('write-pkg'); + +WritePkg('package.json', { version: 1 }); // $ExpectType Promise +WritePkg({ version: 1 }); // $ExpectType Promise +WritePkg.sync('package.json', { version: 1 }); // $ExpectType void +WritePkg.sync({ version: 1 }); // $ExpectType void