File tree 3 files changed +28
-0
lines changed
3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 50
50
"@babel/plugin-syntax-jsx" : " ^7.0.0" ,
51
51
"@babel/plugin-transform-react-jsx" : " ^7.1.6" ,
52
52
"@babel/plugin-transform-runtime" : " ^7.5.0" ,
53
+ "@babel/preset-flow" : " ^7.0.0" ,
53
54
"@babel/traverse" : " ^7.1.6" ,
54
55
"@babel/types" : " ^7.1.6" ,
55
56
"babel-eslint" : " ^8.2.6" ,
Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ export function geneReactCode(ast) {
64
64
code = babel . transformSync ( code , {
65
65
babelrc : false ,
66
66
configFile : false ,
67
+ presets : [ "@babel/preset-flow" ] ,
67
68
plugins : [
68
69
babelDecorators ,
69
70
babelRestSpread ,
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) Areslabs.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { parseCode , geneReactCode } from '../../src/util/uast'
10
+
11
+ describe ( 'uast' , ( ) => {
12
+
13
+
14
+ it ( "parseCode geneReactCode: flow语法支持" , ( ) => {
15
+ const code = `
16
+ function foo(one: any, two: number, three?): string {}
17
+ `
18
+
19
+ const ast = parseCode ( code )
20
+ const newcode = geneReactCode ( ast )
21
+
22
+ const expectCode = `function foo(one, two, three) {}`
23
+ expect ( newcode ) . toBe ( expectCode )
24
+ } )
25
+
26
+ } )
You can’t perform that action at this time.
0 commit comments