microsoft / microsoft/TypeScript
Diagnostic code 8030 being incorrectly generated using JSDoc `@type` on a function.
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 132
Descripción
🔎 Search Terms
Diagnostic 8030 is being generated incorrectly when using JSDoc @type on a method when the type is being referred to from an interface. This is using the new tsc LSP - version 7.0.2.
🕗 Version & Regression Information
- This changed between versions 7.0.0-dev.260707.2 and 7.0.2.
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about new native issues being transferred into the main typescript repo.
⏯ Playground Link
No response
💻 Code
// types.ts
interface Example {
method (): number;
}
export {};
// code.js
const exampleFns = {
/**
* @type {Example['method']} // A JSDoc `@type` tag on a function must have a signature with the correct number of arguments.
*/
method () {
return Math.random();
}
};
🙁 Actual behavior
in this example, the diagnostic and LSP info does not tell the user that typescript is internally suffixing | undefined to the type. As such wrapping the type in NonNullable<T> removes the error diagnostic, I do not believe this to be intended behaviour as previous iterations the golang native LSP tsgo (7.0.0-dev.260707.2) did not produce this diagnostic, nor did previous versions of typescript.
🙂 Expected behavior
The type should be properly referenced with no additional suffixing of types, as it used to.
Additional information about the issue
No response
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 reproduciendo el diagnóstico con types.ts y code.js usando la versión de TypeScript 7.0.2 indicada y la versión anterior 7.0.0-dev.260707.2. Rastrea cómo se resuelve la referencia JSDoc @type a Example['method'] y por qué se añade | undefined. Se considera terminado cuando el tipo de método válido ya no produce el diagnóstico 8030 y existe cobertura de regresión para este ejemplo.
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
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100