Files
DefinitelyTyped/types/pkg-conf/index.d.ts
Jorge Gonzalez 67abbade54 Add types for pkg-conf@2.1 (#27284)
* Add types for pkg-conf@2.1

* Refine for tests

* Remove fixture

* Update pkg-conf-tests.ts

* Fix test

* Update pkg-conf-tests.ts
2018-07-23 10:27:19 -07:00

35 lines
1.2 KiB
TypeScript

// Type definitions for pkg-conf 2.1
// Project: https://github.com/sindresorhus/pkg-conf#readme
// Definitions by: Jorge Gonzalez <https://github.com/jorgegonzalez>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
declare namespace pkgConf {
type AnyJson = boolean | number | string | null | JsonArray | JsonMap;
interface JsonArray extends Array<AnyJson> { }
interface JsonMap {
[key: string]: AnyJson;
}
interface Options {
// Directory to start looking up for a package.json file.
// Default: process.cwd()
cwd?: string;
// Default config.
defaults?: object;
// Skip package.json files that have the namespaced config explicitly set to false.
skipOnFalse?: boolean;
}
// Returns the config.
function sync(namespace: string, options?: Options): JsonMap;
// Pass in the config returned from any of the above methods.
// Returns the filepath to the package.json file or null when not found.
function filepath(config: JsonMap): string | null;
}
// Returns a Promise for the config.
declare function pkgConf(namespace: string, options?: pkgConf.Options): Promise<pkgConf.JsonMap>;
export = pkgConf;