google / closure-compiler

A JavaScript checker and optimizer.
https://developers.google.com/closure/compiler/
Apache License 2.0
7.41k stars 1.15k forks source link

It is needlessly complicated to suppress errors #4037

Open fingerartur opened 1 year ago

fingerartur commented 1 year ago

Here is a list of suppression tags and the corresponding errors that each tag covers. If I have an error/warning in my code and I want to suppress it, first I have to go to the wiki, find the corresponding suppression tag for my error and only then I can suppress it.

Ideally the compiler could output not only the error but also the suppression tag (in case I want to suppress).

Another great feature would be to follow the footsteps of Typescript and add a mechanism to ignore any type checks on a line of code (see @ts-ignore) or for a whole file (@ts-nocheck).

rishipal commented 1 year ago

This will be discussed in the upcoming internal triage meeting. A couple of thoughts:

  1. On the plus side, we wouldn't have to update the open source documentation after code changes. For e.g. the current document is already out of date and incorrect after the recent change (cr/491741410) (Allow @Suppress on arbitrary expression statements)

  2. Ideally the compiler could output not only the error but also the suppression tag (in case I want to suppress).

I'm afraid one downside is that this could encourage / hasten the suppression of genuine code errors revealed by the compiler.

  1. Another great feature would be to follow the footsteps of Typescript and add a mechanism to ignore any type checks on a line of code (see @ts-ignore) or for a whole file (@ts-nocheck).

Fyi, even internally, we disallow adding blanket // @ts-ignores internally without a valid motivating project / effort which needs bulk suppressions to land.

bamtang-dev commented 6 months ago

any plans to support this?

lauraharker commented 6 months ago

We agreed it's useful to have error messages print the diagnostic group to suppress them (if they're suppressible) and maybe to make it possible to add suppressions on any line, but this is currently in our backlog and not prioritized.

bamtang-dev commented 6 months ago

We agreed it's useful to have error messages print the diagnostic group to suppress them (if they're suppressible) and maybe to make it possible to add suppressions on any line, but this is currently in our backlog and not prioritized.

thanks for the heads up