microsoft / microsoft/TypeScript
Add a "specify type" command to tsserver
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.3k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 132
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
La demande concerne tsserver et décrit une commande qui agit sur une expression ou un binding mis en évidence. Commencez par retracer les commandes existantes de tsserver pour les modifications du code source et les informations de type ; la tâche sera considérée comme terminée lorsqu’un type saisi manuellement sera accepté dans une position de type JavaScript JSDoc ou TypeScript, exposé aux outils et que la position du curseur sera préservée.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, typescript
- Domaine
- developer-experience, tooling
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100