Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature suggestion: Report unused suppressions #22021

Closed
AriaMinaei opened this issue Feb 18, 2018 · 2 comments
Closed

Feature suggestion: Report unused suppressions #22021

AriaMinaei opened this issue Feb 18, 2018 · 2 comments
Labels
Declined The issue was declined as something which matches the TypeScript vision

Comments

@AriaMinaei
Copy link

AriaMinaei commented Feb 18, 2018

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

@mhegazy
Copy link
Contributor

mhegazy commented Mar 10, 2018

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.

@mhegazy mhegazy added the Declined The issue was declined as something which matches the TypeScript vision label Mar 10, 2018
@AriaMinaei
Copy link
Author

I see. Thanks for pointing to the correct solution!

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Declined The issue was declined as something which matches the TypeScript vision
Projects
None yet
Development

No branches or pull requests

2 participants