File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,23 @@ template <> struct JSIConverter<bool> {
73
73
}
74
74
};
75
75
76
+ template <typename TInner> struct JSIConverter <std::optional<TInner>> {
77
+ static std::optional<TInner> fromJSI (jsi::Runtime& runtime, const jsi::Value& arg) {
78
+ if (arg.isUndefined () || arg.isNull ()) {
79
+ return std::nullopt ;
80
+ } else {
81
+ return JSIConverter<TInner>::fromJSI (runtime, std::move (arg));
82
+ }
83
+ }
84
+ static jsi::Value toJSI (jsi::Runtime& runtime, std::optional<TInner> arg) {
85
+ if (arg == std::nullopt ) {
86
+ return jsi::Value::undefined ();
87
+ } else {
88
+ return JSIConverter<TInner>::toJSI (runtime, arg);
89
+ }
90
+ }
91
+ };
92
+
76
93
template <> struct JSIConverter <std::string> {
77
94
static std::string fromJSI (jsi::Runtime& runtime, const jsi::Value& arg) {
78
95
return arg.asString (runtime).utf8 (runtime);
You can’t perform that action at this time.
0 commit comments