microsoft / microsoft/TypeScript
Improve error message for @ts-expect-error directive
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
I've just been looking for a way to "unit test" some quite complicated generic type signatures, and have just come across the @ts-expect-error and @ts-expect-no-error directives, which I think are fantastic for this kind of use case.
However, if I do something like this:
let myVar = 'bob';
// @ts-expect-error
myVar = 'fred';
The actual error I get is "Unused '@ts-expect-error' directive".
This makes it look as though the directive has been used incorrectly (which obviously it has in this very simple example), but this seems like it will be confusing for anyone subsequently involved in maintaining my code - because it looks as though all they need to do is remove the directive in order to fix the problem, whereas generally speaking, I will have put the directive there for a good reason, and if it's "unused" it means that somebody has broken the type signature logic.
Please could this error message be changed to shift the emphasis more onto the code being wrong, rather than the directive needing to be removed?
E.g.: "'@ts-expect-error' directive - this code should have failed type-checking, but didn't"
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 diagnóstico que informa de "Unused '@ts-expect-error' directive" e inspecciona las pruebas del compilador relacionadas, si las hay. Actualiza el texto para enfatizar que el código anotado superó inesperadamente la comprobación de tipos y, a continuación, verifica que el ejemplo produzca el diagnóstico revisado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- compilers
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 42/100