write-pkg: add library definitions.

This commit is contained in:
Aleh Zasypkin
2018-02-16 15:04:37 +01:00
parent 423ace8fe7
commit d60260c67d
4 changed files with 45 additions and 0 deletions

15
types/write-pkg/index.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
// Type definitions for write-pkg 3.1
// Project: https://github.com/sindresorhus/write-pkg#readme
// Definitions by: Aleh Zasypkin <https://github.com/azasypkin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface WritePkg {
(path: string, data: { [k: string]: any }): Promise<void>;
(data: { [k: string]: any }): Promise<void>;
sync(path: string, data: { [k: string]: any }): void;
sync(data: { [k: string]: any }): void;
}
declare const writePkg: WritePkg;
export = writePkg;

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",
"write-pkg-tests.ts"
]
}

View File

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

View File

@@ -0,0 +1,6 @@
import WritePkg = require('write-pkg');
WritePkg('package.json', { version: 1 }); // $ExpectType Promise<void>
WritePkg({ version: 1 }); // $ExpectType Promise<void>
WritePkg.sync('package.json', { version: 1 }); // $ExpectType void
WritePkg.sync({ version: 1 }); // $ExpectType void