Skip to content

FuseOptions<T> prevents nested key search #261

@LiamLB

Description

@LiamLB

Version: 3.3.0
Type: Potential Bug

Hi,

With the recent addition of typing to FuseOptions and Fuse nested key search is now giving Typescript compile errors.

The particular culprit is this line in the FuseOptions interface

keys?: (keyof T)[] | { name: keyof T; weight: number }[];

An example of how this was used in my application:

  fuseOptions: FuseOptions<Template> = {
    shouldSort: true,
    threshold: 0.6,
    keys: [
      { name: 'metadata.title', weight: 0.8 },
      { name: 'metadata.category', weight: 0.1 },
      { name: 'metadata.summary', weight: 0.1 },
    ],
  };

Where metadata was a key in template and title is a key in metadata. This is no longer allowed by the interface. As a temporary solution I've included a // @ts-ignore above the fuseOptions definition and functionality is fully #restored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions