microsoft / microsoft/TypeScript

Emit errors for rogue jsdoc tags

Abierto
#53,104 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.4k
Merge medio
1 d 19 h
PR fusionados (30 d)
117

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.
jsdoc rogue type tag

✅ 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

Emit an error for jsdoc tags that have an unusual or unexpected position.

📃 Motivating Example

Say you want to cast a value but you forget the brackets around the value you want to cast:

const x = /** @type {you can pretty much type anything here} */ 3;

At the moment no error is emitted at all, but it seems like this shouldn't be legal.

💻 Use Cases

/**
 * @param {any} data
 */
function sanitizeData(data) {
    // ... sanitize
    return /** @type {SanitizedType} */ data;
}

It's easy to miss that this function has any as return type, rather than the SanitizedType you'd expect.


Note that even though this would be a breaking change, this change would likely only highlight code that was already broken and not type safe, rather than introduce new issues.

Related #47222

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

Revisa primero los ejemplos de JSDoc sugeridos y el issue relacionado #47222; después, sigue el rastro de cómo se aceptan actualmente las etiquetas JSDoc en JavaScript. El cambio estará completo cuando las posiciones inusuales o inesperadas de las etiquetas produzcan diagnósticos sin cambiar la salida en tiempo de ejecución, y haya cobertura para los ejemplos de cast y function.

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

Evaluación

Stack tecnológico
javascript, typescript
Área
compilers
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.