microsoft / microsoft/TypeScript
Allow to Override Import Paths For Auto-Import
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
IDisposable, Emitter and Event are very common types in the VS Code codebase.
Unfortunately, you have to be very careful when importing them through autocomplete.
Even worse, sometimes all the places to import from are suggested except the correct one.
In 99% of cases, we are importing IDisposable from vs/base/common/lifecycle. As you can see here, TypeScripts suggests all places except the right one:

It would be very practical if one could override where to import unresolved symbols from.
E.g.
"typescript.importFromOverrides": {
"src/vs/editor/**": {
"IDisposable": "vs/base/common/lifecycle",
"Event": "vs/base/common/events"
}
}
Alternatively, TypeScript could figure out where the Symbol has been imported from in adjacent files.
Maybe a disallow-list would also make sense (never import IDisposable from node-pty, or never import anything from vs/workbench/workbench.web.api).
This is now the second codebase where I ran into the permanent problem of importing a common symbol from a wrong module, which makes me believe this is a common problem.
I run into this problem one to ten times per day.
Here is another example:

We never want to import from vscode.
Being able to customize the preferred import would be a huge deal (especially for the quickfix "add all missing imports").
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported auto-import and quick-fix behavior in the VS Code codebase using symbols such as IDisposable, Emitter, and Event. Compare the suggested modules with the preferred import paths in the examples; done should mean the requested import preference or exclusion behavior is supported and works for adding missing imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100