Apply destructuring rules in functions to catch param (#4385)
parent
d77f5e9c3a
commit
32900842e3
|
@ -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 &&
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
`;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue