Closed LukeNotable closed 1 year ago
When trying to import generate-password from a TypeScript project built as ES Module (rather than CommonJS), it gives the error:
generate-password
Could not find a declaration file for module 'generate-password'.
My temporary workaround has been to add this to tsconfig.json:
tsconfig.json
"paths": { "generate-password": ["./node_modules/generate-password/src/generate.d.ts"] },
Basically, the types are not declared correctly for consumption by ESM. You can check this on Are the Types Wrong?, or using its CLI:
Are the Types Wrong?
npx @arethetypeswrong/cli --pack .
This PR updates the exports field in package.json to something that passes the above check and works in my ESM project (as well as CJS projects).
exports
package.json
👍
Thanks for the contribution @LukeNotable , merged in https://github.com/brendanashworth/generate-password/commit/5068595ab3e7f3d85ec5b8f1f513cb30c0b1d296!
and it's also published as 1.7.1
When trying to import
generate-password
from a TypeScript project built as ES Module (rather than CommonJS), it gives the error:My temporary workaround has been to add this to
tsconfig.json
:Basically, the types are not declared correctly for consumption by ESM. You can check this on
Are the Types Wrong?
, or using its CLI:This PR updates the
exports
field inpackage.json
to something that passes the above check and works in my ESM project (as well as CJS projects).