Skip to content

Commit

Permalink
fix: fix types under node16 moduleResolution (#441)
Browse files Browse the repository at this point in the history
The types of this library do not match the actual JS code, leading to a situation where using ESM under the `node16` moduleResolution method in TypeScript, the default export types will fail to resolve. TypeScript is more strict around type compliance with these settings enabled, and therefore requires the types to match.

The JS code does not use a default import, as `export default` in ESM is not identical to `module.exports = `. `export =` can be used in the `index.d.ts` to match the behaviour within the JS file.

More information on this specific issue is available here, https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md
  • Loading branch information
me4502 authored Dec 8, 2023
1 parent 7bf34e9 commit 2767829
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ export interface Hotkeys {
}
// https://github.com/eiriklv/react-masonry-component/issues/57
declare var hotkeys: Hotkeys;
export default hotkeys;
export = hotkeys;

0 comments on commit 2767829

Please sign in to comment.