Add optionality to catch bindings (#5956)

This commit is contained in:
MarckK
2017-07-25 15:38:48 +01:00
committed by Brian Ng
parent 51a293601b
commit 9fc910d8c0
29 changed files with 360 additions and 9 deletions

View File

@@ -0,0 +1,17 @@
import syntaxOptionalCatchBinding from "babel-plugin-syntax-optional-catch-binding";
export default function() {
return {
inherits: syntaxOptionalCatchBinding,
visitor: {
CatchClause(path) {
if (!path.node.param) {
const uid = path.scope.generateUidIdentifier("unused");
const paramPath = path.get("param");
paramPath.replaceWith(uid);
}
},
},
};
}