Feat request: absolute path for auto import
See original GitHub issueInfo
- Platform: Window 10 1809
- Vetur version: 0.18.0
- VS Code version: 1.32.3
Problem
Currently the auto import is imported in relative path, is that any possible to add support auto import in absolute path or with alias? Example:
- absolute path:
import { getStoreUserData } from './store/getter.types.js'
- with alias
import { getStoreUserData } from '@/store/getter.types.js'
Besides, I find that another extension auto import was working in previous version, but It was broken after new version installed. Is that any possible to disable?
Thank you so much for contributing such a great work, I hope It will getting better!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:16
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Auto import in Visual Studio Code only offering absolute path ...
In Visual Studio Code, menu File → Preferences → Settings → User Settings, "typescript.preferences.importModuleSpecifier": "relative".
Read more >Configuring the Style of Imports in JavaScript and TypeScript
To control that for auto imports, open the Imports tab and check the option “Use paths relative to the project, resource or sources...
Read more >API — Flask Documentation (2.2.x)
from flask import Flask app = Flask(__name__) ... Relative to the application root_path or an absolute path. Defaults to 'static' .
Read more >Configuration Options | Navidrome
Option in config file Env var Description Def...
ND_CONFIGFILE Load configurations from an external config file "./n...
DataFolder ND_DATAFOLDER Folder to store application data (DB,...
Read more >Get Started with the Google Fonts API
Copy and paste the following HTML into a file: <html> ... Add a stylesheet link to request the desired web font(s):. <link rel="stylesheet"...
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
tsconfig.json
Extension Version
What’s Happening
With the above tsconfig.json here’s what I get.
Aliases work when the import path is typed manually. So I write
@/
and then hit <kbd>Ctrl</kbd> + <kbd>Space</kbd> and I get the autocompletion as expected.If somewher in the code, say a method, I try to access anything that’s exported in some other file and TS knows about it, it allows me to automatically import it. BUT, when it does that, it doesn’t use absolute path starting from say
@/
.In a TS file however, if I try to import anything that’s exported in a file that doesn’t exist in the same directory, VSCode does full path completion. Here’s a screenshot.
In a TS file itself however, if I import something that exists in file that resides in same directory, VSCode uses relative path like…
What do I expect?
I would love the autocompletion inside the .vue file for a TS/JS project to always use absolute path, with the root alias.
Why?
With relative paths, it becomes a pain to figure out at what level a thing is and then moving those file while refactoring becomes an even bigger pain because VSCode’s automatic file path updates don’t work for .vue files.
With an absolute path, it’s absolutely easy to move around things.
maybe you should try this vscode-extension https://marketplace.visualstudio.com/items?itemName=IWANABETHATGUY.path-alias