You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It errors: "Could not find a declaration file for module 'eta'. 'node_modules/eta/dist/eta.cjs' implicitly has an 'any' type."
The reason is because eta's package.json exports does not have a types field for each entry, so TS can't associate the js files with their types. (Before, TS would always use the root types entry).
Fixing this is a bit involved, because the package also has "type": "module", which causes the .d.ts files to be interpreted as ESM. Therefore, even for .d.ts files, explicit extensions are required. I'm not sure what the best way to fix this is, so I just want it to be in your backlog first.
@jakubmazanec just added a "types" field to the exports entry in package.json, but I'll leave this open because the exports field needs some more substantial changes.
While working on facebook/docusaurus#7586,
eta
was one of the packages blocking a successful compilation.To Reproduce
yarn add typescript eta
tsconfig.json:
Add a TS file with:
It errors: "Could not find a declaration file for module 'eta'. 'node_modules/eta/dist/eta.cjs' implicitly has an 'any' type."
The reason is because eta's package.json
exports
does not have atypes
field for each entry, so TS can't associate the js files with their types. (Before, TS would always use the roottypes
entry).Fixing this is a bit involved, because the package also has
"type": "module"
, which causes the .d.ts files to be interpreted as ESM. Therefore, even for .d.ts files, explicit extensions are required. I'm not sure what the best way to fix this is, so I just want it to be in your backlog first.Expected behavior
Successful TS compilation
Package & Environment Details
Additional context
There's some basic writeup here: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencing I can't find a more comprehensive guide.
The text was updated successfully, but these errors were encountered: