1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-08-30 01:00:11 +02:00

- 更新index.d.ts

- 为Resolver添加泛型支持

- 更新types.ts
  测试ts静态类型
This commit is contained in:
flycran
2025-05-05 10:47:57 +08:00
parent 21ebe443dc
commit 15a9ff334a

24
index.d.ts vendored
View File

@@ -217,9 +217,9 @@ declare module "flexsearch" {
/* Index Search */ /* Index Search */
/************************************/ /************************************/
type DefaultSearchResults = Id[]; export type DefaultSearchResults = Id[];
type IntermediateSearchResults = Array<Id[]>; type IntermediateSearchResults = Array<Id[]>;
type SearchResults = DefaultSearchResults | Resolver; type SearchResults<D extends DocumentData = DocumentData> = DefaultSearchResults | Resolver<D>;
/** /**
* **Document:** * **Document:**
@@ -606,14 +606,14 @@ declare module "flexsearch" {
enrich?: boolean; enrich?: boolean;
}; };
type ResolverOptions = DefaultResolve & { type ResolverOptions<D extends DocumentData = DocumentData> = DefaultResolve & {
index?: Index | Document; index?: Index | Document<D>;
pluck?: FieldName; pluck?: FieldName<D>;
field?: FieldName; field?: FieldName<D>;
and?: ResolverOptions | Array<ResolverOptions>; and?: ResolverOptions<D> | Array<ResolverOptions<D>>;
or?: ResolverOptions | Array<ResolverOptions>; or?: ResolverOptions<D> | Array<ResolverOptions<D>>;
xor?: ResolverOptions | Array<ResolverOptions>; xor?: ResolverOptions<D> | Array<ResolverOptions<D>>;
not?: ResolverOptions | Array<ResolverOptions>; not?: ResolverOptions<D> | Array<ResolverOptions<D>>;
boost?: number; boost?: number;
suggest?: boolean; suggest?: boolean;
resolve?: boolean; resolve?: boolean;
@@ -660,7 +660,7 @@ declare module "flexsearch" {
addReplacer(match: string | RegExp, replace: string): this; addReplacer(match: string | RegExp, replace: string): this;
} }
export class Resolver { export class Resolver<D extends DocumentData = DocumentData> {
result: IntermediateSearchResults; result: IntermediateSearchResults;
constructor(options?: ResolverOptions | IntermediateSearchResults); constructor(options?: ResolverOptions | IntermediateSearchResults);
@@ -679,7 +679,7 @@ declare module "flexsearch" {
boost(boost: number): this; boost(boost: number): this;
resolve(options?: DefaultResolve): SearchResults; resolve(options?: DefaultResolve): SearchResults<D>;
} }
class StorageInterface { class StorageInterface {