Skip to content

Commit ba9e359

Browse files
committed
refactor(codegen): use the new computePartialProperties method
1 parent 4194cfd commit ba9e359

File tree

2 files changed

+17
-33
lines changed
  • packages/react-native-codegen/src/parsers

2 files changed

+17
-33
lines changed

packages/react-native-codegen/src/parsers/flow/modules/index.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,22 +172,15 @@ function translateTypeAnnotation(
172172
parser,
173173
);
174174

175-
const properties = annotatedElement.right.properties.map(prop => {
176-
return {
177-
name: prop.key.name,
178-
optional: true,
179-
typeAnnotation: translateTypeAnnotation(
180-
hasteModuleName,
181-
prop.value,
182-
types,
183-
aliasMap,
184-
enumMap,
185-
tryParse,
186-
cxxOnly,
187-
parser,
188-
),
189-
};
190-
});
175+
const properties = parser.computePartialProperties(
176+
annotatedElement.right.properties,
177+
hasteModuleName,
178+
types,
179+
aliasMap,
180+
enumMap,
181+
tryParse,
182+
cxxOnly,
183+
);
191184

192185
return emitObject(nullable, properties);
193186
}

packages/react-native-codegen/src/parsers/typescript/modules/index.js

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -253,23 +253,14 @@ function translateTypeAnnotation(
253253
parser,
254254
);
255255

256-
const properties = annotatedElement.typeAnnotation.members.map(
257-
member => {
258-
return {
259-
name: member.key.name,
260-
optional: true,
261-
typeAnnotation: translateTypeAnnotation(
262-
hasteModuleName,
263-
member.typeAnnotation.typeAnnotation,
264-
types,
265-
aliasMap,
266-
enumMap,
267-
tryParse,
268-
cxxOnly,
269-
parser,
270-
),
271-
};
272-
},
256+
const properties = parser.computePartialProperties(
257+
annotatedElement.typeAnnotation.members,
258+
hasteModuleName,
259+
types,
260+
aliasMap,
261+
enumMap,
262+
tryParse,
263+
cxxOnly,
273264
);
274265

275266
return emitObject(nullable, properties);

0 commit comments

Comments
 (0)