File tree 3 files changed +16
-3
lines changed
src/compiler/phases/1-parse
tests/parser-modern/samples
typescript-in-event-handler
3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1
1
import * as acorn from 'acorn' ;
2
2
import { walk } from 'zimmerframe' ;
3
3
import { tsPlugin } from 'acorn-typescript' ;
4
+ import { locator } from '../../state.js' ;
4
5
5
6
const ParserWithTS = acorn . Parser . extend ( tsPlugin ( { allowSatisfies : true } ) ) ;
6
7
@@ -127,6 +128,16 @@ function amend(source, node) {
127
128
// @ts -expect-error
128
129
delete node . loc . end . index ;
129
130
131
+ if ( typeof node . loc ?. end === 'number' ) {
132
+ const loc = locator ( node . loc . end ) ;
133
+ if ( loc ) {
134
+ node . loc . end = {
135
+ line : loc . line ,
136
+ column : loc . column
137
+ } ;
138
+ }
139
+ }
140
+
130
141
if ( /** @type {any } */ ( node ) . typeAnnotation && node . end === undefined ) {
131
142
// i think there might be a bug in acorn-typescript that prevents
132
143
// `end` from being assigned when there's a type annotation
Original file line number Diff line number Diff line change 36
36
},
37
37
"end" : {
38
38
"line" : 3 ,
39
- "column" : 25 ,
40
- "character" : 54
39
+ "column" : 25
41
40
}
42
41
},
43
42
"end" : 46 ,
Original file line number Diff line number Diff line change 54
54
"line" : 6 ,
55
55
"column" : 12
56
56
},
57
- "end" : 87
57
+ "end" : {
58
+ "line" : 6 ,
59
+ "column" : 25
60
+ }
58
61
},
59
62
"name" : " e" ,
60
63
"typeAnnotation" : {
You can’t perform that action at this time.
0 commit comments