Skip to content

Commit 4f9618a

Browse files
committed
fix(gen): fix gen issue with flow on
1 parent a401b8d commit 4f9618a

File tree

1 file changed

+31
-29
lines changed

1 file changed

+31
-29
lines changed

Diff for: src/generators/app/index.js

+31-29
Original file line numberDiff line numberDiff line change
@@ -466,35 +466,37 @@ export class Generator extends Base {
466466
const codeshiftStream = tap(function(file, t) {
467467
var contents = file.contents.toString();
468468

469-
// remove `implements Foo` from class declarations
470-
contents = jscodeshift(contents)
471-
.find(jscodeshift.ClassDeclaration)
472-
.forEach(path => {
473-
path.value.implements = null;
474-
})
475-
.toSource();
476-
477-
// remove any type annotations
478-
contents = jscodeshift(contents)
479-
.find(jscodeshift.TypeAnnotation)
480-
.remove()
481-
.toSource();
482-
contents = jscodeshift(contents)
483-
.find(jscodeshift.GenericTypeAnnotation)
484-
.remove()
485-
.toSource();
486-
487-
// remove any `type Foo = { .. }` declarations
488-
contents = jscodeshift(contents)
489-
.find(jscodeshift.TypeAlias)
490-
.remove()
491-
.toSource();
492-
493-
// remove any flow directive comments
494-
contents = jscodeshift(contents)
495-
.find(jscodeshift.Comment, path => path.type === 'CommentLine' && path.value.includes('@flow'))
496-
.forEach(path => path.prune())
497-
.toSource();
469+
if(!flow) {
470+
// remove `implements Foo` from class declarations
471+
contents = jscodeshift(contents)
472+
.find(jscodeshift.ClassDeclaration)
473+
.forEach(path => {
474+
path.value.implements = null;
475+
})
476+
.toSource();
477+
478+
// remove any type annotations
479+
contents = jscodeshift(contents)
480+
.find(jscodeshift.TypeAnnotation)
481+
.remove()
482+
.toSource();
483+
contents = jscodeshift(contents)
484+
.find(jscodeshift.GenericTypeAnnotation)
485+
.remove()
486+
.toSource();
487+
488+
// remove any `type Foo = { .. }` declarations
489+
contents = jscodeshift(contents)
490+
.find(jscodeshift.TypeAlias)
491+
.remove()
492+
.toSource();
493+
494+
// remove any flow directive comments
495+
contents = jscodeshift(contents)
496+
.find(jscodeshift.Comment, path => path.type === 'CommentLine' && path.value.includes('@flow'))
497+
.forEach(path => path.prune())
498+
.toSource();
499+
}
498500

499501
file.contents = new Buffer(contents);
500502
});

0 commit comments

Comments
 (0)