From e93905fc36a95020c9faac5e8185d4feaf8dfba0 Mon Sep 17 00:00:00 2001 From: Thomas Wilkerling Date: Tue, 6 May 2025 13:47:05 +0200 Subject: [PATCH] minor improve readability of index.d.ts --- index.d.ts | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/index.d.ts b/index.d.ts index bdb3a81..57f2cfd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -162,7 +162,13 @@ declare module "flexsearch" { LatinAdvanced: EncoderOptions, LatinExtra: EncoderOptions, LatinSoundex: EncoderOptions, - CJK: EncoderOptions + CJK: EncoderOptions, + /** @deprecated */ + LatinSimple: EncoderOptions, + /** @deprecated */ + LatinExact: EncoderOptions, + /** @deprecated */ + LatinDefault: EncoderOptions }; /** @@ -230,8 +236,15 @@ declare module "flexsearch" { * * Usage: https://github.com/nextapps-de/flexsearch#usage */ - type IndexSearchResultsWrapper = - W extends false ? D extends undefined ? SearchResults : Promise> : Promise> + type IndexSearchResultsWrapper< + W extends boolean = false, + D extends StorageInterface = undefined, + R extends boolean = false + > = W extends false + ? D extends undefined + ? SearchResults + : Promise> + : Promise> export class Index { constructor(options?: Preset | IndexOptions); @@ -405,12 +418,13 @@ declare module "flexsearch" { }>; type DocumentSearchResults = - R extends true ? Resolver : - M extends true ? - MergedDocumentSearchResults : - E extends true ? - EnrichedDocumentSearchResults : - DefaultDocumentSearchResults + R extends true + ? Resolver + : M extends true + ? MergedDocumentSearchResults + : E extends true + ? EnrichedDocumentSearchResults + : DefaultDocumentSearchResults /** @@ -428,9 +442,12 @@ declare module "flexsearch" { * * Document search options: https://github.com/nextapps-de/flexsearch#document-search-options */ - type DocumentSearchOptions = - SearchOptions - & { + type DocumentSearchOptions< + D extends DocumentData = DocumentData, + R extends boolean = false, + E extends boolean = false, + M extends boolean = false + > = SearchOptions & { tag?: Object | Array; field?: Array> | DocumentSearchOptions | string[] | string; index?: Array> | DocumentSearchOptions | string[] | string; @@ -470,7 +487,11 @@ declare module "flexsearch" { * * API overview: https://github.com/nextapps-de/flexsearch#api-overview * * Document store: https://github.com/nextapps-de/flexsearch#document-store */ - export class Document { + export class Document< + D extends DocumentData = DocumentData, + W extends WorkerType = false, + B extends StorageInterface = undefined + > { constructor(options: DocumentOptions); add(id: Id, document: D): this | Promise; @@ -648,7 +669,7 @@ declare module "flexsearch" { resolve?: boolean; limit?: number; offset?: number; - /** only usable when "resolve" was set to true */ + /** only usable when "resolve" was not set to false */ enrich?: boolean; }; @@ -716,7 +737,6 @@ declare module "flexsearch" { db: any; constructor(name: string, config: PersistentOptions); - constructor(config: string | PersistentOptions); mount(index: Index | Document): Promise;