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

Import typescript file with alias in path into vue component. #1463

Closed
mstys opened this issue Oct 17, 2019 · 6 comments
Closed

Import typescript file with alias in path into vue component. #1463

mstys opened this issue Oct 17, 2019 · 6 comments
Labels

Comments

@mstys
Copy link

mstys commented Oct 17, 2019

  • [ x ] I have searched through existing issues
  • [ x ] I have read through docs
  • [ x ] I have read FAQ

Info

  • 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

Zrzut ekranu 2019-10-17 o 11 03 24

Path with alias with an error.

Zrzut ekranu 2019-10-17 o 11 03 45

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"]
}
@mstys
Copy link
Author

mstys commented Oct 18, 2019

Update: no idea what was the reason of above issue but reinstalling vscode and setup project again helped. I can't reproduce an issue again.

@mstys mstys closed this as completed Oct 18, 2019
@octref octref added the invalid label Dec 11, 2019
@samelie
Copy link

samelie commented Aug 6, 2020

Dang! this one is annoying. The code compiles (custom webpack with the resolve :

resolve: {
    modules: [constants.NODE_MODULES_DIR, constants.WORKSPACE_NODE_MODULES_DIR],
    extensions: ['.ts', '.js', '.vue', '.json'],
    alias: {
      '@': constants.SRC_DIR,     
      ),
    },
  },

of course this has nothing to do with VS Code's path resolver. Will post if I find fix

@nizulzaim
Copy link

same issue. i know this already closed but get same problem

@yoyo930021
Copy link
Member

Hello everyone,
Vetur is support this feature now.
Please keep tsconfig.json in project root.
Remember set compilerOption.paths.
and than restart vue language server or restart VSCode.

@luan-orlandi-ifood
Copy link

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

@ishaan-puniani
Copy link

Hello, I am getting the same issue,
Working fine on my teammate machine but not working on my machine and not working on github actions.

not sure what I am missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants