diff --git a/index.d.ts b/index.d.ts index 57f2cfd..6ddf756 100644 --- a/index.d.ts +++ b/index.d.ts @@ -30,9 +30,8 @@ declare module "flexsearch" { | "default"; /** - * **Document:** - * * Tokenizer: https://github.com/nextapps-de/flexsearch#tokenizer-prefix-search - * * Add custom tokenizer: https://github.com/nextapps-de/flexsearch#add-custom-tokenizer + * Tokenizer: https://github.com/nextapps-de/flexsearch#tokenizer-prefix-search \ + * Custom Tokenizer: https://github.com/nextapps-de/flexsearch#add-custom-tokenizer */ type Tokenizer = | "strict" | "exact" | "default" @@ -41,8 +40,7 @@ declare module "flexsearch" { | "full"; /** - * **Document:** - * * Encoders: https://github.com/nextapps-de/flexsearch#encoders + * Encoders: https://github.com/nextapps-de/flexsearch#encoders */ type Encoders = | "Exact" @@ -77,7 +75,7 @@ declare module "flexsearch" { * **Document:** * * Search options: https://github.com/nextapps-de/flexsearch#search-options */ - export type SearchOptions = { + type SearchOptions = { query?: string; limit?: number; offset?: number; @@ -217,8 +215,8 @@ declare module "flexsearch" { export?: () => Promise; import?: () => Promise; // no persistent supported - db: null; - commit: null; + db?: null; + commit?: null; }; /************************************/ @@ -386,21 +384,23 @@ declare module "flexsearch" { type WorkerType = boolean | WorkerURL | WorkerPath - type DocumentOptions = - IndexOptions - & { + type DocumentOptions< + D extends DocumentData = DocumentData, + W extends WorkerType = false, + B extends StorageInterface = undefined + > = IndexOptions & { worker?: W; doc?: DocumentDescriptor; document?: DocumentDescriptor; }; - export type DefaultDocumentSearchResults = Array<{ + type DefaultDocumentSearchResults = Array<{ field?: FieldName; tag?: FieldName; result: DefaultSearchResults; }>; - export type EnrichedDocumentSearchResults = Array<{ + type EnrichedDocumentSearchResults = Array<{ field?: FieldName; tag?: FieldName; result: Array<{ @@ -410,15 +410,19 @@ declare module "flexsearch" { }>; }>; - export type MergedDocumentSearchResults = Array<{ + type MergedDocumentSearchResults = Array<{ id: Id; doc: D | null; field?: FieldName[]; tag?: FieldName[]; }>; - type DocumentSearchResults = - R extends true + type DocumentSearchResults< + D extends DocumentData = DocumentData, + R extends boolean = false, + E extends boolean = false, + M extends boolean = false + > = R extends true ? Resolver : M extends true ? MergedDocumentSearchResults @@ -733,7 +737,7 @@ declare module "flexsearch" { } global { - export class StorageInterface { + class StorageInterface { db: any; constructor(name: string, config: PersistentOptions);