The proposal by @michaelficarra makes the binding identifier in catch clauses optional.
For example:
try {
JSON.parse("...");
}
catch {
// Don't care, the error message is completely useless,
// but we need to handle it.
}
This proposal reached stage 3 immediately upon presentation.
🚲 🏠 what should we name the variable when downleveling?
I was thinking unexpectedTokenInJsonAtPositionError.
I'd vote 🤷♀️, with further downleveling as appropriate.
The page is moved to https://tc39.github.io/proposal-optional-catch-binding/, for someone who wants to track the change of TS 2.5.
Just a thought but how about having the catch block itself as optional?
For example we have the 'traditional' try catch:
try {
// Something risky
} catch (e) {
// Handle the specifics of e
}
// Continue
The 'I don't care what went wrong' try catch:
try {
// Something risky
} catch {
// ¯\_(ツ)_/¯, Something happen lets do this instead
}
// Continue
So how about a 'I don't care' try (catch):
try {
// Something risky
}
// Continue
That would be a good suggestion for ESDiscuss and I am sure that TypeScript would follow suit if the proposal made it. Diverging outside of that just in TypeScript wouldn't likely make sense.
@ZanderBrown try doesn't imply catch. Consider try...finally.
Most helpful comment
I'd vote 🤷♀️, with further downleveling as appropriate.