krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
17.77k stars 754 forks source link

Typescript definitions for fuse.basic are not being built and exported #642

Closed youssefm closed 1 year ago

youssefm commented 2 years ago

Describe the bug

I was hoping to use fuse.basic because I don't need extended search.

But if you try to import fuse.basic like this in a node project:

import Fuse from "fuse.js/dist/fuse.basic";

You get the following typescript error:

Could not find a declaration file for module 'fuse.js/dist/fuse.basic'

It seems to me like a fuse.basic.d.ts file should be available in the dist folder of the package. Or that there should be a separate fuse.basic npm package that does export a type definition file.

Version

6.5.3

Is this a regression?

Doesn't seem like a regression

🔬Minimal Reproduction

Create a node typescript project, install fuse, try to import Fuse from the fuse.basic script.

Racide commented 2 years ago

I'm not sure how to deal with this problem either, any file which isn't fuse.js will cause the same error.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 30 days

mickaelchanrion commented 1 year ago

While waiting for a fix, you could declare the module in your project using the declaration fuse.d.ts.

In a file with the extension .d.ts:

declare module 'fuse.js/dist/fuse.basic.esm' {
  import Fuse from 'fuse.js'
  export default Fuse
}