Skip to content

Feature suggestion: Report unused suppressions #22021

Closed
@AriaMinaei

Description

@AriaMinaei

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:

image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript vision

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions