-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Auto import suggestions in TS 2.6 : wrong strategy for import paths #19694
Comments
Currently we dedupe by always pointing you to the original rather than a re-export. |
We should always get the top most file, and not the source. usually the source is buried deep inside the module guts. |
Can't we just use the same code from the import quick fix ? |
Some duplicates of this issue:
@andy-ms let's verify that the fix does indeed fix all these cases. |
Should be fixed by #20049 |
@mhegazy |
@nazarkryp When I use |
I still reproduce this on typescript
import AutosizingTextarea from './Autosizing';
import Textarea, { TextareaProps } from './Textarea';
export { Textarea as default, TextareaProps, AutosizingTextarea }; When I type |
@TedDriggs That's interesting, I was able to reproduce that, then noticed that I didn't have |
@andy-ms I had a repro but when I restarted and updated VS Code it started working properly. I've got Code configured to use our project's version of TS rather than VS Code's own and we were on 2.7.1 already, but maybe the editor's autocomplete didn't know about that? |
Well, the tsserver used for autocomplete is the same as the tsserver used for everything else. But glad to hear this is working now. Possibly there was some problem with the config not being picked up. |
I have a JS project with {
"compilerOptions": {
"target": "ES6",
"module": "es2015",
"baseUrl": "./src"
},
"exclude": ["node_modules", "scripts", "build"]
} Clone this MCVE project: https://github.com/kumarharsh/ts-autoimport-bug, go to the The autoimport item inserted is wrong - the actual import should be Also, although it doesn't happen in the MCVE project I posted above, in my real project this happens (all files in question are the same as in the MCVE):
|
@andy-ms is it possible that the fix for preferring shortest path would cause the quick-fix as you're typing to prefer |
TypeScript Version: 2.7.0-dev.20171102
VSCode Version: Insiders, same date
Code
In an Angular project, start typing any Angular code, like :
@Inp
and select the auto-import suggestion.
Expected behavior:
Should import top level export :
Actual behavior:
Imports deep level export :
It was handled fine when just one auto-import was suggested (see #19417).
Also, there was the same issue with the Import quick fix (#15223), but which was resolved a long time ago.
@mhegazy @mjbvz
The text was updated successfully, but these errors were encountered: