RN: Add `RootTag` to New NativeModule Codegen

Summary:
Adds support for `RootTag` in the new codegen for NativeModules/TurboModules.

Changelog: [Internal]

Reviewed By: TheSavior

Differential Revision: D21160788

fbshipit-source-id: 952189f6e8bc8fde8b403d4c0e77b5d66b3f03e4
This commit is contained in:
Tim Yung 2020-04-23 12:38:35 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 064cb12fe0
Коммит 310b0c3af5
16 изменённых файлов: 237 добавлений и 54 удалений

Просмотреть файл

@ -200,6 +200,8 @@ export type PrimitiveTypeAnnotation = $ReadOnly<{|
type: PrimitiveTypeAnnotationType,
|}>;
export type ReservedFunctionValueTypeName = 'RootTag'; // Union with more custom types.
export type FunctionTypeAnnotationParamTypeAnnotation =
| $ReadOnly<{|
type:
@ -207,6 +209,10 @@ export type FunctionTypeAnnotationParamTypeAnnotation =
| 'FunctionTypeAnnotation'
| PrimitiveTypeAnnotationType,
|}>
| $ReadOnly<{|
type: 'ReservedFunctionValueTypeAnnotation',
name: ReservedFunctionValueTypeName,
|}>
| $ReadOnly<{|
type: 'ArrayTypeAnnotation',
elementType: ?FunctionTypeAnnotationParamTypeAnnotation,
@ -228,9 +234,14 @@ export type FunctionTypeAnnotationReturn =
| $ReadOnly<{|
nullable: boolean,
type:
| PrimitiveTypeAnnotationType
| 'GenericPromiseTypeAnnotation'
| 'VoidTypeAnnotation'
| 'GenericPromiseTypeAnnotation',
| PrimitiveTypeAnnotationType,
|}>
| $ReadOnly<{|
nullable: boolean,
type: 'ReservedFunctionValueTypeAnnotation',
name: ReservedFunctionValueTypeName,
|}>
| $ReadOnly<{|
nullable: boolean,

Просмотреть файл

@ -66,8 +66,18 @@ function traverseArg(arg, index): string {
function wrap(suffix) {
return `args[${index}]${suffix}`;
}
const type = arg.typeAnnotation.type;
switch (type) {
const {typeAnnotation} = arg;
switch (typeAnnotation.type) {
case 'ReservedFunctionValueTypeAnnotation':
switch (typeAnnotation.name) {
case 'RootTag':
return wrap('.getNumber()');
default:
(typeAnnotation.name: empty);
throw new Error(
`Unknown prop type for "${arg.name}, found: ${typeAnnotation.name}"`,
);
}
case 'StringTypeAnnotation':
return wrap('.getString(rt)');
case 'BooleanTypeAnnotation':
@ -85,14 +95,16 @@ function traverseArg(arg, index): string {
return wrap('.getObject(rt)');
case 'AnyTypeAnnotation':
throw new Error(`Any type is not allowed in params for "${arg.name}"`);
default:
(type: empty);
throw new Error(`Unknown prop type for "${arg.name}, found: ${type}"`);
// TODO (T65847278): Figure out why this does not work.
// (typeAnnotation.type: empty);
throw new Error(
`Unknown prop type for "${arg.name}, found: ${typeAnnotation.type}"`,
);
}
}
function traverseProprety(property): string {
function traverseProperty(property): string {
const propertyTemplate =
property.typeAnnotation.returnTypeAnnotation.type === 'VoidTypeAnnotation'
? voidPropertyTemplate
@ -127,7 +139,7 @@ module.exports = {
.map(name => {
const {properties} = nativeModules[name];
const traversedProperties = properties
.map(property => traverseProprety(property))
.map(property => traverseProperty(property))
.join('\n');
return moduleTemplate
.replace(/::_MODULE_PROPERTIES_::/g, traversedProperties)

Просмотреть файл

@ -49,12 +49,20 @@ namespace react {
`;
function translatePrimitiveJSTypeToCpp(
type:
typeAnnotation:
| FunctionTypeAnnotationParamTypeAnnotation
| FunctionTypeAnnotationReturn,
error: string,
createErrorMessage: (typeName: string) => string,
) {
switch (type.type) {
switch (typeAnnotation.type) {
case 'ReservedFunctionValueTypeAnnotation':
switch (typeAnnotation.name) {
case 'RootTag':
return 'double';
default:
(typeAnnotation.name: empty);
throw new Error(createErrorMessage(typeAnnotation.name));
}
case 'VoidTypeAnnotation':
return 'void';
case 'StringTypeAnnotation':
@ -75,11 +83,13 @@ function translatePrimitiveJSTypeToCpp(
return 'jsi::Function';
case 'GenericPromiseTypeAnnotation':
return 'jsi::Value';
default:
throw new Error(error);
// TODO (T65847278): Figure out why this does not work.
// (typeAnnotation.type: empty);
throw new Error(createErrorMessage(typeAnnotation.type));
}
}
const propertyTemplate =
'virtual ::_RETURN_VALUE_:: ::_PROPERTY_NAME_::(jsi::Runtime &rt::_ARGS_::) = 0;';
@ -110,7 +120,8 @@ module.exports = {
.map(param => {
const translatedParam = translatePrimitiveJSTypeToCpp(
param.typeAnnotation,
`Unspopported type for param "${param.name}" in ${prop.name}. Found: ${param.typeAnnotation.type}`,
typeName =>
`Unsupported type for param "${param.name}" in ${prop.name}. Found: ${typeName}`,
);
const isObject = translatedParam.startsWith('jsi::');
return (
@ -126,7 +137,8 @@ module.exports = {
'::_RETURN_VALUE_::',
translatePrimitiveJSTypeToCpp(
prop.typeAnnotation.returnTypeAnnotation,
`Unspopported return type for ${prop.name}. Found: ${prop.typeAnnotation.returnTypeAnnotation.type}`,
typeName =>
`Unsupported return type for ${prop.name}. Found: ${typeName}`,
),
)
.replace(

Просмотреть файл

@ -93,20 +93,30 @@ const constants = `- (facebook::react::ModuleConstants<JS::Native::_MODULE_NAME_
function translatePrimitiveJSTypeToObjCType(
param: FunctionTypeAnnotationParam,
error: string,
createErrorMessage: (typeName: string) => string,
) {
const {nullable, typeAnnotation} = param;
function wrapIntoNullableIfNeeded(generatedType: string) {
return param.nullable ? `${generatedType} _Nullable` : generatedType;
return nullable ? `${generatedType} _Nullable` : generatedType;
}
switch (param.typeAnnotation.type) {
switch (typeAnnotation.type) {
case 'ReservedFunctionValueTypeAnnotation':
switch (typeAnnotation.name) {
case 'RootTag':
return nullable ? 'NSNumber *' : 'double';
default:
(typeAnnotation.name: empty);
throw new Error(createErrorMessage(typeAnnotation.name));
}
case 'StringTypeAnnotation':
return wrapIntoNullableIfNeeded('NSString *');
case 'NumberTypeAnnotation':
case 'FloatTypeAnnotation':
case 'Int32TypeAnnotation':
return param.nullable ? 'NSNumber *' : 'double';
return nullable ? 'NSNumber *' : 'double';
case 'BooleanTypeAnnotation':
return param.nullable ? 'NSNumber * _Nullable' : 'BOOL';
return nullable ? 'NSNumber * _Nullable' : 'BOOL';
case 'GenericObjectTypeAnnotation':
return wrapIntoNullableIfNeeded('NSDictionary *');
case 'ArrayTypeAnnotation':
@ -116,18 +126,30 @@ function translatePrimitiveJSTypeToObjCType(
case 'ObjectTypeAnnotation':
return wrapIntoNullableIfNeeded('NSDictionary *');
default:
throw new Error(error);
// TODO (T65847278): Figure out why this does not work.
// (typeAnnotation.type: empty);
throw new Error(createErrorMessage(typeAnnotation.type));
}
}
function translatePrimitiveJSTypeToObjCTypeForReturn(
type: FunctionTypeAnnotationReturn,
error: string,
typeAnnotation: FunctionTypeAnnotationReturn,
createErrorMessage: (typeName: string) => string,
) {
function wrapIntoNullableIfNeeded(generatedType: string) {
return type.nullable ? `${generatedType} _Nullable` : generatedType;
return typeAnnotation.nullable
? `${generatedType} _Nullable`
: generatedType;
}
switch (type.type) {
switch (typeAnnotation.type) {
case 'ReservedFunctionValueTypeAnnotation':
switch (typeAnnotation.name) {
case 'RootTag':
return wrapIntoNullableIfNeeded('NSNumber *');
default:
(typeAnnotation.name: empty);
throw new Error(createErrorMessage(typeAnnotation.name));
}
case 'VoidTypeAnnotation':
case 'GenericPromiseTypeAnnotation':
return 'void';
@ -138,7 +160,7 @@ function translatePrimitiveJSTypeToObjCTypeForReturn(
case 'Int32TypeAnnotation':
return wrapIntoNullableIfNeeded('NSNumber *');
case 'BooleanTypeAnnotation':
return type.nullable ? 'NSNumber * _Nullable' : 'BOOL';
return typeAnnotation.nullable ? 'NSNumber * _Nullable' : 'BOOL';
case 'GenericObjectTypeAnnotation':
return wrapIntoNullableIfNeeded('NSDictionary *');
case 'ArrayTypeAnnotation':
@ -146,9 +168,12 @@ function translatePrimitiveJSTypeToObjCTypeForReturn(
case 'ObjectTypeAnnotation':
return wrapIntoNullableIfNeeded('NSDictionary *');
default:
throw new Error(error);
// TODO (T65847278): Figure out why this does not work.
// (typeAnnotation.type: empty);
throw new Error(createErrorMessage(typeAnnotation.type));
}
}
const methodImplementationTemplate =
'- (::_RETURN_VALUE_::) ::_PROPERTY_NAME_::::_ARGS_::;';
@ -201,7 +226,8 @@ module.exports = {
} else {
paramObjCType = translatePrimitiveJSTypeToObjCType(
param,
`Unspopported type for param "${param.name}" in ${prop.name}. Found: ${param.typeAnnotation.type}`,
typeName =>
`Unsupported type for param "${param.name}" in ${prop.name}. Found: ${typeName}`,
);
}
return `${i === 0 ? '' : param.name}:(${paramObjCType})${
@ -230,7 +256,8 @@ module.exports = {
'::_RETURN_VALUE_::',
translatePrimitiveJSTypeToObjCTypeForReturn(
returnTypeAnnotation,
`Unspopported return type for ${prop.name}. Found: ${prop.typeAnnotation.returnTypeAnnotation.type}`,
typeName =>
`Unsupported return type for ${prop.name}. Found: ${typeName}`,
),
)
.replace('::_ARGS_::', nativeArgs);

Просмотреть файл

@ -71,8 +71,18 @@ namespace react {
} // namespace facebook
`;
function translateReturnTypeToKind(type): string {
switch (type) {
function translateReturnTypeToKind(typeAnnotation): string {
switch (typeAnnotation.type) {
case 'ReservedFunctionValueTypeAnnotation':
switch (typeAnnotation.name) {
case 'RootTag':
return 'NumberKind';
default:
(typeAnnotation.name: empty);
throw new Error(
`Invalid ReservedFunctionValueTypeName name, got ${typeAnnotation.name}`,
);
}
case 'VoidTypeAnnotation':
return 'VoidKind';
case 'StringTypeAnnotation':
@ -92,23 +102,24 @@ function translateReturnTypeToKind(type): string {
case 'ArrayTypeAnnotation':
return 'ArrayKind';
default:
(type: empty);
throw new Error(`Unknown prop type for returning value, found: ${type}"`);
// TODO (T65847278): Figure out why this does not work.
// (typeAnnotation.type: empty);
throw new Error(
`Unknown prop type for returning value, found: ${typeAnnotation.type}"`,
);
}
}
function tranlsateMethodForImplementation(property): string {
function translateMethodForImplementation(property): string {
const {returnTypeAnnotation} = property.typeAnnotation;
const numberOfParams =
property.typeAnnotation.params.length +
(property.typeAnnotation.returnTypeAnnotation.type ===
'GenericPromiseTypeAnnotation'
? 2
: 0);
(returnTypeAnnotation.type === 'GenericPromiseTypeAnnotation' ? 2 : 0);
const translatedArguments = property.typeAnnotation.params
.map(param => param.name)
.concat(
property.typeAnnotation.returnTypeAnnotation.type ===
'GenericPromiseTypeAnnotation'
returnTypeAnnotation.type === 'GenericPromiseTypeAnnotation'
? ['resolve', 'reject']
: [],
)
@ -117,20 +128,14 @@ function tranlsateMethodForImplementation(property): string {
.concat(':');
if (
property.name === 'getConstants' &&
property.typeAnnotation.returnTypeAnnotation.type ===
'ObjectTypeAnnotation' &&
property.typeAnnotation.returnTypeAnnotation.properties &&
property.typeAnnotation.returnTypeAnnotation.properties.length === 0
returnTypeAnnotation.type === 'ObjectTypeAnnotation' &&
returnTypeAnnotation.properties &&
returnTypeAnnotation.properties.length === 0
) {
return '';
}
return propertyTemplate
.replace(
/::_KIND_::/g,
translateReturnTypeToKind(
property.typeAnnotation.returnTypeAnnotation.type,
),
)
.replace(/::_KIND_::/g, translateReturnTypeToKind(returnTypeAnnotation))
.replace(/::_PROPERTY_NAME_::/g, property.name)
.replace(
/::_ARGS_::/g,
@ -220,7 +225,7 @@ module.exports = {
.map(name => {
const {properties} = nativeModules[name];
const translatedMethods = properties
.map(property => tranlsateMethodForImplementation(property))
.map(property => translateMethodForImplementation(property))
.join('\n');
return moduleTemplate
.replace(/::_TURBOMODULE_METHOD_INVOKERS_::/g, translatedMethods)

Просмотреть файл

@ -50,6 +50,14 @@ function getInlineMethodSignature(
): string {
const {typeAnnotation} = property;
switch (typeAnnotation.type) {
case 'ReservedFunctionValueTypeAnnotation':
switch (typeAnnotation.name) {
case 'RootTag':
return `double ${property.name}() const;`;
default:
(typeAnnotation.name: empty);
throw new Error(`Unknown prop type, found: ${typeAnnotation.name}"`);
}
case 'StringTypeAnnotation':
return `NSString *${property.name}() const;`;
case 'NumberTypeAnnotation':
@ -79,6 +87,16 @@ function getInlineMethodImplementation(
): string {
const {typeAnnotation} = property;
switch (typeAnnotation.type) {
case 'ReservedFunctionValueTypeAnnotation':
switch (typeAnnotation.name) {
case 'RootTag':
return inlineTemplate
.replace(/::_RETURN_TYPE_::/, 'double ')
.replace(/::_RETURN_VALUE_::/, 'RCTBridgingToDouble(p)');
default:
(typeAnnotation.name: empty);
throw new Error(`Unknown prop type, found: ${typeAnnotation.name}"`);
}
case 'StringTypeAnnotation':
return inlineTemplate
.replace(/::_RETURN_TYPE_::/, 'NSString *')

Просмотреть файл

@ -63,6 +63,14 @@ function getBuilderInputFieldDeclaration(
}
const {typeAnnotation} = property;
switch (typeAnnotation.type) {
case 'ReservedFunctionValueTypeAnnotation':
switch (typeAnnotation.name) {
case 'RootTag':
return markRequiredIfNecessary('double');
default:
(typeAnnotation.name: empty);
throw new Error(`Unknown prop type, found: ${typeAnnotation.name}"`);
}
case 'StringTypeAnnotation':
if (property.optional) {
return 'NSString *' + property.name + ';';
@ -146,6 +154,14 @@ function unsafeGetter(name: string, optional: boolean) {
function getObjectProperty(property: ObjectParamTypeAnnotation): string {
const {typeAnnotation} = property;
switch (typeAnnotation.type) {
case 'ReservedFunctionValueTypeAnnotation':
switch (typeAnnotation.name) {
case 'RootTag':
return numberGetter(property.name, property.optional);
default:
(typeAnnotation.name: empty);
throw new Error(`Unknown prop type, found: ${typeAnnotation.name}"`);
}
case 'NumberTypeAnnotation':
case 'FloatTypeAnnotation':
case 'Int32TypeAnnotation':

Просмотреть файл

@ -183,6 +183,28 @@ const SIMPLE_NATIVE_MODULES: SchemaType = {
optional: false,
},
},
{
name: 'getRootTag',
typeAnnotation: {
type: 'FunctionTypeAnnotation',
returnTypeAnnotation: {
nullable: false,
type: 'ReservedFunctionValueTypeAnnotation',
name: 'RootTag',
},
params: [
{
nullable: false,
name: 'arg',
typeAnnotation: {
type: 'ReservedFunctionValueTypeAnnotation',
name: 'RootTag',
},
},
],
optional: false,
},
},
{
name: 'getValue',
typeAnnotation: {

Просмотреть файл

@ -99,6 +99,14 @@ const SIMPLE_STRUCT: $ReadOnlyArray<
],
},
},
{
optional: false,
name: 'k',
typeAnnotation: {
type: 'ReservedFunctionValueTypeAnnotation',
name: 'RootTag',
},
},
],
},
},
@ -192,6 +200,14 @@ const SIMPLE_CONSTANTS: $ReadOnlyArray<
],
},
},
{
optional: false,
name: 'k',
typeAnnotation: {
type: 'ReservedFunctionValueTypeAnnotation',
name: 'RootTag',
},
},
],
},
},

Просмотреть файл

@ -98,6 +98,9 @@ static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getArray(jsi:
static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getObject(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<NativeSampleTurboModuleCxxSpecJSI *>(&turboModule)->getObject(rt, args[0].getObject(rt));
}
static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getRootTag(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<NativeSampleTurboModuleCxxSpecJSI *>(&turboModule)->getRootTag(rt, args[0].getNumber());
}
static jsi::Value __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValue(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<NativeSampleTurboModuleCxxSpecJSI *>(&turboModule)->getValue(rt, args[0].getNumber(), args[1].getString(rt), args[2].getObject(rt));
}
@ -119,6 +122,7 @@ NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared
methodMap_[\\"getString\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getString};
methodMap_[\\"getArray\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getArray};
methodMap_[\\"getObject\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getObject};
methodMap_[\\"getRootTag\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getRootTag};
methodMap_[\\"getValue\\"] = MethodMetadata {3, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValue};
methodMap_[\\"getValueWithCallback\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValueWithCallback};
methodMap_[\\"getValueWithPromise\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleCxxSpecJSI_getValueWithPromise};

Просмотреть файл

@ -93,6 +93,7 @@ virtual double getNumber(jsi::Runtime &rt, double arg) = 0;
virtual jsi::String getString(jsi::Runtime &rt, const jsi::String &arg) = 0;
virtual jsi::Array getArray(jsi::Runtime &rt, const jsi::Array &arg) = 0;
virtual jsi::Object getObject(jsi::Runtime &rt, const jsi::Object &arg) = 0;
virtual double getRootTag(jsi::Runtime &rt, double arg) = 0;
virtual jsi::Object getValue(jsi::Runtime &rt, double x, const jsi::String &y, const jsi::Object &z) = 0;
virtual void getValueWithCallback(jsi::Runtime &rt, const jsi::Function &callback) = 0;
virtual jsi::Value getValueWithPromise(jsi::Runtime &rt, bool error) = 0;

Просмотреть файл

@ -298,6 +298,7 @@ inline JS::NativeSampleTurboModule::Constants::Builder::Builder(Constants i) : _
- (NSString *) getString:(NSString *)arg;
- (NSArray<id<NSObject>> *) getArray:(NSArray *)arg;
- (NSDictionary *) getObject:(NSDictionary *)arg;
- (NSNumber *) getRootTag:(double)arg;
- (NSDictionary *) getValue:(double)x
y:(NSString *)y
z:(NSDictionary *)z;

Просмотреть файл

@ -122,6 +122,10 @@ static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getObj
return static_cast<ObjCTurboModule &>(turboModule)
.invokeObjCMethod(rt, ObjectKind, \\"getObject\\", @selector(getObject:), args, count);
}
static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getRootTag(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
return static_cast<ObjCTurboModule &>(turboModule)
.invokeObjCMethod(rt, NumberKind, \\"getRootTag\\", @selector(getRootTag:), args, count);
}
static facebook::jsi::Value __hostFunction_NativeSampleTurboModuleSpecJSI_getValue(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
return static_cast<ObjCTurboModule &>(turboModule)
.invokeObjCMethod(rt, ObjectKind, \\"getValue\\", @selector(getValue:y:z:), args, count);
@ -144,6 +148,7 @@ NativeSampleTurboModuleSpecJSI::NativeSampleTurboModuleSpecJSI(const ObjCTurboMo
methodMap_[\\"getString\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleSpecJSI_getString};
methodMap_[\\"getArray\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleSpecJSI_getArray};
methodMap_[\\"getObject\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleSpecJSI_getObject};
methodMap_[\\"getRootTag\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleSpecJSI_getRootTag};
methodMap_[\\"getValue\\"] = MethodMetadata {3, __hostFunction_NativeSampleTurboModuleSpecJSI_getValue};
methodMap_[\\"getValueWithCallback\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithCallback};
methodMap_[\\"getValueWithPromise\\"] = MethodMetadata {1, __hostFunction_NativeSampleTurboModuleSpecJSI_getValueWithPromise};

Просмотреть файл

@ -101,6 +101,7 @@ namespace JS {
RCTRequired<double> b;
RCTRequired<NSString *> c;
RCTRequired<JS::NativeSampleTurboModule::ConstantsD::Builder> d;
RCTRequired<double> k;
};
/** Initialize with a set of values */
@ -132,6 +133,8 @@ auto c = i.c.get();
d[@\\"c\\"] = c;
auto d = i.d.get();
d[@\\"d\\"] = d.buildUnsafeRawValue();
auto k = i.k.get();
d[@\\"k\\"] = @(k);
return d;
}) {}
inline JS::NativeSampleTurboModule::Constants::Builder::Builder(Constants i) : _factory(^{
@ -188,6 +191,7 @@ namespace JS {
double b() const;
NSString *c() const;
JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeD d() const;
double k() const;
SpecSampleFuncReturnType(NSDictionary *const v) : _v(v) {}
private:
@ -228,6 +232,13 @@ inline JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeD JS::NativeSampleTu
}
inline double JS::NativeSampleTurboModule::SpecSampleFuncReturnType::k() const
{
id const p = _v[@\\"k\\"];
return RCTBridgingToDouble(p);
}
inline bool JS::NativeSampleTurboModule::SpecSampleFuncReturnTypeD::e() const
{
id const p = _v[@\\"e\\"];

Просмотреть файл

@ -1012,13 +1012,15 @@ Object {
"name": "rootTag",
"nullable": false,
"typeAnnotation": Object {
"type": "GenericObjectTypeAnnotation",
"name": "RootTag",
"type": "ReservedFunctionValueTypeAnnotation",
},
},
],
"returnTypeAnnotation": Object {
"name": "RootTag",
"nullable": false,
"type": "GenericObjectTypeAnnotation",
"type": "ReservedFunctionValueTypeAnnotation",
},
"type": "FunctionTypeAnnotation",
},

Просмотреть файл

@ -67,6 +67,11 @@ function getElementTypeForArrayOrObject(
: typeAnnotation.type;
switch (type) {
case 'RootTag':
return {
type: 'ReservedFunctionValueTypeAnnotation',
name: 'RootTag',
};
case 'Array':
case '$ReadOnlyArray':
if (
@ -168,6 +173,15 @@ function getTypeAnnotationForParam(
: typeAnnotation.type;
switch (type) {
case 'RootTag':
return {
name: paramName,
nullable,
typeAnnotation: {
type: 'ReservedFunctionValueTypeAnnotation',
name: 'RootTag',
},
};
case 'Array':
case '$ReadOnlyArray':
if (
@ -300,6 +314,12 @@ function getReturnTypeAnnotation(
: typeAnnotation.type;
switch (type) {
case 'RootTag':
return {
nullable,
type: 'ReservedFunctionValueTypeAnnotation',
name: 'RootTag',
};
case 'Promise':
if (
typeAnnotation.typeParameters &&