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.
Related issues: #19139, #21602
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 variablederivativeis of typeany, then the type annotations would obviously be wrong, but no errors would be shown.I propose a compiler flag like
warnUnusedSuppressions: booleanthat would produce a lint error if a line is annotated with// @ts-ignorebut doesn't contain type errors.Related issues: #19139, #21602