Add support for printing optional catch binding (#2570)

master
Brian Ng 2017-07-31 15:40:14 -05:00 committed by Christopher Chedeau
parent 2560a51f7d
commit 4c335cae0a
5 changed files with 33 additions and 4 deletions

View File

@ -23,7 +23,8 @@ function parse(text, parsers, opts) {
"functionSent",
"dynamicImport",
"numericSeparator",
"importMeta"
"importMeta",
"optionalCatchBinding"
]
};

View File

@ -1552,9 +1552,8 @@ function genericPrintNoParens(path, options, print, args) {
]);
case "CatchClause":
return concat([
"catch (",
path.call(print, "param"),
") ",
"catch ",
n.param ? concat(["(", path.call(print, "param"), ") "]) : "",
path.call(print, "body")
]);
case "ThrowStatement":

View File

@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`optional_catch_binding.js 1`] = `
try {
}
catch {
}
finally {
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
try {
} catch {
} finally {
}
`;

View File

@ -0,0 +1 @@
run_spec(__dirname, { parser: "babylon" });

View File

@ -0,0 +1,9 @@
try {
}
catch {
}
finally {
}