@@ -158,7 +158,7 @@ export class Generator extends Base {
158158 } , {
159159 type : 'confirm' ,
160160 name : 'flow' ,
161- default : false ,
161+ default : true ,
162162 message : 'Would you like to use Flow types with Babel?' ,
163163 when : answers => answers . transpiler === 'babel'
164164 } , {
@@ -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