Add typings for init-package-json (#29356)

This commit is contained in:
Kyle Farnung
2018-10-02 11:15:27 -07:00
committed by Wesley Wigham
parent 1038a88306
commit ce1ee6c93f
4 changed files with 68 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for init-package-json 1.10
// Project: https://github.com/npm/init-package-json#readme
// Definitions by: Kyle Farnung <https://github.com/kfarnung>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace init_package_json {
interface Config {
[key: string]: any;
get(k: string): any;
}
function yes(conf: Config): boolean;
}
declare function init_package_json(
dir: string,
input: string,
config: init_package_json.Config | {},
cb: (err: any, data: any) => void): void;
declare function init_package_json(
dir: string,
input: string,
cb: (err: any, data: any) => void): void;
export = init_package_json;
@@ -0,0 +1,18 @@
import init_package_json = require("init-package-json");
init_package_json("", "", (err: any, data: any) => {}); // $ExpectType void
init_package_json("", "", {}, (err: any, data: any) => {}); // $ExpectType void
init_package_json("", "", { foo: "bar" }, (err: any, data: any) => {}); // $ExpectType void
const config: init_package_json.Config = {
foo: "bar",
get(k) {
return "";
},
};
init_package_json("", "", config, (err: any, data: any) => {}); // $ExpectType void
init_package_json.yes({}); // $ExpectError
init_package_json.yes({ foo: "bar" }); // $ExpectError
init_package_json.yes(config); // $ExpectType boolean
+23
View File
@@ -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",
"init-package-json-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }