Skip to content

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

Closed
@BenJenkinson

Description

@BenJenkinson
Contributor

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

added 3 commits that reference this issue on May 5, 2022
739222c
ddfee1f
4acabb6
krisk

krisk commented on May 6, 2022

@krisk
Owner

Does look like a regression specifically for the getFn part. Will address.

added a commit that references this issue on May 6, 2022
3463d1d
added 2 commits that reference this issue on May 6, 2022
80b87a9
0a790b5
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

      Participants

      @BenJenkinson@krisk

      Issue actions

        [Typescript] `FuseOptionKeyObject` type doesn't match the implementation · Issue #655 · krisk/Fuse