From 0a790b516efec2e6c5539bdd40d04889e6252dfe Mon Sep 17 00:00:00 2001 From: Kiro Risk <565580+krisk@users.noreply.github.com> Date: Thu, 5 May 2022 19:39:06 -0700 Subject: [PATCH] fix(typescript): type definition for FuseOptionKeyObject fixes #655 #656 --- src/index.d.ts | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/index.d.ts b/src/index.d.ts index a97c19370..a3abe588d 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -178,10 +178,8 @@ declare namespace Fuse { // 'n': 0.5773502691896258 // } type RecordEntryObject = { - /** The text value */ - v: string - /** The field-length norm */ - n: number + v: string // The text value + n: number // The field-length norm } // 'author.tags.name': [{ @@ -207,8 +205,7 @@ declare namespace Fuse { // } // } type FuseIndexObjectRecord = { - /** The index of the record in the source list */ - i: number + i: number // The index of the record in the source list $: RecordEntry } @@ -221,33 +218,23 @@ declare namespace Fuse { // ] // } type FuseIndexStringRecord = { - /** The index of the record in the source list */ - i: number - /** The text value */ - v: string - /** The field-length norm */ - n: number + i: number // The index of the record in the source list + v: string // The text value + n: number // The field-length norm } type FuseIndexRecords = | ReadonlyArray | ReadonlyArray - - type FuseOptionKeyObjectGetFunction = ( - obj: T, - ) => ReadonlyArray | string // { // name: 'title', - // weight: 0.7, - // getFn: (book) => book.title + // weight: 0.7 // } export type FuseOptionKeyObject = { - name: string | string[] - /** Adjust the weight of each key to give them higher (or lower) values in search results. The `weight` value must be greater than zero. If undefined, it will default to `1`. Internally, Fuse will normalize weights to be within `0` and `1` exclusive. */ + name: string | string[] weight?: number - /** The function to use to retrieve an object's value */ - getFn?: FuseOptionKeyObjectGetFunction + getFn?: (obj: T) => ReadonlyArray | string } export type FuseOptionKey = FuseOptionKeyObject | string | string[]