File tree Expand file tree Collapse file tree 4 files changed +18
-8
lines changed
packages/react-native-codegen/src/parsers Expand file tree Collapse file tree 4 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 1111'use strict' ;
1212
1313import type { SchemaType } from '../../CodegenSchema.js' ;
14+ import type { Parser } from '../parser' ;
1415
1516// $FlowFixMe[untyped-import] there's no flowtype flow-parser
1617const flowParser = require ( 'flow-parser' ) ;
@@ -49,7 +50,11 @@ function Visitor(infoMap: {isComponent: boolean, isModule: boolean}) {
4950 } ;
5051}
5152
52- function buildSchema ( contents : string , filename : ?string ) : SchemaType {
53+ function buildSchema (
54+ contents : string ,
55+ filename : ?string ,
56+ parser : Parser ,
57+ ) : SchemaType {
5358 // Early return for non-Spec JavaScript files
5459 if (
5560 ! contents . includes ( 'codegenNativeComponent' ) &&
@@ -75,11 +80,11 @@ function buildSchema(contents: string, filename: ?string): SchemaType {
7580function parseModuleFixture ( filename : string ) : SchemaType {
7681 const contents = fs . readFileSync ( filename , 'utf8' ) ;
7782
78- return buildSchema ( contents , 'path/NativeSampleTurboModule.js' ) ;
83+ return buildSchema ( contents , 'path/NativeSampleTurboModule.js' , parser ) ;
7984}
8085
8186function parseString ( contents : string , filename : ?string ) : SchemaType {
82- return buildSchema ( contents , filename ) ;
87+ return buildSchema ( contents , filename , parser ) ;
8388}
8489
8590module . exports = {
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ class FlowParser implements Parser {
8787 parseFile ( filename : string ) : SchemaType {
8888 const contents = fs . readFileSync ( filename , 'utf8' ) ;
8989
90- return buildSchema ( contents , filename ) ;
90+ return buildSchema ( contents , filename , this ) ;
9191 }
9292}
9393
Original file line number Diff line number Diff line change 1111'use strict' ;
1212
1313import type { SchemaType } from '../../CodegenSchema.js' ;
14+ import type { Parser } from '../parser' ;
1415
1516// $FlowFixMe[untyped-import] Use flow-types for @babel/parser
1617const babelParser = require ( '@babel/parser' ) ;
@@ -55,7 +56,11 @@ function Visitor(infoMap: {isComponent: boolean, isModule: boolean}) {
5556 } ;
5657}
5758
58- function buildSchema ( contents : string , filename : ?string ) : SchemaType {
59+ function buildSchema (
60+ contents : string ,
61+ filename : ?string ,
62+ parser : Parser ,
63+ ) : SchemaType {
5964 // Early return for non-Spec JavaScript files
6065 if (
6166 ! contents . includes ( 'codegenNativeComponent' ) &&
@@ -85,11 +90,11 @@ function buildSchema(contents: string, filename: ?string): SchemaType {
8590function parseModuleFixture ( filename : string ) : SchemaType {
8691 const contents = fs . readFileSync ( filename , 'utf8' ) ;
8792
88- return buildSchema ( contents , 'path/NativeSampleTurboModule.ts' ) ;
93+ return buildSchema ( contents , 'path/NativeSampleTurboModule.ts' , parser ) ;
8994}
9095
9196function parseString ( contents : string , filename : ?string ) : SchemaType {
92- return buildSchema ( contents , filename ) ;
97+ return buildSchema ( contents , filename , parser ) ;
9398}
9499
95100module . exports = {
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ class TypeScriptParser implements Parser {
9292 parseFile ( filename : string ) : SchemaType {
9393 const contents = fs . readFileSync ( filename , 'utf8' ) ;
9494
95- return buildSchema ( contents , filename ) ;
95+ return buildSchema ( contents , filename , this ) ;
9696 }
9797}
9898module . exports = {
You can’t perform that action at this time.
0 commit comments