fix flow-comments - class type paramters and implements (#9897)
This commit is contained in:
parent
71013088ef
commit
ca3c53ae0b
@ -146,15 +146,32 @@ export default declare(api => {
|
|||||||
|
|
||||||
Class(path) {
|
Class(path) {
|
||||||
const { node } = path;
|
const { node } = path;
|
||||||
|
if (node.typeParameters || node.implements) {
|
||||||
|
const comments = [];
|
||||||
if (node.typeParameters) {
|
if (node.typeParameters) {
|
||||||
const typeParameters = path.get("typeParameters");
|
const typeParameters = path.get("typeParameters");
|
||||||
const block = path.get("body");
|
comments.push(
|
||||||
block.addComment(
|
generateComment(typeParameters, typeParameters.node).replace(
|
||||||
"leading",
|
/^:: /,
|
||||||
generateComment(typeParameters, typeParameters.node),
|
"",
|
||||||
|
),
|
||||||
);
|
);
|
||||||
typeParameters.remove();
|
typeParameters.remove();
|
||||||
}
|
}
|
||||||
|
if (node.implements) {
|
||||||
|
const impls = path.get("implements");
|
||||||
|
comments.push(
|
||||||
|
"implements " +
|
||||||
|
impls
|
||||||
|
.map(impl => generateComment(impl).replace(/^:: /, ""))
|
||||||
|
.join(", "),
|
||||||
|
);
|
||||||
|
delete node["implements"];
|
||||||
|
}
|
||||||
|
|
||||||
|
const block = path.get("body");
|
||||||
|
block.addComment("leading", ":: " + comments.join(" "));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
class Foo implements Bar, Baz {}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
class Foo
|
||||||
|
/*:: implements Bar, Baz*/
|
||||||
|
{}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
class Foo<S, T> implements Bar, Baz {}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
class Foo
|
||||||
|
/*:: <S, T> implements Bar, Baz*/
|
||||||
|
{}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
class Foo<T> {}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
class Foo
|
||||||
|
/*:: <T>*/
|
||||||
|
{}
|
||||||
Loading…
x
Reference in New Issue
Block a user