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
A lot of code seems to depend on the fact that any thrown error is at least some form of Error, so this'd help remove the possibility for undefined bugs.
We'll probably also want to add the option "allowThrowingAny": false
The text was updated successfully, but these errors were encountered:
As described in #2116 (comment) (at the bottom, header useUnknownInCatchVariables), handling thrown values in catch requires to treat it as anything unknown, this is because anything can be thrown, and this lint helps present this.
I think, in a large library such as this, throwing a literal value is an antipattern, as the library works and deals with Errors anywhere, having a lint which prevents developers throwing any literal value would help conform error-throwing to Errors (mostly) only, and no singleton nonsensical or context-less values such as strings, numbers, undefineds, and nulls.
This lint also has options to disallow throwing any or unknown, as these could be non-object values.
Reasons explaining why any should be prohibited anywhere is outlined in #2115, while unknown should very likely still be allowed, as with useUnknownInCatchVariables, re-throwing is also common, and with that linter, es in catch(e)s would be unknown.
https://typescript-eslint.io/rules/no-throw-literal
A lot of code seems to depend on the fact that any thrown error is at least some form of
Error
, so this'd help remove the possibility forundefined
bugs.We'll probably also want to add the option
"allowThrowingAny": false
The text was updated successfully, but these errors were encountered: