Path alias is not recognised in .vue files
Hi,
I'm running the Vue.js project with typescript and having issues with imports in the .vue files.
As you can see in the screenshot (Upload id: 2020_10_05_61aRoUrLVauJf9Pg (file: Screenshot 2020-10-05 at 15.38.07.png)) path alias are not recognized by IDE (though project compiles without errors). "appTypes" is a .ts file. Alias is configured in the webpack.config and in the tsconfig files.
Can you please assist me with this issue? Thanks in advance.
Please sign in to leave a comment.
path mappings in tsconfig.json are correctly resolved for me
Are you importing a .ts or .vue file? In the latter case, did you try adding '.vue' extension to the import? Also, what IDE build do you use?
I'm importing from the .ts file. Imports from .vue and libraries are resolved without any errors.
Works fine for me.
what IDE build do you use? Could you share a sample project the issue can be repeated with?
Here is a link to a sample app with the same configuration: https://github.com/tokarskadiana/test-vue .
Not recognized import is the file under src/views/TestComponent.vue
import { TestType } from "@/appTypes";I'm using WebStorm 2020.2.2, Build #WS-202.7319.49, built on September 14, 2020
Works fine for me in 2020.2.2 when using your project:
No errors are reported, Ctrl+click jumps to TestType declaration in src/appTypes.ts
Do you have Typescript language service enabled in Settings | Languages & Frameworks | TypeScript, BTW? Though it works fine without the language service, it usually provides better coding assistance when editing Typescript
Thanks for the tip to look into the settings. The language service was on, but restoring default WebStorm settings resolved the issue.
Having the same issue.
- Node version 16.14.2.
- Nuxt 2.15.8.
- WebStorm 2022.3.1 (issue only happens after migrating to this version)
Here's my tsconfig
{"compilerOptions": {
"target": "ES2018",
"module": "ESNext",
"moduleResolution": "Node",
"lib": ["ESNext", "ESNext.AsyncIterable", "DOM"],
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noEmit": true,
"experimentalDecorators": true,
"noImplicitThis": false,
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
},
"types": ["@nuxt/types", "@types/node", "@nuxtjs/vuetify", "@nuxtjs/i18n", "jest"]
},
"include": ["**/*.ts", "decs.d.ts", "vue-shim.d.ts"],
"exclude": ["node_modules", ".nuxt", "dist", ".output", ".github"]
}
Adding `**/*.vue` to the include array fixes that issue, but introduces a whole host of different issues, which leads me to believe that this is not the solution.
Restoring default WebStorm settings didn't help for me.