Skip to content

Feature suggestion: Report unused suppressions #22021

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

Activity

  1. mhegazy commented on Mar 10, 2018

    @mhegazy
    Contributor

    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.

    If this is a .d.ts file that you are testing, consider using https://github.com/Microsoft/dtslint, with $ExpectType assertions.

  2. AriaMinaei commented on Mar 10, 2018

    @AriaMinaei
    Author

    I see. Thanks for pointing to the correct solution!

  3. locked and limited conversation to collaborators on Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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