This results in a mysterious failure like so (from deno i.e. swc):
error: TS18046 [ERROR]: 'err' is of type 'unknown'.
console.log(err.message)
The design of this option is very wrong, it's not worth the tiny saving of not having to type :unknown give how mysterious the above error is for a user who isn't aware of this option. It should have been designed to require this declaration rather than injecting it.
I realize this option can't be fixed at this point and it's probably not worth introducing a similar one with the better behavior. Perhaps as an alternative swc (and maybe other compilers) could be fixed to give an error that at least mentions useUnknownInCatchVariables.
🔎 Search Terms
useUnknownInCatchVariables
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
No response
🙁 Actual behavior
With
useUnknownInCatchVariables
:unknonw
is magically injected after err (incatch (err)
)This results in a mysterious failure like so (from deno i.e. swc):
The design of this option is very wrong, it's not worth the tiny saving of not having to type
:unknown
give how mysterious the above error is for a user who isn't aware of this option. It should have been designed to require this declaration rather than injecting it.I realize this option can't be fixed at this point and it's probably not worth introducing a similar one with the better behavior. Perhaps as an alternative swc (and maybe other compilers) could be fixed to give an error that at least mentions useUnknownInCatchVariables.
🙂 Expected behavior
Something less mysterious :)
Additional information about the issue
None