-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Inconsistent and broken Auto import in VSCode #23014
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
Comments
Could you try and reproduce this in a simple project with only a few files? |
I have actually just started this project, there is only a handful of components. I removed all credentials and all references to firebase, here's the repo. https://github.com/ackvf/vscode-auto-import |
In
It seems valid?
As with error2, this is working for me half the time. The other half, vscode doesn't seem to be requesting completion details. |
@Andy-MS I am sorry, I fixed all imports by hand before pushing to github. The Well in fact, it was there at first, but then I got some complicated import issues and while investigating, I discovered that the issue can be reproduced much easier in the |
So you can't reproduce any issue any more? I've filed an issue at microsoft/vscode#47988 about the other problems I noticed. |
What's the bug in that image? |
The bug is that |
Import fix is designed to give you a choice of all possible ways of importing something. Completions just chooses what it thinks is the best one. |
Right, but I am actually missing the mentioned import in completions in this case and in all cases mentioned at the top, so I guess it is a bug, isn't it? |
That screenshot shows that the completions are giving you one way of getting the identifier. We intentionally avoid adding many different completions for the same identifier. |
@ackvf I cloned the repository and I don't see your own implementation? I added one and now it does show up in completions: |
I will test it tomorrow. Thank you for your reply. |
I see! Actually I continued working on the project so the This is the exhibited behavior as per #23014 (comment) |
@ackvf Thanks, there was a bug due our handling of default exports in tsx. |
Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
Hereby I confirm I did search and read dozen of auto import issues, but they were not related or outdated.
TypeScript Version: 2.7.2
Search Terms: auto import relative absolute tsconfig baseUrl paths
Code

This is my project structure and code. Look for
Account
.Expected behavior:
paths
turned OFF (code commented)Expected is that I am offered with correct relative paths
index.ts
fileAuto import from './Account/Account' ; class Account
- import is already correctAuto import from './routes' ; CONST ACCOUNT
- correctSignIn.tsx
fileAuto import from '../Account/Account' ; class Account
- this import is missingAuto import from '../routes' ; CONST ACCOUNT
- correctpaths
turned ON (code uncommented)Expected is that I am offered with correct relative AND absolute paths
index.ts
fileAuto import from './Account/Account' ; class Account
- missingAuto import from '~/pages/Account/Account' ; class Account
- correctAuto import from './routes' ; CONST ACCOUNT
- missingAuto import from '~pages/routes' ; CONST ACCOUNT
- correctSignIn.tsx
fileAuto import from '../Account/Account' ; class Account
- missingAuto import from '~/pages/Account/Account' ; class Account
- missingAuto import from '../routes' ; CONST ACCOUNT
- missingAuto import from '~pages/routes' ; CONST ACCOUNT
- correctActual behavior:
note that there are also some completely wrong import suggestions
paths
OFF'.'
is invalid - there is no localy available exportpaths
ON'~/pages'
is invalid - there is no available exportnote: Auto import in a root file


App.tsx
finds the class exports.note2: There is still the wrong import from
src/pages
folder.paths
OFFpaths
ONSo far I have counted 6 missing import suggestions and 4 wrong import suggestions. I am verry confused by the actual behaviour. It looks like I can import from any parent folder of importing module, but not from a sibling folder.
Restarting computer didn't help.
Am I missing something? What's wrong with my configuration?
Related Issues:
Autoimport always imports relative to baseUrl #19920
The text was updated successfully, but these errors were encountered: