Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Codegen 77] Extract the functions to compute partial properties in the Flow and TypeScript parsers. #36373

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(codegen): use the new computePartialProperties method
  • Loading branch information
MaeIg committed Mar 6, 2023
commit f1994ff71d910abe639aa07636b5df58ebef3cff
25 changes: 9 additions & 16 deletions packages/react-native-codegen/src/parsers/flow/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,15 @@ function translateTypeAnnotation(
parser,
);

const properties = annotatedElement.right.properties.map(prop => {
return {
name: prop.key.name,
optional: true,
typeAnnotation: translateTypeAnnotation(
hasteModuleName,
prop.value,
types,
aliasMap,
enumMap,
tryParse,
cxxOnly,
parser,
),
};
});
const properties = parser.computePartialProperties(
annotatedElement.right.properties,
hasteModuleName,
types,
aliasMap,
enumMap,
tryParse,
cxxOnly,
);

return emitObject(nullable, properties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,14 @@ function translateTypeAnnotation(
parser,
);

const properties = annotatedElement.typeAnnotation.members.map(
member => {
return {
name: member.key.name,
optional: true,
typeAnnotation: translateTypeAnnotation(
hasteModuleName,
member.typeAnnotation.typeAnnotation,
types,
aliasMap,
enumMap,
tryParse,
cxxOnly,
parser,
),
};
},
const properties = parser.computePartialProperties(
annotatedElement.typeAnnotation.members,
hasteModuleName,
types,
aliasMap,
enumMap,
tryParse,
cxxOnly,
);

return emitObject(nullable, properties);
Expand Down