Skip to content

Commit 0a790b5

Browse files
committed
fix(typescript): type definition for FuseOptionKeyObject
fixes #655 #656
1 parent da6e399 commit 0a790b5

1 file changed

Lines changed: 9 additions & 22 deletions

File tree

src/index.d.ts

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,8 @@ declare namespace Fuse {
178178
// 'n': 0.5773502691896258
179179
// }
180180
type RecordEntryObject = {
181-
/** The text value */
182-
v: string
183-
/** The field-length norm */
184-
n: number
181+
v: string // The text value
182+
n: number // The field-length norm
185183
}
186184

187185
// 'author.tags.name': [{
@@ -207,8 +205,7 @@ declare namespace Fuse {
207205
// }
208206
// }
209207
type FuseIndexObjectRecord = {
210-
/** The index of the record in the source list */
211-
i: number
208+
i: number // The index of the record in the source list
212209
$: RecordEntry
213210
}
214211

@@ -221,33 +218,23 @@ declare namespace Fuse {
221218
// ]
222219
// }
223220
type FuseIndexStringRecord = {
224-
/** The index of the record in the source list */
225-
i: number
226-
/** The text value */
227-
v: string
228-
/** The field-length norm */
229-
n: number
221+
i: number // The index of the record in the source list
222+
v: string // The text value
223+
n: number // The field-length norm
230224
}
231225

232226
type FuseIndexRecords =
233227
| ReadonlyArray<FuseIndexObjectRecord>
234228
| ReadonlyArray<FuseIndexStringRecord>
235-
236-
type FuseOptionKeyObjectGetFunction<T> = (
237-
obj: T,
238-
) => ReadonlyArray<string> | string
239229

240230
// {
241231
// name: 'title',
242-
// weight: 0.7,
243-
// getFn: (book) => book.title
232+
// weight: 0.7
244233
// }
245234
export type FuseOptionKeyObject<T> = {
246-
name: string | string[]
247-
/** 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. */
235+
name: string | string[]
248236
weight?: number
249-
/** The function to use to retrieve an object's value */
250-
getFn?: FuseOptionKeyObjectGetFunction<T>
237+
getFn?: (obj: T) => ReadonlyArray<string> | string
251238
}
252239

253240
export type FuseOptionKey<T> = FuseOptionKeyObject<T> | string | string[]

0 commit comments

Comments
 (0)