Skip to content

Enable auto imports and add missing import for module/package names #52527

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

Open
mjbvz opened this issue Jan 31, 2023 · 2 comments
Open

Enable auto imports and add missing import for module/package names #52527

mjbvz opened this issue Jan 31, 2023 · 2 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Auto-import Suggestion An idea for TypeScript

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jan 31, 2023

Suggestion

πŸ” Search Terms

  • auto import
  • quick fix
  • missing import

⭐ Suggestion

Auto imports / add missing imports should be able to add import * as XYZ from 'XYZ' when triggered on the symbol name XYZ in a file. This is useful if you prefer using namespace imports and can also help with discovering/exploring new packages

Right now we have auto imports and an add missing import quick fix for symbols in a module, but I don't see these options for the module itself

πŸ“ƒ Motivating Example

  1. In a new project
  2. npm I @types/vscode
  3. Open new TS file and write vscode.

Right now I don't get an auto import for vscode. I'd expect an import that adds: import * as vscode from 'vscode'; at the top of the file

πŸ’» Use Cases

  • Make it easier to reference a symbol if you prefer using namespaces from the start
  • Helping users explore new packages (just type vscode. to see suggestions in the vscode package)
  • Working with node packages. It'd be nice to be able to type fs. to get an fs import
  • Fixing code that has been copy and pasted between files
@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Auto-import labels Feb 1, 2023
@DanielRosenwasser
Copy link
Member

This was discussed at #23830, right?

@mjbvz
Copy link
Contributor Author

mjbvz commented Feb 8, 2023

@DanielRosenwasser Looks like it. Andrew's answer makes sense but it does feel like we could do better here. Maybe only apply this for node packages to start?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Domain: Auto-import Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants