Skip to content

[Typescript] FuseOptionKeyObject type doesn't match the implementation #655

Closed
@BenJenkinson

Description

The FuseOptionKeyObject type definition doesn't match the implementation.

Fuse/src/index.d.ts

Lines 234 to 239 in 6afcfaf

export type FuseOptionKeyObject = {
name: string | string[]
weight: number
}
export type FuseOptionKey = FuseOptionKeyObject | string | string[]

  • The weight property may be optional. (Since if not specified, Fuse will default it to 1)

if (hasOwn.call(key, 'weight')) {
weight = key.weight
if (weight <= 0) {
throw new Error(ErrorMsg.INVALID_KEY_WEIGHT_VALUE(name))
}
}

  • The getFn property is missing.

Fuse/docs/examples.md

Lines 170 to 180 in 6afcfaf

const options = {
includeScore: true,
keys: [
{ name: 'title', getFn: (book) => book.title },
{ name: 'authorName', getFn: (book) => book.author.name }
]
})
const fuse = new Fuse(list, options)
const result = fuse.search({ authorName: 'Steve' })

Version

6.6.0

Is this a regression?

No

🔬Minimal Reproduction (in Typescript)

  • The weight property cannot be omitted without an error.
  • The getFn example from the docs cannot be written without an error.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions