Import typescript file with alias in path into vue component.
See original GitHub issueInfo
- Platform: macOS
- Vetur version: 0.22.4
- VS Code version: 1.32.1 (1.32.1)
Problem
Error in .vue file during import .ts file with alias in path. File is imported correctly but editor mark line with import.
Relative path without an error
Path with alias with an error.
Please note that other files are imported without any error.
tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"noImplicitAny": true,
"noImplicitThis": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": ["webpack-env", "types/globalTypes.ts"],
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": ["node_modules"]
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How can one use a path alias in *.vue component imports ...
When I work with Vue single file components in Vite I can use a baseUrl and path alias in tsconfig.json to import *.ts...
Read more >Import TS file in Vue component via alias (Cannot find ...
When I import vue file - all works fine. But when I'm trying import ts file with path alias then IDE shows error...
Read more >Vue.js+Typescript: tsconfig.json path aliases not resolved ...
Vue.js+Typescript: tsconfig.json path aliases not resolved in .vue files ... recognize folder containing JS .vue file when importing from TS .vue file.
Read more >Documentation - Module Resolution
A relative import is resolved relative to the importing file and cannot resolve to an ambient module declaration. You should use relative imports...
Read more >Aliases | Laravel Mix Documentation
Path aliases are useful when you want to include files from a particular directory but do so from many others without repeatedly writing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello everyone, Vetur is support this feature now. Please keep
tsconfig.json
in project root. Remember setcompilerOption.paths
. and than restart vue language server or restart VSCode.For anyone still struggling with this, In my case, what worked was by inserting the
.vue
format at the of the import, then the error was gone