unplugin / unplugin-icons

🤹 Access thousands of icons as components on-demand universally.
https://www.npmjs.com/package/unplugin-icons
MIT License
3.79k stars 133 forks source link

Cannot resolve directory '~icons' in PHPStorm IDE #235

Closed anburocky3 closed 1 year ago

anburocky3 commented 1 year ago

How to suppress or get rid of these IDE errors?

image

Adding docs on that, in the readme, would be super helpful.

userquin commented 1 year ago

try adding a vite-env.d.ts inside your src folder adding this (if you're NOT using vue, configure the corresponding fw):

/// <reference types="unplugin-icons/types/vue" />
userquin commented 1 year ago

if not working try adding this to your tsconfig.json:

"compilerOptions": {
  "types": ["unplugin-icons/types/vue"]
}
anburocky3 commented 1 year ago

I have already added the types in the tsconfig.json file.

I'm using Laravel with Vite, Where should i place the file vite-env.d.ts?

I placed in root as well as resources/js/ both, didn't pick up that, same issue.

userquin commented 1 year ago

what's the content of your tsconfig.json file?

EDIT: just add the include entry and set it where you want...

anburocky3 commented 1 year ago

These are my tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "module": "es2020",
        "moduleResolution": "node",
        "strict": true,
        // Enable strict type-checking options
        "skipLibCheck": true,
        // Skip type checking of declaration files
        "noImplicitAny": false,
        // Bypass raising errors on `any` type
        "baseUrl": ".",
        "paths": {
            "@/*": [
                "./resources/js/*"
            ],
            "ziggy": [
                "vendor/tightenco/ziggy/dist/vue"
            ]
        },
        "types": [
            "vite/client",
            "node",
            "unplugin-icons/types/vue"
        ]
    },
    "include": [
        "resources/assets",
        "resources/js/**/*"
    ]
    // Frontend paths pattern
}

I think, the error which i showed before, is coming from PHPStorm and not typescript.

userquin commented 1 year ago

try adding the dts file inside resources folder and add "resources/**.d.ts" to the include entry.

have you configured TS in the IDE (IntelliJ screenshot)?

upps, I'll upload another screenshot

imagen

userquin commented 1 year ago

For example, Vue3 example resolving, but the react one missing (in both cases the IDE will go to the definition):

imagen

anburocky3 commented 1 year ago

This is what i did:

  1. Created vite-env.d.ts inside resources directory with the following code.
    /// <reference types="unplugin-icons/types/vue" />
  2. Added the entry in the tsconfig.json file
    "include": [
        "resources/assets",
        "resources/js/**/*",
    +        "resources/**.d.ts"
    ]
  3. Yes, my Typescript is configured correctly like this. image

After all this, still: image

LUDA0831 commented 1 year ago

You can refer to this issues #213

anburocky3 commented 1 year ago

Thank you and it fixed the errors. Thank you.