mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-22 20:37:58 +08:00
Merge pull request #26533 from jinwoo/export-default
[cosmiconfig] fix wrong "export default"
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import cosmiconfig, { CosmiconfigResult } from "cosmiconfig";
|
||||
import cosmiconfig = require("cosmiconfig");
|
||||
import { CosmiconfigResult } from "cosmiconfig";
|
||||
import * as path from "path";
|
||||
|
||||
const explorer = cosmiconfig("yourModuleName", {
|
||||
|
||||
99
types/cosmiconfig/index.d.ts
vendored
99
types/cosmiconfig/index.d.ts
vendored
@@ -3,57 +3,62 @@
|
||||
// Definitions by: ozum <https://github.com/ozum>
|
||||
// szeck87 <https://github.com/szeck87>
|
||||
// saadq <https://github.com/saadq>
|
||||
// jinwoo <https://github.com/jinwoo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export interface Config {
|
||||
[key: string]: any;
|
||||
declare function cosmiconfig(moduleName: string, options?: cosmiconfig.ExplorerOptions): cosmiconfig.Explorer;
|
||||
|
||||
declare namespace cosmiconfig {
|
||||
interface Config {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
type CosmiconfigResult = {
|
||||
config: Config;
|
||||
filepath: string;
|
||||
isEmpty?: boolean;
|
||||
} | null;
|
||||
|
||||
interface LoaderResult {
|
||||
config: Config | null;
|
||||
filepath: string;
|
||||
}
|
||||
|
||||
type SyncLoader = (filepath: string, content: string) => Config | null;
|
||||
type AsyncLoader = (filepath: string, content: string) => Config | null | Promise<object | null>;
|
||||
|
||||
interface LoaderEntry {
|
||||
sync?: SyncLoader;
|
||||
async?: AsyncLoader;
|
||||
}
|
||||
|
||||
interface Loaders {
|
||||
[key: string]: LoaderEntry;
|
||||
}
|
||||
|
||||
interface Explorer {
|
||||
search(searchFrom?: string): Promise<null | CosmiconfigResult>;
|
||||
searchSync(searchFrom?: string): null | CosmiconfigResult;
|
||||
load(loadPath: string): Promise<CosmiconfigResult>;
|
||||
loadSync(loadPath: string): CosmiconfigResult;
|
||||
clearLoadCache(): void;
|
||||
clearSearchCache(): void;
|
||||
clearCaches(): void;
|
||||
}
|
||||
|
||||
// These are the user options with defaults applied.
|
||||
interface ExplorerOptions {
|
||||
stopDir?: string;
|
||||
cache?: boolean;
|
||||
transform?: (result: CosmiconfigResult) => Promise<CosmiconfigResult> | CosmiconfigResult;
|
||||
packageProp?: string;
|
||||
loaders?: Loaders;
|
||||
searchPlaces?: string[];
|
||||
ignoreEmptySearchPlaces?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
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<object | null>;
|
||||
|
||||
export interface LoaderEntry {
|
||||
sync?: SyncLoader;
|
||||
async?: AsyncLoader;
|
||||
}
|
||||
|
||||
export interface Loaders {
|
||||
[key: string]: LoaderEntry;
|
||||
}
|
||||
|
||||
export interface Explorer {
|
||||
search(searchFrom?: string): Promise<null | CosmiconfigResult>;
|
||||
searchSync(searchFrom?: string): null | CosmiconfigResult;
|
||||
load(loadPath: string): Promise<CosmiconfigResult>;
|
||||
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> | CosmiconfigResult;
|
||||
packageProp?: string;
|
||||
loaders?: Loaders;
|
||||
searchPlaces?: string[];
|
||||
ignoreEmptySearchPlaces?: boolean;
|
||||
}
|
||||
|
||||
export default function cosmiconfig(moduleName: string, options?: ExplorerOptions): Explorer;
|
||||
export = cosmiconfig;
|
||||
|
||||
Reference in New Issue
Block a user