palerdot / react-d3-speedometer

React Speedometer component using d3.js ⚛️
https://palerdot.in/react-d3-speedometer/
MIT License
232 stars 58 forks source link

Added "types" export to package.json #182

Closed boginw closed 9 months ago

boginw commented 9 months ago

The current package.json results in an error in TypeScript 5.2.2 (perhaps also for versions back to 4.7). Here's the error:

error TS7016: Could not find a declaration file for module 'react-d3-speedometer'. '<path-to-project>/node_modules/react-d3-speedometer/dist/react-d3-speedometer.es.js' implicitly has an 'any' type.
  There are types at '<path-to-project>/node_modules/react-d3-speedometer/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'react-d3-speedometer' library may need to update its package.json or typing.

According to this StackOverflow post, when "exports" is defined "types" needs to be defined in the "exports".

Adding "types": "./dist/index.d.ts" to "exports" fixes things, at least it does for my project.

palerdot commented 9 months ago

Thanks. I will update the issue once the package is published in npm.

palerdot commented 9 months ago

v2.2.1 published with the changes.

boginw commented 9 months ago

Thanks for the swift response :)