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

Type declaration is messed up with JSON imports #430

Open
hyrious opened this issue Aug 28, 2024 · 0 comments
Open

Type declaration is messed up with JSON imports #430

hyrious opened this issue Aug 28, 2024 · 0 comments
Labels
bug Something isn't working dts

Comments

@hyrious
Copy link

hyrious commented Aug 28, 2024

Environment

Node.js v22.5.1

Reproduction

See this type declaration file in @unocss/preset-icons: https://hyrious.me/npm-browser/?q=@unocss/[email protected]/package/dist/core.d.ts:101

Describe the bug

image

Additional context

I myself solved this problem by adding a custom rollup plugin that replaces the JSON file with a transformed valid JS(TS) file so that rollup-plugin-dts can handle it like other files: https://github.com/hyrious/dts/blob/main/src/index.ts#L162-L169

This is not the best solution as it needs to write to the filesystem. Ideally the plugin should just return a .d.ts file representing the JSON module with a custom resolve hook so that rollup-plugin-dts's transform file task won't run. However it needs to replicate some works in rollup-plugin-dts where I'm too lazy to do so.

Logs

No response

@hyrious hyrious added the bug Something isn't working label Aug 28, 2024
@pi0 pi0 added the dts label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dts
Projects
None yet
Development

No branches or pull requests

2 participants