microsoft / microsoft/TypeScript

Configurable import suggestions to override global types

Aperta
#31,199 1 commento 4 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Domain: LS: Quick Fixes Needs Proposal Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

Search Terms

Suggestion

In our code base we have a module export called Option which we use very often.

However, if we try to reference Option in a module where it's not currently imported, we will not get import suggestions/fixes for this.

This is because there is already a (different) global type of the same name, provided by the dom lib types.

I would like to be able to configure TypeScript and/or VS Code so that I do have import suggestions for Option.

Suggestion: any time a module references a global value, and the project has a module export of the same name, provide an import suggestion for that.

Potential caveat of this suggestion: what happens when you select "add all missing imports"? Ideally I would want it to import my Option, but what if I intentionally wanted to use the global version instead?

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando il comportamento richiesto dei suggerimenti di importazione di TypeScript e/o VS Code per un’esportazione di modulo che condivide il nome con un tipo DOM globale. Definisci come i suggerimenti espliciti e «aggiungi tutte le importazioni mancanti» debbano scegliere tra l’esportazione del modulo e la versione globale. Il lavoro è completato quando il comportamento è configurabile e il caso d’uso intenzionale della versione globale rimane chiaro.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
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
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.