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