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

[Feature request] Imports on the fly #224

Open
svipas opened this issue Dec 21, 2024 · 2 comments
Open

[Feature request] Imports on the fly #224

svipas opened this issue Dec 21, 2024 · 2 comments

Comments

@svipas
Copy link

svipas commented Dec 21, 2024

Is that would be possible to have something like in WebStorm?

Unambiguous imports on the fly With this checkbox selected, WebStorm adds import statements when you type your code or paste a fragment with a symbol that is not yet imported if there is only one source to import the symbol from.

Meaning that for e.g. if I type Text while my suggest widget is turned off it automatically imports it from the react-native package, because Text exists there. Or lets say I'm in Node.js project and I type path. and it automatically adds: import path from "path".

I thought about creating an extension which reads diagnostics and uses built-in VS Code source.addMissingImports, but I do believe you guys are way more experienced to know more gotchas and if it really possible to have this feature which works reliably.

/cc @zardoy @Ilanaya

@zardoy
Copy link
Owner

zardoy commented Dec 23, 2024

I thought about creating an extension which reads diagnostics and uses built-in VS Code source.addMissingImports, but I do believe you guys are way more experienced to know more gotchas and if it really possible to have this feature which works reliably.

@svipas Yes I have an extension exactly does this thing. It's called better snippets (https://github.com/zardoy/vscode-better-snippets,which has exactly this thing implemented with the feature called auto-imports, you can read the docs and try it with typing snippets, I use them on everyday basis. However TS doesn't provide auto import quick fixes in some cases such as path or fs. Will try to not to forget to attach some configuration examples once I'm home

@svipas
Copy link
Author

svipas commented Dec 23, 2024

@zardoy sounds awesome, but does it support that it auto-imports anything what I type, because I have bunch of packages and a lot of local exports does that mean I need to add into configuration each one of them? Because I want it to work with more than path or fs.

Please if it is possible, share me a configuration example if it is possible.

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

No branches or pull requests

2 participants