File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 33 parseSync ,
44 ParserOptions ,
55 TransformOptions ,
6+ ParseResult ,
67} from '@babel/core' ;
7- import * as t from '@babel/types' ;
88import path from 'path' ;
99
1010const TYPESCRIPT_EXTS = {
@@ -46,7 +46,7 @@ function getDefaultPlugins(
4646}
4747
4848export type Options = TransformOptions & { parserOptions ?: ParserOptions } ;
49- export type FileNodeWithOptions = t . File & {
49+ export type FileNodeWithOptions = ParseResult & {
5050 program : { options : Options } ;
5151 __src : string ;
5252} ;
@@ -104,7 +104,11 @@ export default function buildParse(options: Options = {}): Parser {
104104
105105 return {
106106 parse ( src : string ) : FileNodeWithOptions {
107- const ast = parseSync ( src , opts ) as FileNodeWithOptions ;
107+ const ast = parseSync ( src , opts ) as FileNodeWithOptions | null ;
108+
109+ if ( ! ast ) {
110+ throw new Error ( 'Unable to parse source code.' ) ;
111+ }
108112 // Attach options to the Program node, for use when processing imports.
109113 ast . program . options = options ;
110114 return ast ;
You can’t perform that action at this time.
0 commit comments