@react-native/codegen 0.75.0-nightly-20240225-12f2c3cd2 → 0.75.0-nightly-20240227-8317325fb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -153,7 +153,6 @@ function serializeArg(moduleName, arg, index, resolveAlias, enumMap) {
|
|
|
153
153
|
_unwrapNullable2 = _slicedToArray(_unwrapNullable, 2),
|
|
154
154
|
typeAnnotation = _unwrapNullable2[0],
|
|
155
155
|
nullable = _unwrapNullable2[1];
|
|
156
|
-
const isRequired = !optional && !nullable;
|
|
157
156
|
let realTypeAnnotation = typeAnnotation;
|
|
158
157
|
if (realTypeAnnotation.type === 'TypeAliasTypeAnnotation') {
|
|
159
158
|
realTypeAnnotation = resolveAlias(realTypeAnnotation.name);
|
|
@@ -161,21 +160,21 @@ function serializeArg(moduleName, arg, index, resolveAlias, enumMap) {
|
|
|
161
160
|
function wrap(callback) {
|
|
162
161
|
const val = `args[${index}]`;
|
|
163
162
|
const expression = callback(val);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
condition = `count <= ${index} || ${condition}`;
|
|
170
|
-
}
|
|
171
|
-
return `${condition} ? std::nullopt : std::make_optional(${expression})`;
|
|
163
|
+
|
|
164
|
+
// param: ?T
|
|
165
|
+
// param?: ?T
|
|
166
|
+
if (nullable || optional) {
|
|
167
|
+
return `count <= ${index} || ${val}.isNull() || ${val}.isUndefined() ? std::nullopt : std::make_optional(${expression})`;
|
|
172
168
|
}
|
|
169
|
+
|
|
170
|
+
// param: T
|
|
171
|
+
return `count <= ${index} ? throw jsi::JSError(rt, "Expected argument in position ${index} to be passed") : ${expression}`;
|
|
173
172
|
}
|
|
174
173
|
switch (realTypeAnnotation.type) {
|
|
175
174
|
case 'ReservedTypeAnnotation':
|
|
176
175
|
switch (realTypeAnnotation.name) {
|
|
177
176
|
case 'RootTag':
|
|
178
|
-
return wrap(val => `${val}.
|
|
177
|
+
return wrap(val => `${val}.asNumber()`);
|
|
179
178
|
default:
|
|
180
179
|
realTypeAnnotation.name;
|
|
181
180
|
throw new Error(
|
|
@@ -122,7 +122,6 @@ function serializeArg(
|
|
|
122
122
|
const {typeAnnotation: nullableTypeAnnotation, optional} = arg;
|
|
123
123
|
const [typeAnnotation, nullable] =
|
|
124
124
|
unwrapNullable<NativeModuleParamTypeAnnotation>(nullableTypeAnnotation);
|
|
125
|
-
const isRequired = !optional && !nullable;
|
|
126
125
|
|
|
127
126
|
let realTypeAnnotation = typeAnnotation;
|
|
128
127
|
if (realTypeAnnotation.type === 'TypeAliasTypeAnnotation') {
|
|
@@ -132,22 +131,22 @@ function serializeArg(
|
|
|
132
131
|
function wrap(callback: (val: string) => string) {
|
|
133
132
|
const val = `args[${index}]`;
|
|
134
133
|
const expression = callback(val);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
condition = `count <= ${index} || ${condition}`;
|
|
141
|
-
}
|
|
142
|
-
return `${condition} ? std::nullopt : std::make_optional(${expression})`;
|
|
134
|
+
|
|
135
|
+
// param: ?T
|
|
136
|
+
// param?: ?T
|
|
137
|
+
if (nullable || optional) {
|
|
138
|
+
return `count <= ${index} || ${val}.isNull() || ${val}.isUndefined() ? std::nullopt : std::make_optional(${expression})`;
|
|
143
139
|
}
|
|
140
|
+
|
|
141
|
+
// param: T
|
|
142
|
+
return `count <= ${index} ? throw jsi::JSError(rt, "Expected argument in position ${index} to be passed") : ${expression}`;
|
|
144
143
|
}
|
|
145
144
|
|
|
146
145
|
switch (realTypeAnnotation.type) {
|
|
147
146
|
case 'ReservedTypeAnnotation':
|
|
148
147
|
switch (realTypeAnnotation.name) {
|
|
149
148
|
case 'RootTag':
|
|
150
|
-
return wrap(val => `${val}.
|
|
149
|
+
return wrap(val => `${val}.asNumber()`);
|
|
151
150
|
default:
|
|
152
151
|
(realTypeAnnotation.name: empty);
|
|
153
152
|
throw new Error(
|