// Type definitions for cosmiconfig 5.0 // Project: https://github.com/davidtheclark/cosmiconfig // Definitions by: ozum // szeck87 // saadq // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 /// export interface Config { [key: string]: any; } export type CosmiconfigResult = { config: Config; filePath: string; isEmpty?: boolean; } | null; export interface LoaderResult { config: Config | null; filepath: string; } export type SyncLoader = (filepath: string, content: string) => Config | null; export type AsyncLoader = (filepath: string, content: string) => Config | null | Promise; export interface LoaderEntry { sync?: SyncLoader; async?: AsyncLoader; } export interface Loaders { [key: string]: LoaderEntry; } export interface Explorer { search(searchFrom?: string): Promise; searchSync(searchFrom?: string): null | CosmiconfigResult; load(loadPath: string): Promise; loadSync(loadPath: string): CosmiconfigResult; clearLoadCache(): void; clearSearchCache(): void; clearCaches(): void; } // These are the user options with defaults applied. export interface ExplorerOptions { stopDir?: string; cache?: boolean; transform?: (result: CosmiconfigResult) => Promise | CosmiconfigResult; packageProp?: string; loaders?: Loaders; searchPlaces?: string[]; ignoreEmptySearchPlaces?: boolean; } export default function cosmiconfig(moduleName: string, options?: ExplorerOptions): Explorer;