luizbarboza / polyclip-ts

MIT License
27 stars 10 forks source link

Types not being exported in a robust way #18

Open smallsaucepan opened 4 hours ago

smallsaucepan commented 4 hours ago

Hi @luizbarboza. We're quite keen to use polyclip-ts over in Turfjs. However having some issues gettings the types imported e.g.

index.ts(10,27): error TS7016: Could not find a declaration file for module 'polyclip-ts'. '/Users/james/Code/turf/cmurphy23/node_modules/.pnpm/polyclip-ts@0.16.6/node_modules/polyclip-ts/dist/index.js' implicitly has an 'any' type.
  There are types at '/Users/james/Code/turf/cmurphy23/packages/turf-intersect/node_modules/polyclip-ts/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'polyclip-ts' library may need to update its package.json or typings.

One fix would be to flesh out the exports section of polyclip-ts/package.json, so would be happy to prepare a PR for that. However, without packaging CJS version of the library as well, the best we could hope for from arethetypeswrong would be:

Screenshot 2024-10-26 at 7 19 28 PM

Would you like a PR that will generate and export CJS also? Or do you prefer to stick with ESM only?

Thanks for maintaining the package!

luizbarboza commented 2 hours ago

Hi! Thanks for the suggestion and for supporting the package!

If possible, could you split it into two PRs—one to fix the type export issue and another to add CJS support? This would make the review process easier.

smallsaucepan commented 52 minutes ago

Sure thing 👍 Will do the smaller type export one first.

smallsaucepan commented 29 minutes ago

Oh, actually just saw #8, which had a similar goal to this issue. That PR was merged in e079fa8 but then rolled back some months later by 7bfaa6c.

Did something go wrong? Couldn't find any chatter about the reason.

luizbarboza commented 5 minutes ago

The PR was merged but rolled back before publishing a new version on npm. It references a PR in another repository that hasn’t been merged. I still have doubts about the ideal solution and want to be cautious with breaking changes.