Skip to content

Commit dfa4823

Browse files
committed
fix(typescript): add typing for nested paths with array notation
1 parent 938db2a commit dfa4823

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

dist/fuse.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ declare class Fuse<T, O extends Fuse.IFuseOptions<T>> {
8585
* @returns An indexed list
8686
*/
8787
static createIndex<U>(
88-
keys: Fuse.FuseOptionKeyObject[] | string[],
88+
keys: Array<Fuse.FuseOptionKey>,
8989
list: ReadonlyArray<U>,
9090
options?: Fuse.FuseIndexOptions<U>
9191
): FuseIndex<U>
@@ -231,10 +231,12 @@ declare namespace Fuse {
231231
// weight: 0.7
232232
// }
233233
export type FuseOptionKeyObject = {
234-
name: string
234+
name: string | [string]
235235
weight: number
236236
}
237237

238+
export type FuseOptionKey = FuseOptionKeyObject | string | [string]
239+
238240
export interface IFuseOptions<T> {
239241
isCaseSensitive?: boolean
240242
distance?: number
@@ -244,7 +246,7 @@ declare namespace Fuse {
244246
ignoreFieldNorm?: boolean
245247
includeMatches?: boolean
246248
includeScore?: boolean
247-
keys?: FuseOptionKeyObject[] | string[]
249+
keys?: Array<FuseOptionKey>
248250
location?: number
249251
minMatchCharLength?: number
250252
shouldSort?: boolean
@@ -278,6 +280,10 @@ declare namespace Fuse {
278280

279281
export type Expression =
280282
| { [key: string]: string }
283+
| {
284+
$path: ReadonlyArray<string>
285+
$val: string
286+
}
281287
| { $and?: Expression[] }
282288
| { $or?: Expression[] }
283289
}

src/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ declare namespace Fuse {
277277

278278
export type Expression =
279279
| { [key: string]: string }
280+
| {
281+
$path: ReadonlyArray<string>
282+
$val: string
283+
}
280284
| { $and?: Expression[] }
281285
| { $or?: Expression[] }
282286
}

0 commit comments

Comments
 (0)