microsoft / microsoft/TypeScript
Add a "specify type" command to tsserver
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
Suggestion
🔍 Search Terms
List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.
✅ Viability 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, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
I would like to be able to highlight an expression/binding and have typescript let me input the type it should be instead of inferring the type and/or replacing the current type.
📃 Motivating Example
// a .js file, as I use JSDoc mostly
function double(a) {
return a * 2;
}
I would like to be able to highlight a and have a JSDoc in JS or type position in TS open up for me to input the type number manually. In particular figuring out nesting for "casting" in JS can be confusing if applied to non-bindings:
let a = JSON.parse(_);
💻 Use Cases
I mostly want to use this for tooling that can integrate against existing code without my cursor jumping around to manually specify types. Having this be done and placing my cursor back where it was would be mildly convenient. Having it as an API would also let me do this automatically with some tooling that works on existing code instead of just code generators.
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
La richiesta riguarda tsserver e descrive un comando che opera su un'espressione o un binding evidenziato. Inizia tracciando i comandi esistenti di tsserver per le modifiche al codice sorgente e le informazioni sui tipi; il lavoro sarà completato quando un tipo inserito manualmente verrà accettato in una posizione di tipo JavaScript JSDoc o TypeScript, esposto agli strumenti e la posizione del cursore verrà preservata.
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
- Da chiarire
- Idoneità per principianti
- 25/100