krisk / Fuse

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

Fix incorrect default export in TS declaration file #731

Closed andrewbranch closed 10 months ago

andrewbranch commented 11 months ago

The TS declaration file is loaded by TypeScript in the "typings" field of package.json. This field corresponds to the "main" field, which is set to ./dist/fuse.common.js, which does

module.exports = Fuse;

The correct TS representation of module.exports = Fuse is export = Fuse, not export default Fuse.

This is the root cause of many previous reports:

and was brought to my attention at https://github.com/microsoft/TypeScript/issues/50058#issuecomment-1644335391.

You can see the bug is also detected at https://arethetypeswrong.github.io/?p=fuse.js%406.6.2. Explainer: https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md.

Note also:

I’ve thrown a lot of information at you, but I’m happy to answer any questions or concerns you may have!

jstasiak commented 11 months ago

I just tried this patch locally and it worked.

andrewbranch commented 11 months ago

This may be superseded by #727

favna commented 10 months ago

I have processed your review comment on #727 so I think you can close this one @andrewbranch

andrewbranch commented 10 months ago

Awesome!