Strip flow-only class props without needing transform-class-properties. (#3655)

This commit is contained in:
Logan Smyth 2016-08-16 07:30:04 -07:00 committed by Henry Zhu
parent 043da1a26a
commit 2aaee8b8d4
4 changed files with 24 additions and 2 deletions

View File

@ -26,8 +26,17 @@ export default function ({ types: t }) {
if (!path.node.value) path.remove();
},
Class({ node }) {
node.implements = null;
Class(path) {
path.node.implements = null;
// We do this here instead of in a `ClassProperty` visitor because the class transform
// would transform the class before we reached the class property.
path.get("body.body").forEach((child) => {
if (child.isClassProperty()) {
child.node.typeAnnotation = null;
if (!child.node.value) child.remove();
}
});
},
Function({ node }) {

View File

@ -0,0 +1,3 @@
class Test {
prop: string;
}

View File

@ -0,0 +1,3 @@
let Test = function Test() {
babelHelpers.classCallCheck(this, Test);
};

View File

@ -0,0 +1,7 @@
{
"plugins": [
"transform-flow-strip-types",
"transform-es2015-classes",
"external-helpers"
]
}