Skip to content

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

Open

Description

@mjbvz

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

Activity

  1. DanielRosenwasser commented on Feb 7, 2023

    @DanielRosenwasser
    Member

    This was discussed at #23830, right?

  2. mjbvz commented on Feb 8, 2023

    @mjbvz
    ContributorAuthor

    Daniel Rosenwasser (@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions