diff --git a/packages/react-native/React/Base/RCTBridgeModule.h b/packages/react-native/React/Base/RCTBridgeModule.h index e2cac1687abb..a9eaf3c3ca75 100644 --- a/packages/react-native/React/Base/RCTBridgeModule.h +++ b/packages/react-native/React/Base/RCTBridgeModule.h @@ -76,10 +76,25 @@ RCT_EXTERN_C_END // With both legacy interop layers removed, RCTRegisterModule is compiled out, so // static module registration is a no-op: only the JS module name is emitted. -#define RCT_EXPORT_MODULE(js_name) \ - +(NSString *)moduleName \ - { \ - return @ #js_name; \ +#ifdef __cplusplus +#define _RCT_ASSERT_EXPORTED_MODULE_IS_TURBO_MODULE() \ + static_assert( \ + __is_convertible_to(__typeof__([self alloc]), id), \ + "Without the legacy module interop, only RCTTurboModule classes are created: conform this module " \ + "to RCTTurboModule (or its codegen spec) and implement getTurboModule:") +#else +#define _RCT_ASSERT_EXPORTED_MODULE_IS_TURBO_MODULE() \ + _Static_assert( \ + 0, \ + "Without the legacy module interop, only RCTTurboModule classes are created, which needs Objective-C++: " \ + "rename this file to .mm and conform the module to RCTTurboModule") +#endif + +#define RCT_EXPORT_MODULE(js_name) \ + +(NSString *)moduleName \ + { \ + _RCT_ASSERT_EXPORTED_MODULE_IS_TURBO_MODULE(); \ + return @ #js_name; \ } #else diff --git a/packages/react-native/React/CoreModules/RCTActionSheetManager.mm b/packages/react-native/React/CoreModules/RCTActionSheetManager.mm index d615eca6e8a3..8a58c410ad82 100644 --- a/packages/react-native/React/CoreModules/RCTActionSheetManager.mm +++ b/packages/react-native/React/CoreModules/RCTActionSheetManager.mm @@ -317,6 +317,9 @@ - (void)showShareActionSheetWithOptions: using namespace facebook::react; +@interface RCTActionSheetManager () +@end + @implementation RCTActionSheetManager RCT_EXPORT_MODULE()