diff --git a/src/index.ts b/src/index.ts index 5e4d5ba8..333d0b89 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,11 +4,17 @@ import Provider from './providers/provider'; import ProviderStream from './providers/stream'; import ProviderSync from './providers/sync'; import Settings, { Options } from './settings'; -import { EntryItem, Pattern } from './types/index'; +import { Entry, EntryItem, Pattern } from './types/index'; import * as utils from './utils/index'; type Task = taskManager.Task; +type EntryObjectModePredicate = { [P in keyof Pick]-?: true }; +type EntryStatsPredicate = { [P in keyof Pick]-?: true }; +type EntryObjectPredicate = EntryObjectModePredicate | EntryStatsPredicate; + +function sync(source: Pattern | Pattern[], options: Options & EntryObjectPredicate): Entry[]; +function sync(source: Pattern | Pattern[], options?: Options): string[]; function sync(source: Pattern | Pattern[], options?: Options): EntryItem[] { assertPatternsInput(source); @@ -17,6 +23,8 @@ function sync(source: Pattern | Pattern[], options?: Options): EntryItem[] { return utils.array.flatten(works); } +function async(source: Pattern | Pattern[], options: Options & EntryObjectPredicate): Promise; +function async(source: Pattern | Pattern[], options?: Options): Promise; function async(source: Pattern | Pattern[], options?: Options): Promise { try { assertPatternsInput(source); diff --git a/src/tests/smoke/smoke.ts b/src/tests/smoke/smoke.ts index d71d4373..e423cab4 100644 --- a/src/tests/smoke/smoke.ts +++ b/src/tests/smoke/smoke.ts @@ -160,5 +160,5 @@ function getFastGlobEntries(pattern: Pattern, ignore?: Pattern, cwd?: string, op ...opts }; - return fg.sync(pattern, options).sort() as string[]; + return fg.sync(pattern, options).sort(); }