babel-plugin-syntax-optional-catch-binding
This plugin allows Babel to parse optional catch bindings.
Example
Syntax
try {
throw 0;
} catch {
doSomethingWhichDoesntCareAboutTheValueThrown();
console.log("Yay, code executes!");
}
Installation
npm install --save-dev babel-plugin-syntax-optional-catch-binding
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["syntax-optional-catch-binding"]
}
Via CLI
babel --plugins syntax-optional-catch-binding script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["syntax-optional-catch-binding"]
});
References