-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Description
Description
Note: The items in this list are eligible for Hacktoberfest (https://hacktoberfest.com/). All the accepted PRs under this umbrella task will be tagged with the hacktoberfest-accepted label, to count toward your score.:tada:
Hi everyone!
This is an umbrella issue to collect a set of tasks aimed to improve the code in the react-native-codegen package.
Codegen is a pillar for the New Architecture and is part of the core developer experience. We believe that everyone would benefit from a clear and maintainable codebase, hence this umbrella issue to help us cleanup and restructure some of its components.
The codegen internals
Codegen work with a 2-steps process:
- It parses a set of JS-based specifications and it creates a JSON Schema.
- Starting from the Schema, it generates a set of Native files in various languages: Java, Objective-C++ and C++.
Codegen package is divided in three high-level folders:
- cli => it contains a set of scripts to use the Codegen from a Command Line Interface.
- generators => it contains a set of file which generate the final code.
- parsers => it contains a set of files to parse Flow and TypeScript specifications.
The first step of this imrpovement effort will focus on the Parsers.
Parsers
The parsers folders contains subfolders to parse Flow and TypeScript specs. The two folders have a very similar structure:
- a components folder, where there is the logic to parse Native Components specs
- a modules folder, where there is the logic to parse the Native Modules specs
- some extra files:
index.js,errors.jsandutils.js
There are different levels of code duplication we want to reduce.
- In some case, we can put together some concepts between TS and Flow.
- In some other cases, we can share some code between Components and Modules.
- Finally, we will extract and refactor code within the same file to improve its maintainability and readability.
How to Test
It’s crucial that you test the changes you submit. The proper way of doing this is:
- If it doesn’t exists, create a new folders called
__tests__at the same level of the file you added/modified. - Add some unit tests to verify the behavior of your function, by creating a
<your-file>-tests.jsfile (if it doesn't exists). An example test is this one. Make sure to:- Add the license lines (otherwise the Meta internal linter will complain)
- Use the strict mode
- Import your file (if it hasn't been imported yet)
- Follow the what-when-result pattern when describing the test ("What are we testing, in which context, what is the expected result")
Once you implemented your changes, you can run the tests locally by following these steps:
- Navigate to react-native root folder
- yarn install to set up the dependencies
- yarn jest react-native-codegen to test your changes against the existing test suite.
You can find more documentation on Jest, our testing framework, here (https://jestjs.io/).
The Tasks
The following is a list of tasks we need to execute to improve the code quality of this tool. The list is a living one: the more we improve with the situation, the more patterns we can discover. Whenever we found some pattern that we can add, we will attach this to the list.
If you want to tackle some specific task which is not listed, feel free to post a comment with a brief description of the task and I'll make sure to add it to the list of tasks so it is tracked.
Please comment below if you're willing to take the stance on any of those task and wait for a confirmation before start working on it. Please note that if you claim a task, but don't submit a PR within 2 week, we're going to free up that task for someone else.
-
Extract theCommit 7227bdeerror.jsfile from the flow and typescript folders into anerror.jsfile in their parent folder. Then, have the two parsers use the sameParserError
Assigned to @gabrieldonadel -
Extract theCommit 35556dbmodules/schema.jsfrom the flow and typescript folders in a sharedparsers-commons.jsfile. Then, have the two parsers use the samewrapModuleSchemafunction for modules.
Assigned to @tarunrajput -
Extract theCommit 24efebfmodules/utils.jsfrom the flow and typescript folders in a sharedparsers-commons.jsfile. Then, have the two parsers use the samewrapModuleSchemafunction for modules.
assigned to @AntoineDoubovetzky -
[Assigned to @matiassalles99] Extract theUnsupportedArrayElementTypeAnnotationParserErrorin its own throwing function and reuse that function passing a proper type. The error is thrown at lines132,141and150in both Flow and TypeScript parsers.-
Refactor the code using a dictionary and avoiding the three differentifs in the Flow parser -
Refactor the code using a dictionary and avoiding the three differentCommit cc311ffifs in the TS parser
-
-
[Assigned to @dhruvtailor7]Extract theUnsupportedObjectPropertyValueTypeAnnotationParserErrorin its own throwing function and reuse that function passing a proper type. The error is thrown at lines281,290and299in both Flow and TypeScript parsers.-
Refactor the code using a dictionary and avoiding the three differentifs in the Flow parser -
Refactor the code using a dictionary and avoiding the three differentCommit aba6be6ifs in the TS parser
-
-
Extract all the errors in theCommit 7b345bcflow/module/errors.jsand in thetypescript/module/errors.jsinto a singleparser/errors.jsfile. All the errors must drop the correspondingFloworTypescripttoken in the name and take an extralanguageparameter in the constructor. Also, rename thehasteModuleNameparameter tonativeModuleName.
Assigned to @tarunrajput - Extract each individual exception to a separate function inside an
error-utils.jsfile. Each function should accept an extra parser parameter, throw the proper error based on the parser and use it in the Flow parser and in the TypeScript one. All these errors can be found in thebuildModuleSchemafunction (Flow, Typescript) The list of exceptions to handle is:-
[Assigned to @gabrieldonadel ]Commit c9338c4InterfaceNotFound -
[Assigned to @Marcoo09 ]Commit f628edcMoreThanOneModule -
[Assigned to @mohitcharkha]Commit 9fb3700MisnamedModuleFlowInterfaceParserError -
[Assigned to @vinayharwani13]Commit a33f672UnusedModuleFlowInterfaceParserError -
[Assigned to @mohitcharkha]Commit ab22e3aMoreThanOneModuleRegistryCallsParserError -
[Assigned to @dakshbhardwaj]Commit 76c5b6fIncorrectModuleRegistryCallArityParserError -
[Assigned to @mdaj06]Commit bb519ecIncorrectModuleRegistryCallArgumentTypeParserError -
[Assigned to @dhruvtailor7]Commit 1e15e21UntypedModuleRegistryCallParserError -
[Assigned to @harshsiri110]Commit bb519ecIncorrectModuleRegistryCallTypeParameterParserError
-
-
[Assigned to @ZihanChen-MSFT] Support intersection of object types,Commit 813fd04{...a, ...b, ...}in Flow is equivalent toa & b & {...}in TypeScript, the order and the form is not important. - [Assigned to @ZihanChen-MSFT] Refactor the code using flattenProperties and its implementation is duplicated, it will become obvious after adding intersection type.
- [Assigned to @ZihanChen-MSFT] Automatically converting
CodegenSchema.jstoCodegenSchema.d.ts, and add type descriptions for exposed functions. - [Assigned to @ZihanChen-MSFT] In
CodegenSchema.jscomponent property types are better to be defined in recursion, not to repeat everything in Array again. -
[Assigned to @AntoineDoubovetzky] Extract the functionCommit 790f40cassertGenericTypeAnnotationHasExactlyOneTypeParameter(Flow TypeScript) into a single function in theparsers-common.jsfile and replace its invocation with this new function. -
Extract the content of the case 'RootTag' (Flow, TypeScript) into a singleCommit 5f05b07emitRootTagfunction in theparsers-primitives.jsfile. Use the new function in the parsers.
Assigned to @MaeIg -
Extract the content of the case 'Promise' (Flow, TypeScript) into a singleCommit 966f3cdemitPromisefunction in theparsers-primitives.jsfile. Use the new function in the parsers.
Assigned to @AntoineDoubovetzky -
[Assigned to @gabrieldonadel] Extract the content of the case 'Stringish' (Flow, TypeScript) into a singleCommit 305f7c3emitStringishfunction in theparsers-primitives.jsfile. Use the new function in the parsers. -
Extract the content of the case 'Int32' (Flow, TypeScript) into a singleCommit db8c11demitInt32function in theparsers-primitives.jsfile. Use the new function in the parsers.
Assigned to @Naturalclar -
[Assigned to @AntoineDoubovetzky]Extract the content of the case 'Double' (Flow, TypeScript) into a singleCommit 3ab7ef2emitDoublefunction in theparsers-primitives.jsfile. Use the new function in the parsers. -
[Assigned to @gabrieldonadel]Extract the content of the case 'Float' (Flow, TypeScript) into a singleCommit: 87d6580emitFloatfunction in theparsers-primitives.jsfile. Use the new function in the parsers. -
[Assigned to @Marcoo09] Extract the content of the case 'Object' (Flow, TypeScript) into a singleCommit fd4451eemitObjectfunction in theparsers-primitives.jsfile. Use the new function in the parsers. -
[Assigned to @MaeIg] Wrap the TypeAlias resolution lines (Flow, TypeScript) in a propertypeAliasResolutionfunction in theparsers-primitives.jsfiles and replace those lines with the new function. -
[Assigned to @tarunrajput] Extract the content of the case 'BooleanTypeAnnotation' (Flow, TypeScript) into a singleCommit 7a2e346emitBooleanfunction in theparsers-primitives.jsfile. Use the new function in the parsers. -
[Assigned to @youedd] Extract the content of the case 'NumberTypeAnnotation' (Flow, TypeScript) into a singleCommit 54fc62cemitNumberfunction in theparsers-primitives.jsfile. Use the new function in the parsers. -
[Assigned to @youedd] Extract the content of the case 'VoidTypeAnnotation' (Flow, TypeScript) into a singleCommit b3219feemitVoidfunction in theparsers-primitives.jsfile. Use the new function in the parsers. -
[Assigned to @ken0nek]Extract the content of the case 'StringTypeAnnotation' (Flow, TypeScript) into a singleCommit eda90e5emitStringfunction in theparsers-primitives.jsfile. Use the new function in the parsers. -
[Assigned to @mohitcharkha] Extract the content of the case 'FunctionTypeAnnotation' (Flow, TypeScript) into a singleCommit c403cd4emitFunctionfunction in theparsers-primitives.jsfile. Use the new function in the parsers. -
[Assigned to @MaeIg] Extract the function createParserErrorCapturer (Flow TypeScript) into a single function in the parsers/utils.js file and replace its invocation with this new function.Commit 38fcafe -
[Assigned to @AntoineDoubovetzky] Extract the function visit (Flow TypeScript) into a single function in the parsers/utils.js file and replace its invocation with this new function.Commit 3c8d678 -
[Assigned to @AntoineDoubovetzky] Extract the function isModuleRegistryCall (Flow TypeScript) into a single function in the parsers/utils.js file and replace its invocation with this new function.Commit: 83e2126 -
[Assigned to @dhruvtailor7] This task is more advanced than the others and a 2-steps tasks. First, extract thevisitorobject into a separate dictionary in the same file (Flow, TypeScript. The signature of thevisitmethod is in these links: Flow, TypeScript). Then, factor out the thegetConfigTypefunction (Flow, TypeScript) into theparsers/utils.jsfile. -
[Assigned to @MaeIg] This task is more advanced than the others. Extract theCommit 8f484c3switch(configType)block (Flow, TypeScript) from thebuildSchemafunction into a new function in theparsers/utils.jsfile and use it in the two functions. Note that the new function must accept some callbacks to wrapModule/ComponentSchema and to buildModule/ComponentSchema. -
[Assigned to @gabrieldonadel] ExportCommit 376ffacparseFile(Flow, TypeScript) in to aparseFilefunction inparsers/utils.js. Note that the function should accept a callback tobuildSchemaproperly. -
[Assigned to @vinayharwani13] This task is much simple than the others, it just moves a type and there is no logic. Export theCommit 2934399TypeDeclarationMaptype (Flow, TypeScript) into a single type in theparsers/utils.jsfile. -
[Assigned to @dakshbhardwaj] Extract theCommit 1eaa092nullGuardfunction (Flow, TypeScript) into a function in theparsers-utils.jsfile and use it in the other parsers. -
[Assigned to @MaeIg] Wrap the content of theCommit c388e6ccase Array:andcase ReadOnlyArrayin Flow into a separate function, as it is for the TypeScript parser. This will enable us to unify the two parsers in a later step. -
[Assigned to @gabrieldonadel] This task is more advanced than the others Create a function to unify theCommit ea55e3bdefault:case (Flow, TypeScript) into theparser-commons.jsfile and use it in the two parsers. For theif (CxxOnlystatement, we may accept an OR betweenEnumDeclarationandTSEnumDeclaration. The function should accept aParserTypeparameter to implement the proper logic to extract thememberTypevariable. Ideally, we should create a couple of supporting functions to implement those logics. -
[Assigned to @youedd] This task is more advanced than the others Create a function to unify theCommit 0627cd6unionTypeand theTSUnionType. This task may share some logic from the previous task. The function should accept aParserTypeparameter to implement the proper logic to extract thememberTypevariable. Ideally, we should create a couple of supporting functions to implement those logics. -
[Assigned to @tarunrajput] Create a functionCommit b87d371emitMixedTypeAnnotationinto theparsers-commons.jsfile to put together this code from Flow and TypeScript. -
[Assigned to @harshsiri110] Extract the logic that throw theCommit 3247436UnsupportedFunctionReturnTypeAnnotationParserError(Flow, TypeScript) into a new function in the theparsers/error-utils.jsfile. The function should encapsulate the logic that decide whether to throw the error or not. Please reuse theUnsupportedFunctionReturnTypeAnnotationParserErrorthat has already been exported in theparsers/errors.jsfile. -
[Assigned to @mohitcharkha] Extract the logic that throws theCommit f645404UnsupportedModulePropertyParserError(Flow, TypeScript) into a new function in theparsers/error-utils.jsfile. It should take a parameterParserTypeto discriminate the logic of the two. Please reuse theUnsupportedModulePropertyParserErrorthat has already been exported in theparsers/errors.jsfile. -
[Assigned to @youedd] Extract theCommit 633498fnameToValidatelogic (Flow, TypeScript) into a shared function into theparser/utils.jsfile. Notice that you may need a callback to update the cxx boolean. -
[Assigned to @ZihanChen-MSFT] Support function signature along with function type properties in commands.Commit ae1d54b -
[Assigned to @MaeIg] Extract theCommit 3f2691cparseFilefunction in theparsers-commons.jsfile to a top levelbuildSchemafunction which takes additional parameters to properly parse the content, get the config type and to build the schema, based on the language used. -
[Assigned to @MaeIg] Extract theCommit 4628150buildSchemafunction (Flow, TypeScript) in theparsers-commons.jsfile to a top levelbuildSchemafunction which takes additional parameters to properly parse the content, get the config type and to build the schema, based on the language used. -
[Assigned to @Pranav-yadav ] Note: this task depends on "Extract theCommit 5a20bd5UnsupportedArrayElementTypeAnnotationParserError" Extract the functiontranslateArrayTypeAnnotation(Flow, TypeScript) into a funtion in theparsers-primitives.jsfile. -
[Assigned to @gabrieldonadel] Note: This task depends on Extract the functionCommit ea9e78dtranslateArrayTypeAnnotationExtract the content of thecase Arrayandcase ReadOnlyArray(Flow, Typescript) into anemitArrayTypefunction in theparsers-primitives.jsfile. -
[Assigned to @Pranav-yadav] Extract the content of theCommit 5744b21tryParse(Flow, TypeScript)lambda into a properparseObjectPropertyfunction into theparsers-commons.jsfile. -
[Assigned to @AntoineDoubovetzky] Extract theCommit 8c69b6cUnsupportedFunctionParamTypeAnnotationParserError(Flow, Typescript) in its own throwing function (if it does not exists already) and reuse that function passing a proper type. Then, refactor the code using a dictionary and avoiding the three different ifs in both parsers. -
[Assigned to @gabrieldonadel] This task is more complex than the others and it depends on Extract theCommit 62244d4UnsupportedFunctionParamTypeAnnotationParserErrorExtract thetranslateFunctionTypeAnnotation(Flow, TypeScript)into a common function in theparsers-primitives.jsfile. This function extracts some information from the ASTs that have different structures for Flow and Typescript. Whenever there is such difference, create an helper function that takes thetypeAnnotationand the language to make the decision. For example: in theforloop at the beginning of the function, the flow parser gets the list of parameters fromflowFunctionTypeAnnotation.paramswhile the typescript parser usestypescriptFunctionTypeAnnotation.parameters. In this case, you'll have to create a functiongetTypeAnnotationParameters(typeAnnotation, language)with a simple switch over the languages to return the array of parameters. -
[Assigned to @Marcoo09] This task depends on Extract theCommit 64ea7cetranslateFunctionTypeAnnotationMove thetranslateFunctionTypeAnnotationinvocation (Flow, TypeScript) into theemitFunctioncall so that thecase FuntionTypeAnnotationresults in a one-liner. -
[Assigned to @Pranav-yadav] This task depends on Extract theCommit fb37deatranslateFunctionTypeAnnotationExtract thebuildPropertySchema(Flow TypeScript) into theparsers-commons.jsfile. It has to take the language parameter to extract the value and an additional callback for theresolveTypeAnnotationfunction. -
[Codegen_buildModuleSchema - assign to @tarunrajput] Extract theCommit 3cd97e4buildModuleSchemafunction (Flow, TypeScript)in theparsers-commons.jsfunction. The two functions are almost identical except for thefilter(property =>)at the end of the function, which is different based on the language. -
[Assigned to @Pranav-yadav] Move theCommit 95e685aemitMixedTypeAnnotationfunction to theparser-primitives.jsfile. -
[Assigned to @AntoineDoubovetzky] Create a new functionCommit 8a847a3typeParameterInstantiationin theparsers.jsfile and add documentation to it. Implement it properly in theFlowParser.jsand in theTypeScriptParser.js. Update the signature ofassertGenericTypeAnnotationHasExactlyOneTypeParameterfunction to take theParserinstead of the language and use the new function in place of the ternary operator?:. -
[Assigned to @youedd] Create a new functionCommit a7ae988remapUnionTypeAnnotationMemberNamesin theparser.jsfile and add documentation to it. Implement it properly in theFlowParser.jsand in theTypeScriptParser.js. Remove the functionremapUnionTypeAnnotationMemberNamesand update theemitUnionTypeAnnotationsignature to accept aParserparameter instead of a language one. Use the new Parser function instead of the old one here. -
[Assigned to @gabrieldonadel] Create a getKeyName function in theCommit f849f49parser.jsfile and document it. Implement it properly in theFlowParser.jsand in theTypeScriptParser.js: it should contain theObjectTypePropertyand theObjectTypeIndexerfor Flow and theTSObjectTypePropertyand theTSObjectTypeIndexer. Remove the oldgetKeyNamefunction and use the new one in the parser object wherever the other was used. -
[Assigned to @AntoineDoubovetzky] Update theCommit edc4ea0IncorrectlyParameterizedGenericParserErrorerror in theerror.jsfile to accept aParserinstead of aParserTypeparameter. Use thenameForGenericTypeAnnotationmethod of the parser to extract thegenericNameand delete the ternary operator. -
[Assigned to @tarunrajput] Create aCommit e97fb46checkIfInvalidModulefunction in theparser.jsfile and document it. Implement this logic in theFlowParser.jsand this logic in theTypeScriptParser.js. Refactor thethrowIfIncorrectModuleRegistryCallTypeParameterParserErrorfunction to accept a Parser instead of a ParserType and use the newly created function instead of theif (language)logic. -
[Codegen_functionTypeAnnotation - assigned to @gabrieldonadel] Define aCommit 43986e8functionTypeAnnotationin theparser.jsfile and document it. Implement this logic in theFlowParser.jsand this logic in theTypeScriptParser.js. Refactor thethrowIfModuleTypeIsUnsupportedfunction to accept aParserinstead of aParserTypeand use the newly created function instead of theif (language)logic. -
[Codegen 74 assigned to @AntoineDoubovetzky] MoveCommit f23f7f4getTypesfunctions fromutils.jsto specific Parsers. Right now we have two Parser classes that takes care of the language specific details and two utils files that contains similar logic. We would like to move everything under the Parsers classes for better OOP architecture and to encourage code-reuse. -
[Codegen 75 assigned to @gabrieldonadel] Create aCommit 5ff8895throwIfPartialWithMoreParameterfunction in theerror-utils.jsand extract the error-emitting code from Flow and Typescript index files. -
[Codegen 76 - assigned to @tarunrajput ] Create aCommit 371e263throwIfPartialNotAnnotatingTypeParameterfunction in theerror-utils.jsfile and extract the error-emitting code from Flow and Typescript index files. Notice that the way in which theannotatedElementis computed is different, therefore we should add anextractAnnotatedElementfunction to the Flow and TypeScript parsers. -
[Codegen 77 - assigned to @MaeIg] Extract the functions to compute partial properties from theCommit a448c6dindex.jsfile (Flow and TypeScript)in the Flow and TypeScript parsers. -
[Codegen 78 - Assigned to @Pranav-yadav] It depends on [Codegen 75][Codegen 76][Codegen 77] Extract the logic that emits Partial values in anCommit 2f25261emitPartialfunction, which takes the Parsers as parameter. -
[Codegen 79 - Assigned to @Pranav-yadav] It depends on [Codegen 78] Extract the basicCommit 2f25261caseslogics (case Stringish,case Int32,case Double, ...,case Partial. Flow lines and TypeScript lines) into a functionemitCommonTypesinparsers-primitives.js. Make sure that thedefaultcase returnsnull. Call this function in thedefault:case (Flow, TypeScript) of theindex.jsfile: if the function return something, return that from thedefaultcase; otherwise if theemitCommonTypesreturnsnull, keep the currentdefaultimplementation (throw the error). -
[Codegen 80 - assigned to @kyawthura-gg] It depends on [Codegen 79] Convert theCommit 4a15f90emitCommonTypesimplementation from a switch based implementation to a dictionary based one. -
[Codegen 81 - Assigned to @gabrieldonadel] It depends on [Codegen 80] Expand theCommit 66ae98eemitcCommonTypesfunction adding the remaining basic types: lines for Flow and lines for Typescript: the way to do it is by using theflowkeys in the dictionary and by implementing aconvertKeywordToTypeannotationfunction in the two parsers. The flow parser will return the same parameter it receives as input, the TypeScript parser will convert the TypeAnnotation to Keywords. For example,TSBooleanKeywordwill becomeBooleanTypeAnnotation. Call theemitCommonTypesin thedefault:case: if it return something, use that as returned type. Otherwise, keep the current implementation which throws an error. -
[Codegen 82 - assigned to @kyawthura-gg] MoveCommit 85245afisModuleInterfacefunction (Flow, TypeScript) to the Flow and TypeScript parsers. -
[Codegen 83 - assigned to @Pranav-yadav] Create a functionCommit 1362820throwIfIncorrectModuleRegistryCallArgumnentfunction in theerror-utils.jsfile and factor together the code from Flow and TypeScript. Update the Parsers to return the right Literl type -
[Codegen 84 - assigned to @Pranav-yadav] It depends on [Codegen 83] export theCommit 05454faparseModuleNameanonymous function (Flow, TypeScript) in a commonparseModuleNamefunction in theparsers-commons.jsfile. -
[Codegen 85 - assigned to @tarunrajput] TheCommit 8be9dbfparses/flow/components/schema.jsandparses/typescript/components/schema.jsare the same. Move theschema.jsfrom the one of the two folders to theparserscommon root. Delete the other. Update the references to use the shared file. -
[Codegen 86 - Assigned to @ken0nek] TheCommit 0212179buildPropSchemafunction inparsers/typescript/components/props.jsandparsers/flow/components/props.jsis the same. move it inparser-commonsand use it in the origina files. -
[Codegen 87 - Assigned to @siddarthkay] Depends on [Codegen 86] Add theCommit fc927d1getPropsfunction to the Parsers abstract class and implement it in the Flow and TypeScript parsers: this is the reference implementation for Flow and TypeScript. Remove theprops.jsfiles afterward. -
[Codegen 88 - assigned to @tarunrajput] Move the Visitor.js file fromCommit d9f2cbeparsers/flow/Visitor.jstoparser-promitives.js. Copy theTSInterfaceDeclaration(node: $FlowFixMe)function and add it to the Visitor.js just copied. Remove theparsers/typescript/Visitor.js. Make sure we use the same Visitor in both parsers. (We will end up with a Visitor that is the union of the two, being able to handle both Flow and TS. In this specific case, this trade-off make sense as it allows us to remove one file, several duplicated lines for a small price.) -
[Codegen 89 - Assigned to @MaeIg] Remove theCommit 26b22a6const languagevariable fromflow/modules/index.jsand replace its usage withparser.language() -
[Codegen 90 - Assigned to @MaeIg] Remove theCommit 26b22a6const languagevariable fromtypescript/modules/index.jsand replace its usage withparser.language() -
[Codegen 91 - Assigned to @yux-m] Extract the inner switch inCommit 94f505btypescript/modules/index.jsat line to parse thecase TSTypereference(lines)into a functiontranslateTypeReferenceAnnotation()(the goal is to try and get a simpler switch statement and to spot structural similiarities between the flow and typescript index.js files) -
[Codegen 92 - assigned to @kyawthura-gg] TheCommit 221aacdgetCommandOptionsfunction inparsers/typescript/components/options.jsandparsers/flow/components/options.jsis the same. move it inparser-commonsand use it in the original files. If the file twooptions.jsfiles are empty, delete them. -
[Codegen 93 - assigned to @tarunrajput] The221aacdgetOptionsfunction inparsers/typescript/components/options.jsandparsers/flow/components/options.jsis the same. move it inparser-commonsand use it in the original files. If the file twooptions.jsfiles are empty, delete them. -
[Codegen 94 - assigned to @siddarthkay] TheCommit c937162extendsForPropfunction inparsers/typescript/components/extends.jsandparsers/flow/components/extend.jsis the same. Move it inparser-commonsand use it in the origina files. -
[Codegen 95 - assigned to @Pranav-yadav] Extract theCommit c0a46c696b7365a0b74fc4dbf41e83de24305d7fdefaultExports.forEach(statement =>(Flow, TS) function inparser-commons, so that it accept a Parser parameter to unify the behaviors between flow and typescript. The Parser object needs to be enriched with all the methods to extract the required information from the Node, if they are not there yet. -
[Codegen 96 - assigned to @AntoineDoubovetzky] Create aCommit 8fbcfcethrowIfConfigNotfoundin theerror-utils.jsfile and extract the error code from Flow and TS -
[Codegen 97 - assigned to @AntoineDoubovetzky] Create aCommit 8fbcfcethrowIfMoreThanOneConfigin theerror-utils.jsfile and extract the error code from Flow and TS -
[Codegen 98 - assigned to @MaeIg] Extract theCommit 5ff01bcnamedExports.map(statement =>(Flow, TS) function inparser-commons, so that it accept a Parser parameter to unify the behaviors between flow and typescript. The Parser object needs to be enriched with all the methods to extract the required information from the Node, if they are not there yet. -
[Codegen 99 - assigned to @tarunrajput] Extract theCommit (347d6f8)[https://github.com/facebook/react-native/commit/347d6f8d899d7a8f5c901611923c9c09039acbdb]throwIfMoreThanOneCodegenNativecommandserror in theerror-utils.jsfile and extract the error code from Flow and TS -
[Codegen 100 - assigned to @marcocaldera] Create aCommit 320e51fcreateComponentConfigfunction in theparser-commons.jsfile. It takes thefoundConfigand thecommandTypeNamesas parameters and returns the component config object. Extract thereturnstatements (Flow TS) and use those implementations in that function. -
[Codegen 101 - assigned to @kyawthura-gg] The code ofCommit 969a8d0getCommandPropertiesis almost identical in Flow and TS. There are small differences between flow/ts, so we need for it to accept a Parser object. Enrich the parser object with the required methods if necessary. -
[Codegen 102 - assigned to @Pranav-yadav] Extract the code to compute theCommit efc6e14extendsPropsand thepropsproperties in Flow in agetProps() -> {extendsProps, props}function into the sameindex.jsfile. This will help unifying thebuildComponentSchemafunctions between Flow and TS so we can factor it out in a later step. -
[Codegen 103 - assigned to @gabrieldonadel] Extract the code to compute theCommit e962d43extendsPropsand thepropsproperties in TypeScript in agetProps() -> {extendsProps, props}function into the sameindex.jsfile. This will help unifying thebuildComponentSchemafunctions between Flow and TS so we can factor it out in a later step
-
[Codegen 104 - Assigned to @siddarthkay] Add aCommit e09d585getResolvedTypeAnnotationfunction to the Parser class. Implement that function in the FlowParser and TypeScriptParser, using the implementation found in theparsers/flow/utils.jsandparsers/typescript/utils.js. Then, replace those lines using the new function. -
[Codegen 105 - Assigned to @tarunrajput] Add aCommit 0de4768typeAlias: stringproperty to the Parser class. Implement it in the Flow parser so that it returnsTypeAliasand in
the TypeScriptParser so that it returnsTSTypeAliasDeclaration. Replace thecasein theswitchin theparsers/flow/utils.jsandparsers/typescript/utils.jswith this prop. -
[Codegen 106 - Assigned to @tarunrajput] Add aCommit 91c60cbenumDeclaration: stringproperty to the Parser class. Implement it in the Flow parser so that it returnsEnumDeclarationand in the TypeScriptParser so that it returnsTSEnumDeclaration. Replace thecasein theswitchin theparsers/flow/utils.jsandparsers/typescript/utils.jswith this prop. -
[Codegen 107 - @Shubham1429] Add aCommit 9301c8finterfaceDeclaration: stringproperty to the Parser class. Implement it in the Flow parser so that it returnsInterfaceDeclarationand in the TypeScriptParser so that it returnsTSInterfaceDeclaration. Replace thecasein theswitchin theparsers/typescript/utils.jswith this prop. -
[Codegen 108 - Depends on 105, 106, 107 - Assigned to @tarunrajput] Move theCommit (8ffaede)[https://github.com/facebook/react-native/commit/8ffaede05a72973805f668e1dda41060ee054dc4]switchconstruct fromparsers/typescript/utils.jsandparsers/flow/utils.jsto theparsers-commons.jsfile, in ahandleGenericTypeAnnotationfunction. Use that function in place of theswitch. -
[Codegen 109 - assigned to @tarunrajput] Extract the typeAnnotation doesn't have a name error (Commit c65ab4dFlow;TypeScript) inthrowIfEventHasNoNamefunction which takes a typeAnnotation and a parser as parameters. Use it in place of the if in the above call sites. -
[Codegen 110 - Assigned to @kyawthura-gg ] Add aCommit b5c01eenullLiteralTypeAnnotation: stringproperty into the Parser object and implement it in theFlowParser(returning
NullLiteralTypeAnnotation) and in theTypeScriptParser(returningTSNullKeyword). Replace them in theparsers/flow/components/events.jsandparsers/typescript/components/events.js. -
[Codegen 111 - assigned to @Shubham1429] Add anCommit cf8184dundefinedLiteralTypeAnnotation: stringproperty into the Parser object and implement it in theFlowParser(returningVoidLiteralTypeAnnotation) and in theTypeScriptPArser(returningTSUndefinedKeyword). Replace them in andparsers/typescript/components/events.js. -
[Codegen 112 - Depends on 110 and 111 - assigned to @kyawthura-gg] - Extract the content of theCommit ccd191d79ifbranches that handle the EventHandlers (Flow, TypeScript) into ahandleEventHandlerfunction inparsers-commons.js. This will take a name, a typeAnnotation, a parser and afindEventArgumentsAndTypefunction as parameters. Use the switch based approach from TypeScript. -
[Codegen 113 - assigned to @Shubham1429] Add a functionCommit ec66f2eisOptionalProperty(property)in the Parser object and implement it in FlowParser and TypeScriptParser, using the implementation you can find in theparsers/flow/components/events.jsandparsers/typescript/components/events.js. Use the parsers in thebuildPropertiesForEvent. -
[Codegen 114 - Assigned to @MaeIg] Add a functionCommit (663a018)[https://github.com/facebook/react-native/commit/663a0187094b12d423742e65523c20e778925973]getTypeAnnotationFromProperty(property)in the Parser object and implement it in FlowParser and TypeScriptParser, using the implementation you can find in theparsers/flow/components/events.jsandparsers/typescript/components/events.js. Use the parsers in thebuildPropertiesForEvent. -
[Codegen 116 - assigned to @siddarthkay] Extract theCommit d46f92cgetEventArgumentfunction fromFlowandTypeScriptin agetEventArgumentfunction inparsers-commons.js. -
[Codegen 117 - assigned to @AntoineDoubovetzky] Extract the code that throws if argumentProps are null in aCommit f05252athrowIfArgumentPropsAreNullfunction in theerror-utils.jsfile. Use it in theflow/components/events.jsand in thetypescript/components/event.jsfiles -
[Codegen 118 - Assigned to @tarunrajput] Extract the code that throws if argumentProps are null in aCommit 8494707throwIfBubblingTypeisNullfunction in theerror-utils.jsfile. Use it in theflow/components/events.jsand in thetypescript/components/event.jsfiles -
[Codegen 119 - Depends on 117, 118 - Assigned to @siddarthkay] Extract the content of theCommit 1d87279if (bubblingType && argumentProps) {fromFlowand the content of theelsebranch fromTypeScriptin a 'emitBuildEventSchema' function inparsers-commons. Use the new function in the call site. Refactor the callsite so that there are noif-elseas, at this point, we know thatbubblingTypeandargumentPropsare not null. -
[Codegen 120 - Assigned to @Pranav-yadav] Extract theCommit e240879findComponentConfigfrom Flow and TypeScript from theindex.js's files to theparser-commons.jsfile. -
[Codegen 121 - Depends on Codegen 107 - Assigned to @Shubham1429] Extract the code that checks whetherCommit 66f4a91typeAlias.typeis anInterfaceDeclaration(Flow, TypeScript) into athrowIfTypeAliasIsNotIntefaceerror. Create this new function in theerror-utils.jsfile. -
[Codegen 122 - Depends on 121 - Assigned to @Shubham1429] Extract theCommit (34c1923)[https://github.com/facebook/react-native/commit/34c19232d36190650a7d2d1596ac4f9d4a725777]buildCommandPropertiesfunction (Flow, TypeScript) from theindex.js's files to theparsers-commons.jsfile. -
[Codegen 123 - Assigned to @frankcalise] Create a functionCommit 66f4a91emitBoolProp(name: string, optional: boolean)inparser-primitives.js. Factor out the code from Flow and TypeScript into that function. Use that function in the original call site. -
[Codegen 124 - Assigned to @cloudpresser] Create a functionCommit 7062398emitStringProp(name: string, optional: boolean)inparser-primitives.js. Factor out the code from Flow and TypeScript into that function. Use that function in the original call site. -
[Codegen 125 - Assigend to @ahmadao2214] Create a functionCommit (52154e5)[https://github.com/facebook/react-native/commit/52154e54a29f0fc0e5dd73102bd384298a3ce460]emitInt32Prop(name: string, optional: boolean)inparser-primitives.js. Factor out the code from Flow and TypeScript into that function. Use that function in the original call site. -
[Codegen 126 - Assigned to @rota-rossi] Create a functionCommit 8ca085cemitDoubleProp(name: string, optional: boolean)inparser-primitives.js. Factor out the code from Flow and TypeScript into that function. Use that function in the original call site. -
[Codegen 127 - Assigned to @foestauf] Create a functionCommit 1a1e399emitFloatProp(name: string, optional: boolean)inparser-primitives.js. Factor out the code from Flow and TypeScript into that function. Use that function in the original call site. -
[Codegen 128 - Assigned to @gabrieldonadel] Create aCommit b5f5221getObjectProperties(typeAnnotation)function inParser.jswhich returns the properties of an object represented by a type annotation. Use this code for Flow and this code for TypeScript. Useparser.getObjectProperties(typeAnnotation)instead of the language specific to map the object properties -
[Codegen 129 - Depends on 128 - Assigned to @tarunrajput] Create a functionCommit 202b965emitObjectProp(name: string, optional: boolean)inparser-primitives.js. Factor out the code from Flow and TypeScript into that function. Use that function in the original call site. -
[Codegen 130 - assigned to @Zwem ] Create aCommit 6d5be26getLiteralValue(option)function inParser.jswhich returns the literal value of an union represented, given an option. Use this code for Flow and this code for TypeScript. Useparser.getObjectProperties(typeAnnotation)instead of the language specific to map the object properties -
[Codegen 131 - Depends on 130 - assigned to @Zwem] Create a function5eaf28bemitUnionProp(name: string, optional: boolean)inparser-primitives.js. Factor out the code from Flow and TypeScript into that function. Use that function in the original call site. -
[Codegen 132 - Assigned to @siddarthkay] Create a functionCommit (a497882)[https://github.com/facebook/react-native/commit/a4978823841177ff70959e28ed8343b78fb14c20]emitMixedProp(name: string, optional: boolean)inparser-primitives.js. Factor out the code from Flow and TypeScript into that function. Use that function in the original call site. -
[Codegen 133 - Assigned to @Randall71] Create anCommit 67eb494extractTypeFromTypeAnnotation(typeAnnotation)function in the Parser base class. Implement it using this code for Flow and this code for TypeScript. Replace the invocation of that function with the one from the parser -
[Codegen 134 - Assigned to @cloudpresser] Create a functionCommit e22d1a1getTypeAnnotationName(typeAnnotation)in the Parser base class. Implement it using this code for Flow and this code for Typescript. Replace the callsites with the new function. -
[Codegen 135 - assigned to @siddarthkay] Create a function8bcfc49getPaperTopLevelNameDeprecated(typeAnnotation)in the Parser base class. Implement it using this code for Flow and this code for Typescript. Replace the callsites with the new function. -
[Codegen 137 - Assigned to @tarunrajput] ExtractCommit 942bd61buildPropertiesForEventintoparsers-commons.jsfile. Use the code from either Flow or TypeScript which now should be equal. Delete the original ones and use the newly created method instead of those. -
[Codegen 138 - Assigned to @siddarthkay] Add aCommit e73c00f576getPropertiesfunction to the Parser base class. Move the Flow code to the FlowParser and the TypeScript code to the TypeScriptParser. Use theparser.getPropertiesfunction in place of the original one. -
[Codegen 139 - Assigned to @branaust] Move theCommit a108dcbverifyProprsNotAlreadyDefinedfunctions from Flow and [from TypeScript(https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js#LL486-L495)] to theparsers-commons.jsfile. Use the new function in place of the others.