mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Enforce void return type for void return type in JS C++ TM spec (#53214)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9f77d421bb
commit
9f0d24bb05
@@ -27,6 +27,11 @@ JSReturnT callFromJs(
|
||||
sizeof...(ArgsT) == sizeof...(JSArgsT), "Incorrect arguments length");
|
||||
static_assert(
|
||||
(supportsFromJs<ArgsT, JSArgsT> && ...), "Incompatible arguments");
|
||||
if constexpr (std::is_void_v<JSReturnT>) {
|
||||
static_assert(
|
||||
std::is_void_v<ReturnT>,
|
||||
"Method must return void when JSReturnT is void");
|
||||
}
|
||||
|
||||
if constexpr (std::is_void_v<JSReturnT>) {
|
||||
(instance->*method)(
|
||||
|
||||
Reference in New Issue
Block a user