Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: typescript can't find declaration file for module #520

Open
danyyil-pelekhatyi opened this issue Apr 12, 2024 · 0 comments
Open

Bug: typescript can't find declaration file for module #520

danyyil-pelekhatyi opened this issue Apr 12, 2024 · 0 comments

Comments

@danyyil-pelekhatyi
Copy link

できる限り詳細に、不具合の内容と再現方法を報告してください

Could not find a declaration file for module '@charcoal-ui/icons'. 'g:/Workflow/Amica/amica/node_modules/@charcoal-ui/icons/dist/index.esm.js' implicitly has an 'any' type.
There are types at 'g:/Workflow/Amica/amica/node_modules/@charcoal-ui/icons/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@charcoal-ui/icons' library may need to update its package.json or typings.ts(7016)

Happens on
import { KnownIconType } from "@charcoal-ui/icons";

tsconfig.json settings
...
"module": "esnext",
"moduleResolution": "bundler",
...

The issue seems to be that the types field in package.json is no longer used if there is an exports] field: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-referencing

If you need to point to a different location for your type declarations, you can add a "types" import condition.

Therefore you should be good by simply copying your "types": "./dist/index.d.ts" indication within your exports."." declaration:

"exports": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs.js",
"default": "./dist/index.esm.js"
},

使用している charcoal および周辺環境

@charcoal-ui/icons
@tailwindcss
@esbuild
@eslint
@next
@nodelib
@pixiv
@types
@typescript-eslint

コード例へのリンク

No response

現在の挙動

No response

期待される挙動

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant