microsoft / microsoft/TypeScript
Allow to Override Import Paths For Auto-Import
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
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").
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riprodurre il comportamento segnalato di auto-import e quick-fix nella codebase di VS Code usando simboli come IDisposable, Emitter ed Event. Confrontare i moduli suggeriti con i percorsi di import preferiti negli esempi; il lavoro sarà considerato completato quando il comportamento richiesto di preferenza o esclusione degli import sarà supportato e funzionerà per aggiungere gli import mancanti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript, vscode
- Ambito
- developer-experience, tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100