This repository was archived by the owner on Jan 19, 2019. It is now read-only.
File tree 3 files changed +14
-4
lines changed
3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,8 @@ module.exports = (ast, extra) => {
56
56
parent : null ,
57
57
ast,
58
58
additionalOptions : {
59
- errorOnUnknownASTType : extra . errorOnUnknownASTType || false
59
+ errorOnUnknownASTType : extra . errorOnUnknownASTType || false ,
60
+ useJSXTextNode : extra . useJSXTextNode || false
60
61
}
61
62
} ) ;
62
63
Original file line number Diff line number Diff line change @@ -1613,9 +1613,12 @@ module.exports = function convert(config) {
1613
1613
1614
1614
}
1615
1615
1616
- case SyntaxKind . JsxText :
1616
+ case SyntaxKind . JsxText : {
1617
+ const type = ( additionalOptions . useJSXTextNode )
1618
+ ? AST_NODE_TYPES . JSXText : AST_NODE_TYPES . Literal ;
1619
+
1617
1620
Object . assign ( result , {
1618
- type : AST_NODE_TYPES . Literal ,
1621
+ type,
1619
1622
value : ast . text . slice ( node . pos , node . end ) ,
1620
1623
raw : ast . text . slice ( node . pos , node . end )
1621
1624
} ) ;
@@ -1624,6 +1627,7 @@ module.exports = function convert(config) {
1624
1627
result . range [ 0 ] = node . pos ;
1625
1628
1626
1629
break ;
1630
+ }
1627
1631
1628
1632
case SyntaxKind . JsxSpreadAttribute :
1629
1633
Object . assign ( result , {
Original file line number Diff line number Diff line change @@ -48,7 +48,8 @@ function resetExtra() {
48
48
tolerant : false ,
49
49
errors : [ ] ,
50
50
strict : false ,
51
- ecmaFeatures : { }
51
+ ecmaFeatures : { } ,
52
+ useJSXTextNode : false
52
53
} ;
53
54
}
54
55
@@ -104,6 +105,10 @@ function parse(code, options) {
104
105
extra . errorOnUnknownASTType = true ;
105
106
}
106
107
108
+ if ( typeof options . useJSXTextNode === "boolean" && options . useJSXTextNode ) {
109
+ extra . useJSXTextNode = true ;
110
+ }
111
+
107
112
}
108
113
109
114
// Even if jsx option is set in typescript compiler, filename still has to
You can’t perform that action at this time.
0 commit comments