This repository was archived by the owner on Jan 14, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +22
-80
lines changed Expand file tree Collapse file tree 2 files changed +22
-80
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,12 @@ export function convertComments(
107
107
* Create a TypeScript Scanner, with skipTrivia set to false so that
108
108
* we can parse the comments
109
109
*/
110
- const triviaScanner = ts . createScanner ( ast . languageVersion , false , 0 , code ) ;
110
+ const triviaScanner = ts . createScanner (
111
+ ast . languageVersion ,
112
+ false ,
113
+ ast . languageVariant ,
114
+ code
115
+ ) ;
111
116
112
117
let kind = triviaScanner . scan ( ) ;
113
118
while ( kind !== ts . SyntaxKind . EndOfFileToken ) {
@@ -123,8 +128,21 @@ export function convertComments(
123
128
comments . push ( comment ) ;
124
129
break ;
125
130
}
131
+ case ts . SyntaxKind . GreaterThanToken :
132
+ container = nodeUtils . getNodeContainer ( ast , start , end ) ;
133
+ if (
134
+ container &&
135
+ container . parent &&
136
+ container . parent . kind === ts . SyntaxKind . JsxOpeningElement &&
137
+ container . parent . parent &&
138
+ container . parent . parent . kind === ts . SyntaxKind . JsxElement
139
+ ) {
140
+ kind = triviaScanner . reScanJsxToken ( ) ;
141
+ continue ;
142
+ }
143
+ break ;
126
144
case ts . SyntaxKind . CloseBraceToken :
127
- container = nodeUtils . getNodeContainer ( ast , start , end ) as ts . Node ;
145
+ container = nodeUtils . getNodeContainer ( ast , start , end ) ;
128
146
129
147
if (
130
148
container . kind === ts . SyntaxKind . TemplateMiddle ||
Original file line number Diff line number Diff line change @@ -3888,28 +3888,7 @@ Object {
3888
3888
" type" : " VariableDeclaration" ,
3889
3889
},
3890
3890
],
3891
- " comments" : Array [
3892
- Object {
3893
- " loc" : Object {
3894
- " end" : Object {
3895
- " column" : 9 ,
3896
- " line" : 6 ,
3897
- },
3898
- " start" : Object {
3899
- " column" : 6 ,
3900
- " line" : 4 ,
3901
- },
3902
- },
3903
- " range" : Array [
3904
- 48 ,
3905
- 75 ,
3906
- ],
3907
- " type" : " Block" ,
3908
- " value" : " *
3909
- * test
3910
- " ,
3911
- },
3912
- ],
3891
+ " comments" : Array [],
3913
3892
" loc" : Object {
3914
3893
" end" : Object {
3915
3894
" column" : 0 ,
@@ -4519,26 +4498,7 @@ Object {
4519
4498
" type" : " VariableDeclaration" ,
4520
4499
},
4521
4500
],
4522
- " comments" : Array [
4523
- Object {
4524
- " loc" : Object {
4525
- " end" : Object {
4526
- " column" : 67 ,
4527
- " line" : 1 ,
4528
- },
4529
- " start" : Object {
4530
- " column" : 48 ,
4531
- " line" : 1 ,
4532
- },
4533
- },
4534
- " range" : Array [
4535
- 48 ,
4536
- 67 ,
4537
- ],
4538
- " type" : " Line" ,
4539
- " value" : " example.com</a>);" ,
4540
- },
4541
- ],
4501
+ " comments" : Array [],
4542
4502
" loc" : Object {
4543
4503
" end" : Object {
4544
4504
" column" : 0 ,
@@ -5257,24 +5217,6 @@ Object {
5257
5217
" type" : " Block" ,
5258
5218
" value" : " Test " ,
5259
5219
},
5260
- Object {
5261
- " loc" : Object {
5262
- " end" : Object {
5263
- " column" : 29 ,
5264
- " line" : 3 ,
5265
- },
5266
- " start" : Object {
5267
- " column" : 20 ,
5268
- " line" : 3 ,
5269
- },
5270
- },
5271
- " range" : Array [
5272
- 59 ,
5273
- 68 ,
5274
- ],
5275
- " type" : " Line" ,
5276
- " value" : " </test>" ,
5277
- },
5278
5220
],
5279
5221
" loc" : Object {
5280
5222
" end" : Object {
@@ -6156,24 +6098,6 @@ Object {
6156
6098
" type" : " Block" ,
6157
6099
" value" : " Test " ,
6158
6100
},
6159
- Object {
6160
- " loc" : Object {
6161
- " end" : Object {
6162
- " column" : 29 ,
6163
- " line" : 3 ,
6164
- },
6165
- " start" : Object {
6166
- " column" : 20 ,
6167
- " line" : 3 ,
6168
- },
6169
- },
6170
- " range" : Array [
6171
- 59 ,
6172
- 68 ,
6173
- ],
6174
- " type" : " Line" ,
6175
- " value" : " </test>" ,
6176
- },
6177
6101
],
6178
6102
" loc" : Object {
6179
6103
" end" : Object {
You can’t perform that action at this time.
0 commit comments