fix flow-comment - object destructuring (#9893)
This commit is contained in:
parent
80a5a2e7dd
commit
71013088ef
@ -127,6 +127,17 @@ export default declare(api => {
|
|||||||
}
|
}
|
||||||
wrapInFlowComment(path, parent);
|
wrapInFlowComment(path, parent);
|
||||||
},
|
},
|
||||||
|
ObjectPattern(path) {
|
||||||
|
const { node } = path;
|
||||||
|
if (node.typeAnnotation) {
|
||||||
|
const typeAnnotation = path.get("typeAnnotation");
|
||||||
|
path.addComment(
|
||||||
|
"trailing",
|
||||||
|
generateComment(typeAnnotation, typeAnnotation.node),
|
||||||
|
);
|
||||||
|
typeAnnotation.remove();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
Flow(path) {
|
Flow(path) {
|
||||||
const { parent } = path;
|
const { parent } = path;
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
function add({ a, b }: {a: number, b: number}): number {
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
function add({
|
||||||
|
a,
|
||||||
|
b
|
||||||
|
}
|
||||||
|
/*: {a: number, b: number}*/
|
||||||
|
)
|
||||||
|
/*: number*/
|
||||||
|
{
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
const { a, b }: { a: number, b: number } = { a: 1, b: 2 };
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
const {
|
||||||
|
a,
|
||||||
|
b
|
||||||
|
}
|
||||||
|
/*: { a: number, b: number }*/
|
||||||
|
= {
|
||||||
|
a: 1,
|
||||||
|
b: 2
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user