Skip to content

Commit

Permalink
fix(ts): export FuseIndex type
Browse files Browse the repository at this point in the history
Export FuseIndex type in the namespace. Fixes #519
  • Loading branch information
krisk committed Jan 1, 2021
1 parent 8882044 commit 2e60bee
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ declare class Fuse<T> {
constructor(
list: ReadonlyArray<T>,
options?: Fuse.IFuseOptions<T>,
index?: FuseIndex<T>
index?: Fuse.FuseIndex<T>
)
/**
* Search function for the Fuse instance.
Expand All @@ -25,12 +25,12 @@ declare class Fuse<T> {
* @param options `Fuse.FuseSearchOptions`
* @returns An array of search results
*/
search<R = T>(
search<T>(
pattern: string | Fuse.Expression,
options?: Fuse.FuseSearchOptions
): Fuse.FuseResult<R>[]
): Fuse.FuseResult<T>[]

setCollection(docs: ReadonlyArray<T>, index?: FuseIndex<T>): void
setCollection(docs: ReadonlyArray<T>, index?: Fuse.FuseIndex<T>): void

/**
* Adds a doc to the end the list.
Expand All @@ -52,7 +52,7 @@ declare class Fuse<T> {
/**
* Returns the generated Fuse index
*/
getIndex(): FuseIndex<T>
getIndex(): Fuse.FuseIndex<T>

/**
* Return the current version.
Expand Down Expand Up @@ -89,28 +89,28 @@ declare class Fuse<T> {
keys: Array<Fuse.FuseOptionKey>,
list: ReadonlyArray<U>,
options?: Fuse.FuseIndexOptions<U>
): FuseIndex<U>
): Fuse.FuseIndex<U>

static parseIndex<U>(
index: any,
options?: Fuse.FuseIndexOptions<U>
): FuseIndex<U>
): Fuse.FuseIndex<U>
}

declare class FuseIndex<T> {
constructor(options?: Fuse.FuseIndexOptions<T>)
setSources(docs: ReadonlyArray<T>): void
setKeys(keys: ReadonlyArray<string>): void
setIndexRecords(records: Fuse.FuseIndexRecords): void
create(): void
add(doc: T): void
toJSON(): {
keys: ReadonlyArray<string>
collection: Fuse.FuseIndexRecords
declare namespace Fuse {
export class FuseIndex<T> {
constructor(options?: FuseIndexOptions<T>)
setSources(docs: ReadonlyArray<T>): void
setKeys(keys: ReadonlyArray<string>): void
setIndexRecords(records: FuseIndexRecords): void
create(): void
add(doc: T): void
toJSON(): {
keys: ReadonlyArray<string>
collection: FuseIndexRecords
}
}
}

declare namespace Fuse {
type FuseGetFunction<T> = (
obj: T,
path: string | string[]
Expand Down

0 comments on commit 2e60bee

Please sign in to comment.