Skip to content

Commit 9f0d24b

Browse files
Enforce void return type for void return type in JS C++ TM spec (#53214)
Summary: Pull Request resolved: #53214 Changelog: [General] [Fixed] Enforce void return type for void return type in JS C++ TM spec Example if you have this spec ``` export interface Spec extends TurboModule { +foo: (bar: string) => void; } ``` We must enforce in C++ that the return type is `void` as e.g. ``` void foo(jsi::Runtime& rt, const std::string& bar); ``` Right now you can return any type in C++ such as `std::string` which does not make sense Reviewed By: lenaic Differential Revision: D79980538 fbshipit-source-id: 9b99ea6b1ac97d1e46cdb9952e83c445ec5503b7
1 parent 9f77d42 commit 9f0d24b

File tree

1 file changed

+5
-0
lines changed
  • packages/react-native/ReactCommon/react/bridging

1 file changed

+5
-0
lines changed

packages/react-native/ReactCommon/react/bridging/Class.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ JSReturnT callFromJs(
2727
sizeof...(ArgsT) == sizeof...(JSArgsT), "Incorrect arguments length");
2828
static_assert(
2929
(supportsFromJs<ArgsT, JSArgsT> && ...), "Incompatible arguments");
30+
if constexpr (std::is_void_v<JSReturnT>) {
31+
static_assert(
32+
std::is_void_v<ReturnT>,
33+
"Method must return void when JSReturnT is void");
34+
}
3035

3136
if constexpr (std::is_void_v<JSReturnT>) {
3237
(instance->*method)(

0 commit comments

Comments
 (0)