postcss-normalize icon indicating copy to clipboard operation
postcss-normalize copied to clipboard

Support TS `moduleResolution: "node16"`

Open antitoxic opened this issue 1 year ago • 0 comments

First issue fixed

"moduleResolution": "node16" in TS will cause:

TS7016: Could not find a declaration file for module postcss-normalize. `postcss-normalize/index.mjs` implicitly has an any type.

There are types at `postcss-normalize/index.d.ts`, but this result could not be resolved when respecting package.json exports. The postcss-normalize library may need to update its package.json or typings.

Second issue fixed:

  • Typescript "moduleResolution": "node16" requires different type info when CJS modules like this one are imported from ESM module.
  • To make default exports (export default) work for both CJS and ESM, we need export = X and not export default X.
  • When you have multiple exports you need to create a namespace named exactly X and in there define the exports.

refs:

  • https://github.com/microsoft/TypeScript/issues/52086
  • https://stackoverflow.com/a/51238234/339872

PS/FYI: npm run test tape was failing even before my changes so i had to commit with --no-verify.

antitoxic avatar Dec 26 '23 09:12 antitoxic