microsoft / microsoft/TypeScript

Add a "specify type" command to tsserver

Abierto
#43,291 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Awaiting More Feedback Suggestion
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

La solicitud apunta a tsserver y describe un comando que opera sobre una expresión o binding resaltado. Empieza rastreando los comandos existentes de tsserver para ediciones del código fuente e información de tipos; la tarea estará completada cuando se acepte un tipo introducido manualmente en una posición de tipo de JavaScript JSDoc o TypeScript, se exponga para las herramientas y se conserve la ubicación del cursor.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, typescript
Área
developer-experience, tooling
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.