Skip to content

The type for Fuse.search defaults to unknown #527

@qnighy

Description

@qnighy

Describe the bug

2e60bee changed the signature of Fuse.prototype.search.

  search<T>(
    pattern: string | Fuse.Expression,
    options?: Fuse.FuseSearchOptions
  ): Fuse.FuseResult<T>[]

Here T isn't constrained by any of the arguments. Therefore it defaults to unknown, making it meaningless.

I guess search<T>(...) was meant to be search(...), using T from the outer Fuse<T>?

Version

Fuse 6.4.5

Is this a regression?

Yes. Previously the type parameter was named R and was defaulted to T from the outer class Fuse<T>.

🔬Minimal Reproduction

declare const fuse: Fuse<{ id: number }>;
const matchedIds = fuse.search("").map(res => res.item.id);

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions