Define precise return types for toJs conversions, instead of generic jsi::Value (#51224)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51224

Changelog: [Internal]

We have a bunch of places where we rely on implicit conversion operators of `jsi::Value` and return some primitive type.

This doesn't work well with Bridging, because currently it doesn't take into account these implicit operator conversions: primitives won't be treated as primitivies, but rather as generic `jsi::Value`, which could be many things.

We should be explicit about return type in `toJs`, because it affects the type checking logic.

Reviewed By: javache

Differential Revision: D74478571

fbshipit-source-id: 0633159c5af3a02aafe14e2b137c133d4554a5f8
This commit is contained in:
Ruslan Lesiutin
2025-05-12 12:38:58 -07:00
committed by Facebook GitHub Bot
parent e403b510d0
commit 7430ee0b99
6 changed files with 22 additions and 25 deletions
@@ -62,7 +62,7 @@ struct Bridging<CustomEnumInt> {
}
}
static jsi::Value toJs(jsi::Runtime& rt, CustomEnumInt value) {
static int32_t toJs(jsi::Runtime& rt, CustomEnumInt value) {
return bridging::toJs(rt, static_cast<int32_t>(value));
}
};