File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { generateSource , Parser } from '../utils'
2
+
3
+ function parseExpressionAt ( input : string , pos : number ) {
4
+ return Parser . parseExpressionAt ( input , pos , {
5
+ sourceType : 'module' ,
6
+ ecmaVersion : 'latest' ,
7
+ locations : true
8
+ } )
9
+ }
10
+
11
+ describe ( 'parseExpressionAt API' , function ( ) {
12
+ it ( 'normal' , function ( ) {
13
+ const node = parseExpressionAt ( generateSource ( [
14
+ `<tag prop={` ,
15
+ ` (): void => {}` ,
16
+ `} />`
17
+ ] ) , 14 )
18
+
19
+ expect ( node . type ) . toEqual ( 'ArrowFunctionExpression' )
20
+ } )
21
+ } )
22
+
Original file line number Diff line number Diff line change 1
1
import * as acorn from 'acorn'
2
2
import tsPlugin from '../src'
3
3
4
- const Parser = acorn . Parser . extend ( tsPlugin ( {
4
+ export const Parser = acorn . Parser . extend ( tsPlugin ( {
5
5
jsx : {
6
6
allowNamespacedObjects : true ,
7
7
allowNamespaces : true
Original file line number Diff line number Diff line change @@ -5169,7 +5169,7 @@ function tsPlugin(options?: {
5169
5169
parser . isAmbientContext = true
5170
5170
}
5171
5171
parser . nextToken ( )
5172
- return ( parser as any ) . parseExpressionAt ( )
5172
+ return parser . parseExpression ( )
5173
5173
}
5174
5174
5175
5175
parseImportSpecifiers ( ) {
You can’t perform that action at this time.
0 commit comments