You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using advanced types such as conditional types, I usually write a bunch of type tests to check for which conditions the annotations are supposed to pass/fail. Example:
As you see, every first statement checks for a condition that's supposed to pass, while every second statement checks for a condition that's correctly supposed to fail.
I'd ideally annotate those second statements with // @ts-ignore, except that if the expected type error doesn't happen, I wouldn't know about it. For example if the variable derivative is of type any, then the type annotations would obviously be wrong, but no errors would be shown.
I propose a compiler flag like warnUnusedSuppressions: boolean that would produce a lint error if a line is annotated with // @ts-ignore but doesn't contain type errors.
This is not the intended use of // @ts-ignore. we advice that this feature be used sparingly, and I do not think we want to invest in expanding its support.
When using advanced types such as conditional types, I usually write a bunch of type tests to check for which conditions the annotations are supposed to pass/fail. Example:
As you see, every first statement checks for a condition that's supposed to pass, while every second statement checks for a condition that's correctly supposed to fail.
I'd ideally annotate those second statements with
// @ts-ignore
, except that if the expected type error doesn't happen, I wouldn't know about it. For example if the variablederivative
is of typeany
, then the type annotations would obviously be wrong, but no errors would be shown.I propose a compiler flag like
warnUnusedSuppressions: boolean
that would produce a lint error if a line is annotated with// @ts-ignore
but doesn't contain type errors.Related issues: #19139, #21602
The text was updated successfully, but these errors were encountered: