Fix incorrect default export in TS declaration file #731
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 doesThe correct TS representation of
module.exports = Fuse
isexport = Fuse
, notexport default Fuse
.This is the root cause of many previous reports:
and was brought to my attention at microsoft/TypeScript#50058 (comment).
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:
esModuleInterop
set or not. While TS users should always set that option, when they have to in order to use a library, it always indicates that the library is misconfigured. It’s never a correct solution for a library to require TS users to set that option one way or another.esModuleInterop
is irrelevant for users who are importing Fuse from a true ES module, as was attempted in Old namespace syntax for typescript definitions breaks when using ES Modules #679 and "moduleResolution": "NodeNext" throws ESM related errors microsoft/TypeScript#50058 (comment). Those users are completely unable to import Fuse without compiler errors without this PR, regardless of whether they setesModuleInterop
.I’ve thrown a lot of information at you, but I’m happy to answer any questions or concerns you may have!