microsoft / microsoft/TypeScript
Add a "specify type" command to tsserver
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Die Anfrage richtet sich an tsserver und beschreibt einen Befehl, der auf einem hervorgehobenen Ausdruck oder binding arbeitet. Beginne damit, die bestehenden Befehle von tsserver für Quelltextänderungen und Typinformationen nachzuverfolgen; die Aufgabe gilt als erledigt, wenn ein manuell eingegebener Typ in einer JavaScript-JSDoc- oder TypeScript-Typposition akzeptiert, für Tooling verfügbar gemacht und die Cursorposition beibehalten wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- developer-experience, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100