microsoft / microsoft/TypeScript
Suggest argument names based on type definition of callback functions
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Search Terms
callback, arguments, parameters, suggestion, auto correct
Suggestion
Let's say I have a type definition for my function like this:
function acceptsCallback(callback: (argumentNameThatIsVeryLong: string) => void) {}
When using it, that argumentNameThatIsVeryLong is a very good candidate for my argument name. I want to accept it but there is no way but typing it:
Use Cases
When users are extremely lazy this is very handy! ;) In all seriousness this can avoid bugs by suggesting the right argument name. For instance when req and res objects are misplaced in an Express middleware by mistake
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
- 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
Non sono indicati file di implementazione né test. Inizia dall’esempio collegato di TypeScript Playground e verifica come si comportano attualmente nell’editor i suggerimenti per i parametri di callback. Il lavoro è completato quando i nomi degli argomenti di una definizione di tipo callback vengono offerti come suggerimenti senza modificare il JavaScript emesso.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, 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
- 35/100