microsoft / microsoft/TypeScript
Move types from jsdoc quickfix (instead of copy)
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
Search Terms
jsdoc quickfix- 80004
Suggestion
There's a great quickfix available to copy JSDoc type annotations to TypeScript annotations:

When you do this, however, you still have type annotations in your JSDoc. This is duplicative and is likely to lead to the types getting out of sync over time. It's best to avoid putting type information in JSDoc once you're using TypeScript.
I'd like a quickfix that annotates types and removes the types from the JSDoc.
Use Cases
This would be helpful for any project converting from JavaScript to TypeScript. You should convert your JSDoc types to TypeScript types and you should remove types from your JSDoc once you do. This sort of quickfix would help people get to the right place.
Examples
/**
* @param a {string} Base string.
* @param b {string=} Optional string to add
* @return {string}
*/
function foo(a, b) {
if (b) return a + b;
return a;
}
should get converted to:
/**
* @param a Base string.
* @param b Optional string to add
*/
function foo(a: string, b?: string): string {
if (b) return a + b;
return a;
}
rather than:
/**
* @param a {string} Base string.
* @param b {string=} Optional string to add
* @return {string}
*/
function foo(a: string, b: string | undefined): string {
if (b) return a + b;
return a;
}
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza localizando el quickfix de JSDoc existente asociado con el término de búsqueda 80004 y sigue cómo convierte los tipos de JSDoc en anotaciones de TypeScript. Usa el ejemplo como objetivo de aceptación: mueve los tipos a la firma de la función y elimina la información de tipos del JSDoc, incluida la anotación de retorno.
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
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100