File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/application/project/code/transformation/javascript Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 11import { File } from '@babel/types' ;
22import { parse , print } from 'recast' ;
3- import { parse as babelParser } from 'recast/parsers/babel-ts.js' ;
3+ import { parse as babelParse } from '@babel/parser' ;
4+ import getBabelOptions , { type Overrides } from 'recast/parsers/_babel_options.js' ;
45import { Codemod , CodemodOptions , ResultCode } from '@/application/project/code/transformation/codemod' ;
56import { Language } from '@/application/project/code/transformation/javascript/utils/parse' ;
67
@@ -19,7 +20,13 @@ export class JavaScriptCodemod<O extends CodemodOptions> implements Codemod<stri
1920 public async apply ( input : string , options ?: O ) : Promise < ResultCode < string > > {
2021 const ast = parse ( input , {
2122 parser : {
22- parse : babelParser ,
23+ parse : ( source : string , parseOptions ?: Overrides ) => {
24+ const babelOptions = getBabelOptions ( parseOptions ) ;
25+
26+ babelOptions . plugins . push ( 'jsx' , 'typescript' ) ;
27+
28+ return babelParse ( source , babelOptions ) ;
29+ } ,
2330 } ,
2431 } ) ;
2532
You can’t perform that action at this time.
0 commit comments