-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
Cannot find module '~icons/heroicons-outline/cursor-click' or its corresponding type declarations. (typescript) #128
Comments
@ArgekarStudios duplicate of #119 - fixed in 0.12.23 |
Hi, I have the same problem NodeJS version: 16.13.1 Error images Files package.json
vite.config.ts
tsconfig.json
|
got the same error on the latest 0.12.23 |
I was able to resolve this by :
tsconfig.json compilerOptions : {
types: [
+ "unplugin-icons/types/vue",
]
} |
and for react types? |
@cesswhite From the readme:
Although with this I'm still stuck with a build error on Vite + React :
|
@MrSunshyne thank you for this, it is missing in the documentation and without it the module '~icons' is not defined. |
@hspaay the readme contains the types for |
@userquin found it. It is documented indeed so I stand corrected. Thank you kindly. As a side note, Webstorm still doesn't recognize the ~icons module even though vscode and the build work fine. My workaround is to add it to a shim file.
I can only speculate that webstorm doesn't interpret the compilerOptions 'types' section in tsconfig.json. |
@hspaay I use IntelliJ Ultimate Edition and it seems the problem comes from using typescript 4.5, using I'll add your hint for IDEA/WebStorm/VSCode users to solve the problem (I will also check where is the problem, when I have time ;) ). |
Ah good to hear I'm not alone in this. Maybe there is another factor involved. When forcing typescript to 4.4.4 in package.json, deleting node_modules and rebuilding, the problem with ~icons remains in webstorm. Next, trying this with IntelliJ Ultima the problem remains as well. |
配置确实好了 |
tsconfig.json
This works for me |
For anyone still having this issue, referencing unplugin-icon types in your env.d.ts seems to be the solution if you're working from a monorepo structure, like so:
And then replacing "vue3" with whatever front-end library you're working with. |
Using sveltekit, the error shows up in VSCode, and no solution in this thread worked for me. Adding this:
to Note: The ts error was not preventing the icons from being rendered correctly. |
Using svelte as well
I used MrSunshyne's #128 (comment) solution over here but with svelte instead. Works great! {
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
+ "types": ["unplugin-icons/types/svelte"]
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}
|
If anyone has landed here because of New version adding |
Using vue3/vite, do we have to define ~icons somehow or should that work automatically? I'm stuck here as well with
|
Apparently having them specified in the tsconfig is enough to make VS Code happy, but not enough for vue-tsc. For that to work, we would also need to add the unplugin-icons folder inside node_modules to the `include` option in tsconfig, which didn't feel good. Adding them to the environment seems to do the trick for both though. See: unplugin/unplugin-icons#128 RISDEV-3192
I have installed npm json icons
The text was updated successfully, but these errors were encountered: