kripod / react-polymorphic-types

Zero-runtime polymorphic component definitions for React
MIT License
195 stars 8 forks source link

fix(types): Update package.json exports to support TypeScript 4.7 #16

Open yoginderkumar opened 6 months ago

yoginderkumar commented 6 months ago

PR Description:

This pull request addresses the changes introduced in TypeScript 4.7 regarding the handling of package.json exports and imports. The TypeScript team has improved the way types are resolved when using the exports field in package.json, which requires updates to our codebase to ensure compatibility.

Changes:

Reference:

Before:

"exports": {
  "default": "./empty.js",
  "import": "./empty.js"
},
"main": "./empty.js",
"types": "./index.d.ts"

After:

"exports": {
  "types": "./index.d.ts",
  "default": "./empty.js",
  "import": "./empty.js"
},
"main": "./empty.js"

By making these changes, we ensure compatibility with TypeScript 4.7 and future versions, providing a smoother development experience and preventing potential issues related to type resolution.

kripod commented 6 months ago

Thanks for your contribution!

Unfortunately, though, I’m not maintaining this project anymore as recent improvements in @types/react made it feasible to roll your own implementation: https://www.kripod.dev/blog/behind-the-as-prop-polymorphism-done-well/

Please feel free to fork the codebase if you want to.