You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some errors can be enabled or disabled via setting certain flags to true or false in the tsconfig.json file. It would be nice if these errors could have their severity set as well.
π Motivating Example
During development and testing it is common to comment out a block of code and then compile and run it again.
In certain circumstances this causes novel errors to appear, for example if you comment out all uses of a variable or function argument, you must additionally remove the declaration of the variable or prefix the argument with an underscore to avoid errors such as TS6133. As such notices can be disabled and leave functioning code, via knobs like noUnusedLocals and noUnusedParameters, they are not truly errors.
There should be a compiler-wide option to emit such "errors" as warnings, so testing can proceed without further code modifications, as such modifications are prone to being accidentally left behind, as are such compiler configuration flags.
π» Use Cases
What do you want to use this for?
Testing and debugging of code.
What shortcomings exist with current approaches?
You can only turn these errors on, preventing compilation entirely, or off, which causes them to be ignored completely. This forces you to decide between making further code modifications to do testing, which may introduce errors, or to disable the compiler options, which may cause the unwanted code smell to be left. A warning would allow the code to run but continually draw the developers eye until it is addressed, which is the historic purpose of having warnings as a step between clean compiler output and show-stopping error output.
What workarounds are you using in the meantime?
There are no workarounds. I am disabling compiler options such as noUnusedLocals and noUnusedParameters in some cases, prefixing arguments with underscores in others, and then undoing those changes after the debugging is complete -- only to have to do it all again the next time.
The text was updated successfully, but these errors were encountered:
You can only turn these errors on, preventing compilation entirely, or off, which causes them to be ignored completely. This forces you to decide between making further code modifications to do testing, which may introduce errors, or to disable the compiler options, which may cause the unwanted code smell to be left.
Imo that's what noEmitOnError set to false is there for. The checks still happen, but your code is compiled as well.
Imo that's what noEmitOnError set to false is there for. The checks still happen, but your code is compiled as well.
I wasn't even aware of this option, thanks for the pointer. It turns out that it defaults to false anyway, so the code is being compiled even with the errors being printed. The exit code of tsc being non-zero lead me to believe it was aborting compilation.
I'd still rather these kinds of non-fatal issues were emitted as warnings and not errors for the reason outlined, but I can work with this.
π Search Terms
compiler custom error severity
β Viability Checklist
β Suggestion
Some errors can be enabled or disabled via setting certain flags to true or false in the
tsconfig.json
file. It would be nice if these errors could have their severity set as well.π Motivating Example
During development and testing it is common to comment out a block of code and then compile and run it again.
In certain circumstances this causes novel errors to appear, for example if you comment out all uses of a variable or function argument, you must additionally remove the declaration of the variable or prefix the argument with an underscore to avoid errors such as TS6133. As such notices can be disabled and leave functioning code, via knobs like
noUnusedLocals
andnoUnusedParameters
, they are not truly errors.There should be a compiler-wide option to emit such "errors" as warnings, so testing can proceed without further code modifications, as such modifications are prone to being accidentally left behind, as are such compiler configuration flags.
π» Use Cases
What do you want to use this for?
Testing and debugging of code.
What shortcomings exist with current approaches?
You can only turn these errors on, preventing compilation entirely, or off, which causes them to be ignored completely. This forces you to decide between making further code modifications to do testing, which may introduce errors, or to disable the compiler options, which may cause the unwanted code smell to be left. A warning would allow the code to run but continually draw the developers eye until it is addressed, which is the historic purpose of having warnings as a step between clean compiler output and show-stopping error output.
What workarounds are you using in the meantime?
There are no workarounds. I am disabling compiler options such as
noUnusedLocals
andnoUnusedParameters
in some cases, prefixing arguments with underscores in others, and then undoing those changes after the debugging is complete -- only to have to do it all again the next time.The text was updated successfully, but these errors were encountered: