jashkenas / jashkenas/coffeescript
Discussion: optional catch binding
- Dominant language
- CoffeeScript
- Stars
- 16.6k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
I just stumbled upon this: https://github.com/tc39/proposal-optional-catch-binding
It's a stage 4 proposal which allows js code like
```js
try {
// ...
} catch {
// ...
}
```
### Input Code
```coffee
try obj = JSON.parse '{"a": "1"}'
console.log obj ? "failed to parse json"
```
### Current Behavior
```coffee
var obj;
try {
obj = JSON.parse('{"a": "1"}');
} catch (error) {}
console.log(obj != null ? obj : "failed to parse json");
```
### New Behavior
```coffee
var obj;
try {
obj = JSON.parse('{"a": "1"}');
} catch {}
console.log(obj != null ? obj : "failed to parse json");
```
Support already looks good too:
https://caniuse.com/#feat=mdn-javascript_statements_try_catch_optional_catch_binding
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch#Browser_compatibility
Just dropping this here so it can be looked at whether or not this should be output by CoffeeScript.
Contributor guide
Research direction
The issue names no files or tests. Start by reviewing the linked TC39 proposal and the input, current output, and desired output examples; then locate the compiler path that emits try/catch code. Done means deciding and documenting whether CoffeeScript should emit optional catch bindings, with generated output and compatibility expectations covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- coffeescript, javascript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100