File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
packages/react-devtools-extensions/src Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -542,10 +542,15 @@ async function parseSourceAST(
542542 hookSourceData . originalSourceAST = sourceMetadata . originalSourceAST ;
543543 hookSourceData . originalSourceCode = sourceMetadata . originalSourceCode ;
544544 } else {
545+ // TypeScript is the most commonly used typed JS variant so let's default to it
546+ // unless we detect explicit Flow usage via the "@flow" pragma.
547+ const plugin =
548+ originalSourceCode . indexOf ( '@flow' ) > 0 ? 'flow' : 'typescript' ;
549+
545550 // TODO (named hooks) Parsing should ideally be done off of the main thread.
546551 const originalSourceAST = parse ( originalSourceCode , {
547552 sourceType : 'unambiguous' ,
548- plugins : [ 'jsx' , 'typescript' ] ,
553+ plugins : [ 'jsx' , plugin ] ,
549554 } ) ;
550555 hookSourceData . originalSourceAST = originalSourceAST ;
551556 if ( __DEBUG__ ) {
You can’t perform that action at this time.
0 commit comments