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

Merge pull request #502 from flycran/master

- 修正`StoreOptions`类型推断。
This commit is contained in:
Thomas Wilkerling
2025-05-09 07:42:02 +02:00
committed by GitHub

25
index.d.ts vendored
View File

@@ -404,21 +404,32 @@ declare module "flexsearch" {
export type DefaultFieldOptions< export type DefaultFieldOptions<
D = DocumentData, D = DocumentData,
C extends CustomFN<D> | boolean = false
> = IndexOptions & { > = IndexOptions & {
custom?: C; field: FieldName<D>;
field: C extends false ? FieldName<D> : FieldName;
filter?: (doc: D) => boolean; filter?: (doc: D) => boolean;
db?: StorageInterface; db?: StorageInterface;
}; };
export type FieldOptions<D = DocumentData> = IndexOptions & DefaultFieldOptions<D> & { export type DefaultCustomFieldOptions<
config?: WorkerConfigURL | WorkerConfigPath; D = DocumentData,
> = IndexOptions & {
custom: CustomFN<D>;
field: FieldName;
filter?: (doc: D) => boolean;
db?: StorageInterface;
}; };
export type TagOptions<D = DocumentData> = DefaultFieldOptions<D>; export type TagOptions<D = DocumentData> = DefaultFieldOptions<D> | DefaultCustomFieldOptions<D>;
export type StoreOptions<D = DocumentData> = DefaultFieldOptions<D>; export type StoreOptions<D = DocumentData> = DefaultFieldOptions<D> | DefaultCustomFieldOptions<D>;
export interface IndexWorkerConfig {
config?: WorkerConfigURL | WorkerConfigPath;
}
export type FieldOptions<D extends DocumentData> =
(DefaultFieldOptions<D> & IndexWorkerConfig)
| (DefaultCustomFieldOptions<D> & IndexWorkerConfig)
/** /**
* # Document Search Result * # Document Search Result