fix regression in transform-flow-comments for class properties (#4623)

This commit is contained in:
Dan Harper 2016-10-01 05:56:09 +01:00 committed by Henry Zhu
parent 46339463bd
commit 0e02a18216
8 changed files with 38 additions and 1 deletions

View File

@ -37,6 +37,12 @@ export default function ({ types: t }) {
} }
}, },
// support for `class X { foo: string }` - #4622
ClassProperty(path) {
let { node, parent } = path;
if (!node.value) wrapInFlowComment(path, parent);
},
// support `export type a = {}` - #8 Error: You passed path.replaceWith() a falsy node // support `export type a = {}` - #8 Error: You passed path.replaceWith() a falsy node
"ExportNamedDeclaration|Flow"(path) { "ExportNamedDeclaration|Flow"(path) {
let { node, parent } = path; let { node, parent } = path;

View File

@ -0,0 +1,4 @@
class X {
a: number
b: ?string
}

View File

@ -0,0 +1,4 @@
class X {
/*:: a: number*/
/*:: b: ?string*/
}

View File

@ -0,0 +1,5 @@
{
"plugins": [
"transform-flow-comments"
]
}

View File

@ -0,0 +1,5 @@
class X {
a: number = 2
b: ?string = '3'
c: ?number
}

View File

@ -0,0 +1,7 @@
class X {
constructor() {
this.a = 2;
this.b = '3';
}
}

View File

@ -0,0 +1,6 @@
{
"plugins": [
"transform-flow-comments",
"transform-class-properties"
]
}

View File

@ -1,5 +1,5 @@
class X { class X {
foo = 2; foo = 2;
bar /*: number*/ = 3; bar /*: number*/ = 3;
baz /*: ?string*/; /*:: baz: ?string*/
} }