Apply destructuring rules in functions to catch param (#4385)

master
Lucas Duailibe 2018-05-01 10:24:46 -03:00 committed by GitHub
parent d77f5e9c3a
commit 32900842e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 0 deletions

View File

@ -1048,6 +1048,7 @@ function printPathNoParens(path, options, print, args) {
parent.type !== "FunctionExpression" &&
parent.type !== "ArrowFunctionExpression" &&
parent.type !== "AssignmentPattern" &&
parent.type !== "CatchClause" &&
n.properties.some(
property =>
property.value &&

View File

@ -22,6 +22,18 @@ const UserComponent = function({
};
const { a, b, c, d: { e } } = someObject;
try {
// code
} catch ({ data: { message }}) {
// code
}
try {
// code
} catch ({ data: { message: { errors }}}) {
// code
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const [one, two = null, three = null] = arr;
a = ([s = 1]) => 1;
@ -56,4 +68,20 @@ const {
d: { e }
} = someObject;
try {
// code
} catch ({ data: { message } }) {
// code
}
try {
// code
} catch ({
data: {
message: { errors }
}
}) {
// code
}
`;

View File

@ -19,3 +19,15 @@ const UserComponent = function({
};
const { a, b, c, d: { e } } = someObject;
try {
// code
} catch ({ data: { message }}) {
// code
}
try {
// code
} catch ({ data: { message: { errors }}}) {
// code
}