missing type for remark-emoji on ESM ts file
onemen opened this issue · 8 comments
When using import emoji from 'remark-emoji'
on .ts
file in ESM project with "type": "module",
I get this error:
⚠ Error (TS7016) |
Could not find a declaration file for module
. c:/projects/_____/node_modules/remark-emoji/index.js implicitly has an
type.
There are types at c:/projects/_____/node_modules/remark-emoji/types/index.d.ts', but this result could not be resolved when respecting package.json "exports".
The 'remark-emoji library may need to update its package.json or typings.
I need to understand the reason. I could not find any difference in type definitions configuration in package.json comparing with other packages such as remark-parse.
https://github.com/remarkjs/remark/blob/main/packages/remark-parse/package.json
maybe this will help
https://www.typescriptlang.org/docs/handbook/esm-node.html
Thanks. I could reproduce this with the following tsconfig.json
{
"compilerOptions": {
"target": "es2016",
"module": "NodeNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
It seems that this exports
is not correct.
Line 9 in 8b7530d
I think the following config (or simply removing it) is correct:
"exports": {
".": {
"import": {
"types": "./types/index.d.ts",
"default": "./index.js"
}
}
},
Released at v3.1.2.
👍
It seems that this
exports
is not correct.Line 9 in 8b7530d
I think the following config (or simply removing it) is correct:
"exports": { ".": { "import": { "types": "./types/index.d.ts", "default": "./index.js" } } },
This renders the plugin unusable when trying to add it to Storybook:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in %%REDACTED%%\node_modules\remark-emoji\package.json
The next exports might do the trick, but version 3.1.1 works without any kind of issue:
"exports": {
".": {
"import": {
"types": "./types/index.d.ts",
"default": "./index.js"
},
"require": "./index.js"
}
},