pixiv / charcoal

Design system library by pixiv
https://charcoal-web.pixiv.design/
Apache License 2.0
319 stars 35 forks source link

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

Open danyyil-pelekhatyi opened 6 months ago

danyyil-pelekhatyi commented 6 months ago

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

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