1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-08-28 08:10:54 +02:00

- 更新index.d.ts

- 为Index的search等方法自动推断返回类型
This commit is contained in:
flycran
2025-05-05 11:05:50 +08:00
parent babbe1d73c
commit a685bc1f8f

39
index.d.ts vendored
View File

@@ -219,7 +219,7 @@ declare module "flexsearch" {
type DefaultSearchResults = Id[];
type IntermediateSearchResults = Array<Id[]>;
type SearchResults = DefaultSearchResults | Resolver;
type SearchResults<R extends boolean = false> = R extends true ? Resolver : DefaultSearchResults;
/**
* **Document:**
@@ -242,13 +242,15 @@ declare module "flexsearch" {
remove(id: Id): this | Promise<this>;
search(query: string, options?: Limit | SearchOptions): SearchResults | Promise<SearchResults>;
search(query: string, limit: number, options: SearchOptions): SearchResults | Promise<SearchResults>;
search(options: SearchOptions): SearchResults | Promise<SearchResults>;
search(query: string, limit?: Limit): SearchResults | Promise<SearchResults>;
search<R extends boolean = false>(query: string, options?: SearchOptions<R>): SearchResults<R> | Promise<SearchResults<R>>;
search<R extends boolean = false>(query: string, limit: Limit, options: SearchOptions<R>): SearchResults<R> | Promise<SearchResults<R>>;
search<R extends boolean = false>(options: SearchOptions<R>): SearchResults<R> | Promise<SearchResults<R>>;
searchCache(query: string, options?: Limit | SearchOptions): SearchResults | Promise<SearchResults>;
searchCache(query: string, limit: number, options: SearchOptions): SearchResults | Promise<SearchResults>;
searchCache(options: SearchOptions): SearchResults | Promise<SearchResults>;
searchCache(query: string, limit?: Limit): SearchResults | Promise<SearchResults>;
searchCache<R extends boolean = false>(query: string, options?: Limit | SearchOptions<R>): SearchResults<R> | Promise<SearchResults<R>>;
searchCache<R extends boolean = false>(query: string, limit: Limit, options: SearchOptions<R>): SearchResults<R> | Promise<SearchResults<R>>;
searchCache<R extends boolean = false>(options: SearchOptions<R>): SearchResults<R> | Promise<SearchResults<R>>;
// https://github.com/nextapps-de/flexsearch#check-existence-of-already-indexed-ids
contain(id: Id): boolean | Promise<boolean>;
@@ -299,19 +301,24 @@ declare module "flexsearch" {
searchAsync(
query: string,
options?: Limit | SearchOptions,
limit?: Limit,
callback?: AsyncCallback<SearchResults>,
): Promise<SearchResults>
searchAsync(
searchAsync<R extends boolean = false>(
query: string,
options?: SearchOptions<R>,
callback?: AsyncCallback<SearchResults<R>>,
): Promise<SearchResults<R>>
searchAsync<R extends boolean = false>(
query: string,
limit: Limit,
options?: SearchOptions,
callback?: AsyncCallback<SearchResults>,
): Promise<SearchResults>;
searchAsync(
options: SearchOptions,
callback?: AsyncCallback<SearchResults>,
): Promise<SearchResults>;
options?: SearchOptions<R>,
callback?: AsyncCallback<SearchResults<R>>,
): Promise<SearchResults<R>>;
searchAsync<R extends boolean = false>(
options: SearchOptions<R>,
callback?: AsyncCallback<SearchResults<R>>,
): Promise<SearchResults<R>>;
}
/**