fix regression in transform-flow-comments for class properties (#4623)
This commit is contained in:
parent
46339463bd
commit
0e02a18216
@ -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
|
||||
"ExportNamedDeclaration|Flow"(path) {
|
||||
let { node, parent } = path;
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
class X {
|
||||
a: number
|
||||
b: ?string
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
class X {
|
||||
/*:: a: number*/
|
||||
/*:: b: ?string*/
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-flow-comments"
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
class X {
|
||||
a: number = 2
|
||||
b: ?string = '3'
|
||||
c: ?number
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
class X {
|
||||
constructor() {
|
||||
this.a = 2;
|
||||
this.b = '3';
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-flow-comments",
|
||||
"transform-class-properties"
|
||||
]
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
class X {
|
||||
foo = 2;
|
||||
bar /*: number*/ = 3;
|
||||
baz /*: ?string*/;
|
||||
/*:: baz: ?string*/
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user