diff --git a/types/read-pkg-up/index.d.ts b/types/read-pkg-up/index.d.ts new file mode 100644 index 0000000000..974a9fa0cd --- /dev/null +++ b/types/read-pkg-up/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for read-pkg-up 2.0 +// Project: https://github.com/sindresorhus/read-pkg-up +// Definitions by: Louis Orleans +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace ReadPkgUp { + function sync(options?: Options): Package; + + interface Options { + /** + * Directory to start looking for a package.json file. + * + * @default 'process.cwd()' + */ + cwd?: string; + /** + * [Normalize](https://github.com/npm/normalize-package-data#what-normalization-currently-entails) the package data. + * + * @default true + */ + normalize?: boolean; + } + + interface Package { + [key: string]: any; + } +} + +declare function ReadPkgUp(options?: ReadPkgUp.Options): Promise; + +export = ReadPkgUp; diff --git a/types/read-pkg-up/read-pkg-up-tests.ts b/types/read-pkg-up/read-pkg-up-tests.ts new file mode 100644 index 0000000000..f536f275d2 --- /dev/null +++ b/types/read-pkg-up/read-pkg-up-tests.ts @@ -0,0 +1,6 @@ +import ReadPkgUp = require('read-pkg-up'); + +ReadPkgUp().then(pkg => typeof pkg === 'object'); +ReadPkgUp({cwd: '.', normalize: false}).then(pkg => typeof pkg === 'object'); +typeof ReadPkgUp.sync() === 'object'; +typeof ReadPkgUp.sync({cwd: '.', normalize: false}) === 'object'; diff --git a/types/read-pkg-up/tsconfig.json b/types/read-pkg-up/tsconfig.json new file mode 100644 index 0000000000..58be3b23c7 --- /dev/null +++ b/types/read-pkg-up/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "read-pkg-up-tests.ts" + ] +} diff --git a/types/read-pkg-up/tslint.json b/types/read-pkg-up/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/read-pkg-up/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }