microsoft / microsoft/TypeScript

Quick Fix: Infer parameter types from usage … for one function

Aperta
#31,506 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

Search Terms

  • 7043
  • 7044
  • better type may be inferred from usage

Suggestion

There's a quickfix to infer types from usage for variables that are implicitly any:

image

The two options are both useful, but for a large file the "Infer all types from usage" option feels a bit extreme. But inferring symbol-by-symbol can get tedious.

I'm proposing a middle ground option, something like "Infer all types in this block."

Use Cases

Adding type annotations to variables in large files based on usage piecemeal.

Examples

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

Nell’issue non sono indicati file, test o punti di ingresso. Inizia esaminando i quickfixes esistenti per inferire i tipi dall’utilizzo e determina come una variante con ambito di blocco dovrebbe selezionare i simboli; il lavoro è completato quando la nuova opzione inferisce i tipi per il blocco previsto senza modificare il JavaScript emesso.

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

Valutazione

Stack tecnologico
javascript, typescript
Ambito
compilers
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.