File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33function getJSCodeshiftParser ( api ) {
44 try {
5- let parser = require ( 'recast/parsers/typescript' ) ;
5+ // this is bad, but works around a bug in recent @babel/parser versions:
6+ let babelParser = require ( '@babel/parser' ) ;
7+ let parser = {
8+ parse ( source , _options ) {
9+ let options = require ( 'recast/parsers/_babylon_options' ) ( _options ) ;
10+ options . plugins = options . plugins . filter ( plugin => plugin !== 'pipelineOperator' ) ;
11+ options . plugins . push ( [ 'pipelineOperator' , { proposal : 'minimal' } ] ) ;
12+ options . plugins . push ( 'typescript' ) ;
13+
14+ return babelParser . parse ( source , options ) ;
15+ } ,
16+ } ;
17+
18+ // the above should be replace with the following (once
19+ // https://github.com/benjamn/recast/pull/521 lands in a release):
20+ // let parser = require('recast/parsers/typescript');
621
722 return api . jscodeshift . withParser ( parser ) ;
823 } catch ( e ) {
You can’t perform that action at this time.
0 commit comments