Skip to content

Commit 024ce5d

Browse files
osdnkfacebook-github-bot
authored andcommitted
Change type of params in methods' protocols to nongeneric
Summary: It was mistake which I fix here. Type of param in protocols should be generated struct. See generated struct in snap. It's exactly how it was in previous codegen Reviewed By: RSNara Differential Revision: D16770579 fbshipit-source-id: dac9c15c5d91a41ab2d06aea416f64bd7deb4476
1 parent d3c30cd commit 024ce5d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

packages/react-native-codegen/src/generators/modules/GenerateModuleHObjCpp.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,26 +182,30 @@ module.exports = {
182182
.map(prop => {
183183
const nativeArgs = prop.typeAnnotation.params
184184
.map((param, i) => {
185+
let paramObjCType;
185186
if (
186187
param.typeAnnotation.type === 'ObjectTypeAnnotation' &&
187188
param.typeAnnotation.properties
188189
) {
190+
const variableName =
191+
capitalizeFirstLetter(prop.name) +
192+
capitalizeFirstLetter(param.name);
189193
objectForGeneratingStructs.push({
190-
name:
191-
capitalizeFirstLetter(prop.name) +
192-
capitalizeFirstLetter(param.name),
194+
name: variableName,
193195
object: {
194196
type: 'ObjectTypeAnnotation',
195197
properties: param.typeAnnotation.properties,
196198
},
197199
});
200+
paramObjCType = `JS::Native::_MODULE_NAME_::::Spec${variableName}&`;
201+
} else {
202+
paramObjCType = translatePrimitiveJSTypeToObjCType(
203+
param,
204+
`Unspopported type for param "${param.name}" in ${
205+
prop.name
206+
}. Found: ${param.typeAnnotation.type}`,
207+
);
198208
}
199-
const paramObjCType = translatePrimitiveJSTypeToObjCType(
200-
param,
201-
`Unspopported type for param "${param.name}" in ${
202-
prop.name
203-
}. Found: ${param.typeAnnotation.type}`,
204-
);
205209
return `${i === 0 ? '' : param.name}:(${paramObjCType})${
206210
param.name
207211
}`;

packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ inline NSString *JS::NativeSampleTurboModule::SpecDifficultAE::F() const
149149
150150
151151
@protocol NativeSampleTurboModuleSpec <RCTBridgeModule, RCTTurboModule>
152-
- (NSDictionary *) difficult:(NSDictionary *)A;
152+
- (NSDictionary *) difficult:(JS::NativeSampleTurboModule::SpecDifficultA&)A;
153153
@end
154154
155155

0 commit comments

Comments
 (0)