☂️ Improving Codegen
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.
- [x] ~Extract the
error.jsfile from the flow and typescript folders into anerror.jsfile in their parent folder. Then, have the two parsers use the sameParserErrorAssigned to @gabrieldonadel~ Commit 7227bde - [x] ~Extract the
modules/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~ Commit 35556db - [x] ~Extract the
modules/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~ Commit 24efebf - [x] ~[Assigned to @matiassalles99] Extract the
UnsupportedArrayElementTypeAnnotationParserErrorin its own throwing function and reuse that function passing a proper type. The error is thrown at lines132,141and150in both Flow and TypeScript parsers.~- [x] ~Refactor the code using a dictionary and avoiding the three different
ifs in the Flow parser~ - [x] ~Refactor the code using a dictionary and avoiding the three different
ifs in the TS parser~ Commit cc311ff
- [x] ~Refactor the code using a dictionary and avoiding the three different
- [x] ~[Assigned to @dhruvtailor7]Extract the
UnsupportedObjectPropertyValueTypeAnnotationParserErrorin its own throwing function and reuse that function passing a proper type. The error is thrown at lines281,290and299in both Flow and TypeScript parsers.~- [x] ~Refactor the code using a dictionary and avoiding the three different
ifs in the Flow parser~ - [x] ~Refactor the code using a dictionary and avoiding the three different
ifs in the TS parser~ Commit aba6be6
- [x] ~Refactor the code using a dictionary and avoiding the three different
- [x] ~Extract all the errors in the
flow/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~ Commit 7b345bc - [x] 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:- [x] ~[Assigned to @gabrieldonadel ]
InterfaceNotFound~ Commit c9338c4 - [x] ~[Assigned to @Marcoo09 ]
MoreThanOneModule~ Commit f628edc - [x] ~[Assigned to @mohitcharkha]
MisnamedModuleFlowInterfaceParserError~ Commit 9fb3700 - [x] ~[Assigned to @vinayharwani13]
UnusedModuleFlowInterfaceParserError~ Commit a33f672 - [x] ~[Assigned to @mohitcharkha]
MoreThanOneModuleRegistryCallsParserError~ Commit ab22e3a - [x] ~[Assigned to @dakshbhardwaj]
IncorrectModuleRegistryCallArityParserError~ Commit 76c5b6f - [x] ~[Assigned to @mdaj06]
IncorrectModuleRegistryCallArgumentTypeParserError~ Commit bb519ec - [x] ~[Assigned to @dhruvtailor7]
UntypedModuleRegistryCallParserError~ Commit 1e15e21 - [x] ~[Assigned to @harshsiri110]
IncorrectModuleRegistryCallTypeParameterParserError~ Commit bb519ec
- [x] ~[Assigned to @gabrieldonadel ]
- [x] ~[Assigned to @ZihanChen-MSFT] Support intersection of object types,
{...a, ...b, ...}in Flow is equivalent toa & b & {...}in TypeScript, the order and the form is not important.~ Commit 813fd04 - [x] [Assigned to @ZihanChen-MSFT] Refactor the code using flattenProperties and its implementation is duplicated, it will become obvious after adding intersection type.
- [x] [Assigned to @ZihanChen-MSFT] Automatically converting
CodegenSchema.jstoCodegenSchema.d.ts, and add type descriptions for exposed functions. - [X] [Assigned to @ZihanChen-MSFT] In
CodegenSchema.jscomponent property types are better to be defined in recursion, not to repeat everything in Array again. - [x] ~[Assigned to @AntoineDoubovetzky] Extract the function
assertGenericTypeAnnotationHasExactlyOneTypeParameter(Flow TypeScript) into a single function in theparsers-common.jsfile and replace its invocation with this new function.~ Commit 790f40c - [x] ~Extract the content of the case 'RootTag' (Flow, TypeScript) into a single
emitRootTagfunction in theparsers-primitives.jsfile. Use the new function in the parsers. Assigned to @MaeIg~ Commit 5f05b07 - [x] ~Extract the content of the case 'Promise' (Flow, TypeScript) into a single
emitPromisefunction in theparsers-primitives.jsfile. Use the new function in the parsers.
Assigned to @AntoineDoubovetzky~ Commit 966f3cd - [x] ~[Assigned to @gabrieldonadel] Extract the content of the case 'Stringish' (Flow, TypeScript) into a single
emitStringishfunction in theparsers-primitives.jsfile. Use the new function in the parsers.~ Commit 305f7c3 - [X] ~Extract the content of the case 'Int32' (Flow, TypeScript) into a single
emitInt32function in theparsers-primitives.jsfile. Use the new function in the parsers. Assigned to @Naturalclar~ Commit db8c11d - [x] ~[Assigned to @AntoineDoubovetzky]Extract the content of the case 'Double' (Flow, TypeScript) into a single
emitDoublefunction in theparsers-primitives.jsfile. Use the new function in the parsers.~ Commit 3ab7ef2 - [x] ~[Assigned to @gabrieldonadel]Extract the content of the case 'Float' (Flow, TypeScript) into a single
emitFloatfunction in theparsers-primitives.jsfile. Use the new function in the parsers.~ Commit: 87d6580 - [X] ~[Assigned to @Marcoo09] Extract the content of the case 'Object' (Flow, TypeScript) into a single
emitObjectfunction in theparsers-primitives.jsfile. Use the new function in the parsers.~ Commit fd4451e - [x] ~[Assigned to @MaeIg] Wrap the TypeAlias resolution lines (Flow, TypeScript) in a proper
typeAliasResolutionfunction in theparsers-primitives.jsfiles and replace those lines with the new function.~ - [x] ~[Assigned to @tarunrajput] Extract the content of the case 'BooleanTypeAnnotation' (Flow, TypeScript) into a single
emitBooleanfunction in theparsers-primitives.jsfile. Use the new function in the parsers.~ Commit 7a2e346 - [x] ~[Assigned to @youedd] Extract the content of the case 'NumberTypeAnnotation' (Flow, TypeScript) into a single
emitNumberfunction in theparsers-primitives.jsfile. Use the new function in the parsers.~ Commit 54fc62c - [x] ~[Assigned to @youedd] Extract the content of the case 'VoidTypeAnnotation' (Flow, TypeScript) into a single
emitVoidfunction in theparsers-primitives.jsfile. Use the new function in the parsers.~ Commit b3219fe - [X] ~[Assigned to @ken0nek]Extract the content of the case 'StringTypeAnnotation' (Flow, TypeScript) into a single
emitStringfunction in theparsers-primitives.jsfile. Use the new function in the parsers.~ Commit eda90e5 - [x] ~[Assigned to @mohitcharkha] Extract the content of the case 'FunctionTypeAnnotation' (Flow, TypeScript) into a single
emitFunctionfunction in theparsers-primitives.jsfile. Use the new function in the parsers.~ Commit c403cd4 - [x] ~[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
- [x] ~[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
- [x] ~[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
- [x] ~[Assigned to @dhruvtailor7] This task is more advanced than the others and a 2-steps tasks. First, extract the
visitorobject 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.~ - [x] ~[Assigned to @MaeIg] This task is more advanced than the others. Extract the
switch(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.~ Commit 8f484c3 - [x] ~[Assigned to @gabrieldonadel] Export
parseFile(Flow, TypeScript) in to aparseFilefunction inparsers/utils.js. Note that the function should accept a callback tobuildSchemaproperly.~ Commit 376ffac - [x] ~[Assigned to @vinayharwani13] This task is much simple than the others, it just moves a type and there is no logic. Export the
TypeDeclarationMaptype (Flow, TypeScript) into a single type in theparsers/utils.jsfile.~ Commit 2934399 - [x] ~[Assigned to @dakshbhardwaj] Extract the
nullGuardfunction (Flow, TypeScript) into a function in theparsers-utils.jsfile and use it in the other parsers.~ Commit 1eaa092 - [x] ~[Assigned to @MaeIg] Wrap the content of the
case 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.~ Commit c388e6c - [x] ~[Assigned to @gabrieldonadel] This task is more advanced than the others Create a function to unify the
default: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.~ Commit ea55e3b - [x] ~[Assigned to @youedd] This task is more advanced than the others Create a function to unify the
unionTypeand 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.~ Commit 0627cd6 - [x] ~[Assigned to @tarunrajput] Create a function
emitMixedTypeAnnotationinto theparsers-commons.jsfile to put together this code from Flow and TypeScript.~ Commit b87d371 - [x] ~[Assigned to @harshsiri110] Extract the logic that throw the
UnsupportedFunctionReturnTypeAnnotationParserError(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.~ Commit 3247436 - [x] ~[Assigned to @mohitcharkha] Extract the logic that throws the
UnsupportedModulePropertyParserError(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.~ Commit f645404 - [x] ~[Assigned to @youedd] Extract the
nameToValidatelogic (Flow, TypeScript) into a shared function into theparser/utils.jsfile. Notice that you may need a callback to update the cxx boolean.~ Commit 633498f - [x] ~[Assigned to @ZihanChen-MSFT] Support function signature along with function type properties in commands.~ Commit ae1d54b
- [x] ~[Assigned to @MaeIg] Extract the
parseFilefunction 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.~ Commit 3f2691c - [x] ~[Assigned to @MaeIg] Extract the
buildSchemafunction (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.~ Commit 4628150 - [x] ~[Assigned to @Pranav-yadav ] Note: this task depends on "Extract the
UnsupportedArrayElementTypeAnnotationParserError" Extract the functiontranslateArrayTypeAnnotation(Flow, TypeScript) into a funtion in theparsers-primitives.jsfile.~ Commit 5a20bd5 - [x] ~[Assigned to @gabrieldonadel] Note: This task depends on Extract the function
translateArrayTypeAnnotationExtract the content of thecase Arrayandcase ReadOnlyArray(Flow, Typescript) into anemitArrayTypefunction in theparsers-primitives.jsfile.~ Commit ea9e78d - [x] ~[Assigned to @Pranav-yadav] Extract the content of the
tryParse(Flow, TypeScript)lambda into a properparseObjectPropertyfunction into theparsers-commons.jsfile.~ Commit 5744b21 - [x] ~[Assigned to @AntoineDoubovetzky] Extract the
UnsupportedFunctionParamTypeAnnotationParserError(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.~ Commit 8c69b6cf781bfdf85cbbd7333bc0a0745d61f411 - [x] ~[Assigned to @gabrieldonadel] This task is more complex than the others and it depends on Extract the
UnsupportedFunctionParamTypeAnnotationParserErrorExtract 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.~ Commit 62244d4 - [x] ~[Assigned to @Marcoo09] This task depends on Extract the
translateFunctionTypeAnnotationMove thetranslateFunctionTypeAnnotationinvocation (Flow, TypeScript) into theemitFunctioncall so that thecase FuntionTypeAnnotationresults in a one-liner.~ Commit 64ea7ce - [x] ~[Assigned to @Pranav-yadav] This task depends on Extract the
translateFunctionTypeAnnotationExtract thebuildPropertySchema(Flow TypeScript) into theparsers-commons.jsfile. It has to take the language parameter to extract the value and an additional callback for theresolveTypeAnnotationfunction.~ Commit fb37dea - [X] ~[Codegen_buildModuleSchema - assign to @tarunrajput] Extract the
buildModuleSchemafunction (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.~ Commit 3cd97e4 - [x] ~[Assigned to @Pranav-yadav] Move the
emitMixedTypeAnnotationfunction to theparser-primitives.jsfile.~ Commit 95e685a - [x] ~[Assigned to @AntoineDoubovetzky] Create a new function
typeParameterInstantiationin 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?:.~ Commit 8a847a3 - [X] ~[Assigned to @youedd] Create a new function
remapUnionTypeAnnotationMemberNamesin 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.~ Commit a7ae988 - [x] ~[Assigned to @gabrieldonadel] Create a getKeyName function in the
parser.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.~ Commit f849f49 - [x] ~[Assigned to @AntoineDoubovetzky] Update the
IncorrectlyParameterizedGenericParserErrorerror in theerror.jsfile to accept aParserinstead of aParserTypeparameter. Use thenameForGenericTypeAnnotationmethod of the parser to extract thegenericNameand delete the ternary operator.~ Commit edc4ea0 - [x] ~[Assigned to @tarunrajput] Create a
checkIfInvalidModulefunction 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.~ Commit e97fb46 - [X] ~[Codegen_functionTypeAnnotation - assigned to @gabrieldonadel] Define a
functionTypeAnnotationin 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.~ Commit 43986e8 - [x] ~[Codegen 74 assigned to @AntoineDoubovetzky] Move
getTypesfunctions 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.~ Commit f23f7f4 - [x] ~[Codegen 75 assigned to @gabrieldonadel] Create a
throwIfPartialWithMoreParameterfunction in theerror-utils.jsand extract the error-emitting code from Flow and Typescript index files.~ Commit 5ff8895 - [x] ~[Codegen 76 - assigned to @tarunrajput ] Create a
throwIfPartialNotAnnotatingTypeParameterfunction 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.~ Commit 371e263 - [x] ~[Codegen 77 - assigned to @MaeIg] Extract the functions to compute partial properties from the
index.jsfile (Flow and TypeScript)in the Flow and TypeScript parsers.~ Commit a448c6d - [X] ~[Codegen 78 - Assigned to @Pranav-yadav] It depends on [Codegen 75][Codegen 76][Codegen 77] Extract the logic that emits Partial values in an
emitPartialfunction, which takes the Parsers as parameter.~ Commit 2f25261 - [X] ~[Codegen 79 - Assigned to @Pranav-yadav] It depends on [Codegen 78] Extract the basic
caseslogics (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).~ Commit 2f25261 - [X] ~[Codegen 80 - assigned to @kyawthura-gg] It depends on [Codegen 79] Convert the
emitCommonTypesimplementation from a switch based implementation to a dictionary based one.~ Commit 4a15f90 - [X] ~[Codegen 81 - Assigned to @gabrieldonadel] It depends on [Codegen 80] Expand the
emitcCommonTypesfunction 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.~ Commit 66ae98e - [x] ~[Codegen 82 - assigned to @kyawthura-gg] Move
isModuleInterfacefunction (Flow, TypeScript) to the Flow and TypeScript parsers.~ Commit 85245af - [x] ~[Codegen 83 - assigned to @Pranav-yadav] Create a function
throwIfIncorrectModuleRegistryCallArgumnentfunction in theerror-utils.jsfile and factor together the code from Flow and TypeScript. Update the Parsers to return the right Literl type~ Commit 1362820 - [x] ~[Codegen 84 - assigned to @Pranav-yadav] It depends on [Codegen 83] export the
parseModuleNameanonymous function (Flow, TypeScript) in a commonparseModuleNamefunction in theparsers-commons.jsfile.~ Commit 05454fa - [x] ~[Codegen 85 - assigned to @tarunrajput] The
parses/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.~ Commit 8be9dbf - [x] ~[Codegen 86 - Assigned to @ken0nek] The
buildPropSchemafunction inparsers/typescript/components/props.jsandparsers/flow/components/props.jsis the same. move it inparser-commonsand use it in the origina files.~ Commit 0212179 - [X] ~[Codegen 87 - Assigned to @siddarthkay] Depends on [Codegen 86] Add the
getPropsfunction 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.~ Commit fc927d1 - [x] ~[Codegen 88 - assigned to @tarunrajput] Move the Visitor.js file from
parsers/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.)~ Commit d9f2cbe - [X] ~[Codegen 89 - Assigned to @MaeIg] Remove the
const languagevariable fromflow/modules/index.jsand replace its usage withparser.language()~ Commit 26b22a6 - [X] ~[Codegen 90 - Assigned to @MaeIg] Remove the
const languagevariable fromtypescript/modules/index.jsand replace its usage withparser.language()~ Commit 26b22a6 - [X] ~[Codegen 91 - Assigned to @yux-m] Extract the inner switch in
typescript/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)~ Commit 94f505b - [X] ~[Codegen 92 - assigned to @kyawthura-gg] The
getCommandOptionsfunction 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.~ Commit 221aacd - [X] ~[Codegen 93 - assigned to @tarunrajput] The
getOptionsfunction 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.~ 221aacd - [X] ~[Codegen 94 - assigned to @siddarthkay] The
extendsForPropfunction inparsers/typescript/components/extends.jsandparsers/flow/components/extend.jsis the same. Move it inparser-commonsand use it in the origina files.~ Commit c937162 - [X] ~[Codegen 95 - assigned to @Pranav-yadav] Extract the
defaultExports.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.~ Commit c0a46c696b7365a0b74fc4dbf41e83de24305d7f - [X] ~[Codegen 96 - assigned to @AntoineDoubovetzky] Create a
throwIfConfigNotfoundin theerror-utils.jsfile and extract the error code from Flow and TS~ Commit 8fbcfce - [X] ~[Codegen 97 - assigned to @AntoineDoubovetzky] Create a
throwIfMoreThanOneConfigin theerror-utils.jsfile and extract the error code from Flow and TS~ Commit 8fbcfce - [X] ~[Codegen 98 - assigned to @MaeIg] Extract the
namedExports.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.~ Commit 5ff01bc - [x] ~[Codegen 99 - assigned to @tarunrajput] Extract the
throwIfMoreThanOneCodegenNativecommandserror in theerror-utils.jsfile and extract the error code from Flow and TS~ Commit (347d6f8)[https://github.com/facebook/react-native/commit/347d6f8d899d7a8f5c901611923c9c09039acbdb] - [x] ~[Codegen 100 - assigned to @marcocaldera] Create a
createComponentConfigfunction 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.~ Commit 320e51f - [X] ~[Codegen 101 - assigned to @kyawthura-gg] The code of
getCommandPropertiesis 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.~ Commit 969a8d0 - [X] ~[Codegen 102 - assigned to @Pranav-yadav] Extract the code to compute the
extendsPropsand 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.~ Commit efc6e14 - [x] ~[Codegen 103 - assigned to @gabrieldonadel] Extract the code to compute the
extendsPropsand 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~ Commit e962d43
- [X] ~[Codegen 104 - Assigned to @siddarthkay] Add a
getResolvedTypeAnnotationfunction 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.~ Commit e09d585 - [X] ~[Codegen 105 - Assigned to @tarunrajput] Add a
typeAlias: 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.~ Commit 0de4768 - [X] ~[Codegen 106 - Assigned to @tarunrajput] Add a
enumDeclaration: 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.~ Commit 91c60cb - [X] ~[Codegen 107 - @Shubham1429] Add a
interfaceDeclaration: 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.~ Commit 9301c8f - [X] ~[Codegen 108 - Depends on 105, 106, 107 - Assigned to @tarunrajput] Move the
switchconstruct fromparsers/typescript/utils.jsandparsers/flow/utils.jsto theparsers-commons.jsfile, in ahandleGenericTypeAnnotationfunction. Use that function in place of theswitch.~ Commit (8ffaede05a)[https://github.com/facebook/react-native/commit/8ffaede05a72973805f668e1dda41060ee054dc4] - [x] ~[Codegen 109 - assigned to @tarunrajput] Extract the typeAnnotation doesn't have a name error (
Flow;TypeScript) inthrowIfEventHasNoNamefunction which takes a typeAnnotation and a parser as parameters. Use it in place of the if in the above call sites.~ Commit c65ab4d - [X] ~[Codegen 110 - Assigned to @kyawthura-gg ] Add a
nullLiteralTypeAnnotation: stringproperty into the Parser object and implement it in theFlowParser(returningNullLiteralTypeAnnotation) and in theTypeScriptParser(returningTSNullKeyword). Replace them in theparsers/flow/components/events.jsandparsers/typescript/components/events.js.~ Commit b5c01ee - [X] ~[Codegen 111 - assigned to @Shubham1429] Add an
undefinedLiteralTypeAnnotation: stringproperty into the Parser object and implement it in theFlowParser(returningVoidLiteralTypeAnnotation) and in theTypeScriptPArser(returningTSUndefinedKeyword). Replace them in andparsers/typescript/components/events.js.~ Commit cf8184d - [ ] [Codegen 112 - Depends on 110 and 111 - Assigned to @cloudpresser] - Extract the content of the
ifbranches 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. - [X] ~[Codegen 113 - assigned to @Shubham1429] Add a function
isOptionalProperty(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.~ Commit ec66f2e - [X] ~[Codegen 114 - Assigned to @MaeIg] Add a function
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.~ Commit (663a018709)[https://github.com/facebook/react-native/commit/663a0187094b12d423742e65523c20e778925973] - [x] ~[Codegen 116 - assigned to @siddarthkay] Extract the
getEventArgumentfunction fromFlowandTypeScriptin agetEventArgumentfunction inparsers-commons.js.~ Commit d46f92c - [X] ~[Codegen 117 - assigned to @AntoineDoubovetzky] Extract the code that throws if argumentProps are null in a
throwIfArgumentPropsAreNullfunction in theerror-utils.jsfile. Use it in theflow/components/events.jsand in thetypescript/components/event.jsfiles~ Commit f05252a - [X] ~[Codegen 118 - Assigned to @tarunrajput] Extract the code that throws if argumentProps are null in a
throwIfBubblingTypeisNullfunction in theerror-utils.jsfile. Use it in theflow/components/events.jsand in thetypescript/components/event.jsfiles~ Commit 8494707 - [ ] [Codegen 119 - Depends on 117, 118 - assigned to @AntoineDoubovetzky] Extract the content of the
if (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. - [X] ~[Codegen 120 - Assigned to @Pranav-yadav] Extract the
findComponentConfigfrom Flow and TypeScript from theindex.js's files to theparser-commons.jsfile.~ Commit https://github.com/facebook/react-native/commit/e2408790577064c2f4977ed35bf64cb593a730d7 - [X] ~[Codegen 121 - Depends on Codegen 107 - Assigned to @Shubham1429] Extract the code that checks whether
typeAlias.typeis anInterfaceDeclaration(Flow, TypeScript) into athrowIfTypeAliasIsNotIntefaceerror. Create this new function in theerror-utils.jsfile.~ Commit 66f4a91 - [X] ~[Codegen 122 - Depends on 121 - Assigned to @Shubham1429] Extract the
buildCommandPropertiesfunction (Flow, TypeScript) from theindex.js's files to theparsers-commons.jsfile.~ Commit (34c19232d3)[https://github.com/facebook/react-native/commit/34c19232d36190650a7d2d1596ac4f9d4a725777] - [X] ~[Codegen 123 - Assigned to @frankcalise] Create a function
emitBoolProp(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.~ Commit https://github.com/facebook/react-native/commit/66f4a9168bcbf45d1f2f026ac2613c388ba2c3dc - [X] ~[Codegen 124 - Assigned to @cloudpresser] Create a function
emitStringProp(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.~ Commit 7062398 - [X] ~[Codegen 125 - Assigend to @ahmadao2214] Create a function
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.~ Commit (52154e54a2)[https://github.com/facebook/react-native/commit/52154e54a29f0fc0e5dd73102bd384298a3ce460] - [X] ~[Codegen 126 - Assigned to @rota-rossi] Create a function
emitDoubleProp(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.~ Commit 8ca085c - [X] ~[Codegen 127 - Assigned to @foestauf] Create a function
emitFloatProp(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.~ Commit 1a1e399 - [x] ~[Codegen 128 - Assigned to @gabrieldonadel] Create a
getObjectProperties(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~ Commit b5f5221 - [X] ~[Codegen 129 - Depends on 128 - Assigned to @tarunrajput] Create a function
emitObjectProp(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.~ Commit 202b965 - [ ] [Codegen 130 - Assigned to @harisbaig100] Create a
getLiteralValue(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 @ankit-tailor] Create a function
emitUnionProp(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. - [X] ~[Codegen 132 - Assigned to @siddarthkay] Create a function
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.~ Commit (a497882384)[https://github.com/facebook/react-native/commit/a4978823841177ff70959e28ed8343b78fb14c20] - [X] ~[Codegen 133 - Assigned to @Randall71] Create an
extractTypeFromTypeAnnotation(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~ Commit 67eb494 - [ ] [Codegen 134 - Assigned to @cloudpresser] Create a function
getTypeAnnotationName(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 @rota-rossi] Create a function
getPaperTopLevelNameDeprecated(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. - [X] ~[Codegen 137 - Assigned to @tarunrajput] Extract
buildPropertiesForEventintoparsers-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.~ Commit 942bd61 - [X] ~[Codegen 138 - Assigned to @siddarthkay] Add a
getPropertiesfunction 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.~ Commit (e73c00f576)[https://github.com/facebook/react-native/commit/e73c00f57631cf19787e95906d38616be92ab3c0] - [ ] [Codegen 139 - Assigned to @branaust] Move the
verifyProprsNotAlreadyDefinedfunctions 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.
Hi @cipolleschi I would like to help with the Extract the error.js file from the flow and typescript folders into an error.js file in their parent folder. Then, have the two parsers use the same ParserError task
Hey @cipolleschi I'd like to work on following task:
Extract the modules/schema.js from the flow and typescript folders in a shared parsers-commons.js file. Then, have the two parsers use the same wrapModuleSchema function for modules.
Hey @cipolleschi, thank you for this umbrella issue! I'd like to pick the third one:
Extract the modules/utils.js from the flow and typescript folders in a shared parsers-commons.js file. Then, have the two parsers use the same wrapModuleSchema function for modules.
Hi @cipolleschi, I would like to try helping with this task:
Extract the UnsupportedArrayElementTypeAnnotationParserError in its own throwing function and reuse that function passing a proper type. The error is thrown at lines 132, 141 and 150 in both Flow and TypeScript parsers.
Sounds like a good place to log what I am going to do next for the TypeScript part:
ToDo
- Automatically converting
CodegenSchema.jstoCodegenSchema.d.ts, and add type descriptions for exposed functions.
Done
- ~~Refactor: In component, props and events pick properties from the component interface by themselves independently, I would like to reverse the direction, to have a function dispatching properties to props and events, to reduce duplicated code.~~
- https://github.com/facebook/react-native/pull/34975
- ~~Support intersection of object types,
{...a, ...b, ...}in Flow is equivalent toa & b & {...}in TypeScript, the order and the form is not important.~~- https://github.com/facebook/react-native/pull/35247
- ~~Refactor: the code using
flattenPropertiesand its implementation is duplicated, it will become obvious after adding intersection type.~~- N/A
- ~~Support function signature along with function type properties in commands~~
- https://github.com/facebook/react-native/pull/35311
- ~~Add
TinPromise<T>inCodegenSchema.js~~- https://github.com/facebook/react-native/pull/35345
- ~~Fix output from
{[key:T]:U}~~- https://github.com/facebook/react-native/pull/35344
- ~~Add interface supports in TypeScript module.~~
- https://github.com/facebook/react-native/pull/35812 (not fully addressed)
- https://github.com/facebook/react-native/pull/36011 (addressed)
- ~~Add intersection type supports in TypeScript module.~~
- https://github.com/facebook/react-native/pull/36037
- ~~Add generated
CodegenSchema.d.tsand other files to the package.~~- https://github.com/facebook/react-native/pull/36102
And eventually, since codegen parses TypeScript and Flow using babel, it is no reason to implement them separately. In order to do that, I will try to refactor the TypeScript part and make it more generalized, to be ready to accept Flow AST in a low effort.
Hi @cipolleschi. I would like to work on the following task.
Extract the UnsupportedObjectPropertyValueTypeAnnotationParserError in its own throwing function and reuse that function passing a proper type. The error is thrown at lines 281, 290 and 299 in both Flow and TypeScript parsers.
Hi @cipolleschi. I would like to pick this one too: Extract all the errors in the flow/module/errors.js and in the typescript/module/errors.js into a single parser/errors.js file. All the errors must drop the corresponding Flow or Typescript token in the name and take an extra language parameter in the constructor. Also, rename the hasteModuleName parameter to nativeModuleName
Hi @cipolleschi I would like to help with the task below as well
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:
- [ ]
InterfaceNotFound
@gabrieldonadel these are supposed to be a different task for each error. The logic to decide whether to throw each error is slightly different from each other. Is it ok if we start with the first one?
@gabrieldonadel these are supposed to be a different task for each error. The logic to decide whether to throw each error is slightly different from each other. Is it ok if we start with the first one?
Ohh sorry @cipolleschi , I didn't notice that each of these was one task, can I have the InterfaceNotFound task then?
Hi @cipolleschi I would like to help with the following task:
[ ] 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:
- [ ]
MoreThanOneModule
Hi @cipolleschi, I would like to work on the following task
Extract each individual exception to a separate function inside an error-utils.js file. 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 the buildModuleSchema function (Flow, Typescript) The list of exceptions to handle is:
- [ ] MisnamedModuleFlowInterfaceParserError
Hi @cipolleschi, I would like to take this up
Extract each individual exception to a separate function inside an error-utils.js file. 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 the buildModuleSchema function (Flow, Typescript) The list of exceptions to handle is:
- [ ] UnusedModuleFlowInterfaceParserError
Hi @cipolleschi, I would like to work on the following task
Extract each individual exception to a separate function inside an error-utils.js file. 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 the buildModuleSchema function (Flow, Typescript) The list of exceptions to handle is:
- [ ] MoreThanOneModuleRegistryCallsParserError
Hi @cipolleschi, I would like to work on the following task
Extract each individual exception to a separate function inside an error-utils.js file. 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 the buildModuleSchema function (Flow, Typescript) The list of exceptions to handle is:
- [ ] IncorrectModuleRegistryCallArityParserError
Hi @cipolleschi I would like to take the following issue:
IncorrectModuleRegistryCallArgumentTypeParserError
Hi @mohitcharkha! before taking another task, please open a PR on the one already assigned. You are currently assigned to fixing the MisnamedModuleFlowInterfaceParserError. Thanks a lot!
Small update: given the interest the initiative is having, I added some more tasks for people to pick up. :tada: :tada:
Thank you to every one of you for the amazing work! 😄
Hello @cipolleschi! I'd like to work on the following issue:
Extract the function assertGenericTypeAnnotationHasExactlyOneTypeParameter (Flow TypeScript) into a single function in the parsers-common.js file and replace its invocation with this new function.
edit: seems like this pr needs to be merged first: https://github.com/facebook/react-native/pull/34896
Hello @cipolleschi, this umbrella issue is awesome !
I would like to work on the following task:
Extract the content of the case 'RootTag' (Flow TypeScript) into a single emitRootTag function in the parsers-primitives.js file. Use the new function in the parsers.
Hi! I opened a PR for the task I am assigned to, and now I'd like to work on:
Extract the content of the case 'Promise' into a single emitPromise function in the parsers-primitives.js file. Use the new function in the parsers.
Hi @cipolleschi, I finished my previous task. Now, I'd like to work on:
Wrap the TypeAlias resolution lines (Flow, TypeScript) in a proper typeAliasResolution function in the parsers-primitives.js files and replace those lines with the new function.
I'd like to work on:
Extract the content of the case 'Int32' (Flow, TypeScript) into a single emitInt32 function in the parsers-primitives.js file. Use the new function in the parsers.
Hi @cipolleschi, I would like to complete this task. Thanks!
Extract the content of the case 'Float' (Flow, TypeScript) into a single emitFloat function in the parsers-primitives.js file. Use the new function in the parsers.
Hi @cipolleschi, I'd like to work on this task next:
Extract the content of the case 'BooleanTypeAnnotation' (Flow, TypeScript) into a single emitBoolean function in the parsers-primitives.js file. Use the new function in the parsers.
Hi @cipolleschi, I'd like to help with this task. Thanks!
Extract the content of the case 'NumberTypeAnnotation' (Flow, TypeScript) into a single emitNumber function in the parsers-primitives.js file. Use the new function in the parsers.
Hi! I opened a PR for the task I am assigned to, and now I'd like to work on:
Extract the content of the case 'Promise' into a single emitPromise function in the parsers-primitives.js file. Use the new function in the parsers.
@cipolleschi I believe that the 'Promise' case depends on assertGenericTypeAnnotationHasExactlyOneTypeParameter being extracted which depends on https://github.com/facebook/react-native/pull/34896.
In the meanwhile I'll work
Extract the content of the case 'Double' into a single emitDouble function in the parsers-primitives.js file. Use the new function in the parsers.
@cipolleschi, I would like to help with this task too
Extract the content of the case 'VoidTypeAnnotation' (Flow, TypeScript) into a single emitVoid function in the parsers-primitives.js file. Use the new function in the parsers.
Thanks!
I'm not entirely sure what's the target for this task:
Extract each individual exception to a separate function inside an error-utils.js file. 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.
What I understand: the goal is to create functions like checkIsInterfaceFound, checkIsMoreThanOneModule, checkIsModuleMisnamed that check and throw an error if necessary and then use them in buildModuleSchema so it would look like:
function buildModuleSchema(...) {
checkIsInterfaceFound(...);
checkIsMoreThanOneModule(...);
checkIsModuleMisnamed(...);
{...}
}
Is that right?
@cipolleschi Hi, I would like to help with these unassigned tasks; StringTypeAnnotation and FunctionTypeAnnotation 💡