Support mixed types only for C++

Summary:
There are cases where we want to pass arbitrary types to a TurboModule, which may then handle the values appropriately, but we haven't supported this use case. Since C++ TurboModules can accept any `jsi::Value` (unlike Java/ObjC) and we have real-world need for this (otherwise we must require JSON serialization), this now allows `mixed` (`unknown` in TypeScript) for C++-only TurboModules.

Changelog:
[General][Added] C++ TurboModule methods can now use mixed types

Reviewed By: RSNara

Differential Revision: D36611299

fbshipit-source-id: bbf29dfcc6aed67e213bb3eab06537c18c7db1fe
This commit is contained in:
Scott Kyle authored and Facebook GitHub Bot committed 2022-05-24 19:35:29 -07:00
1 parent b2aa41578e
commit 3c569f546c
21 files changed
+415 -22

No files matched your search

@@ -338,7 +338,7 @@ function getReturnObjCType(
case 'GenericObjectTypeAnnotation':
return wrapIntoNullableIfNeeded('NSDictionary *');
default:
(typeAnnotation.type: empty);
(typeAnnotation.type: 'MixedTypeAnnotation');
throw new Error(
`Unsupported return type for ${methodName}. Found: ${typeAnnotation.type}`,
);
@@ -378,7 +378,7 @@ function getReturnJSType(
case 'GenericObjectTypeAnnotation':
return 'ObjectKind';
default:
(typeAnnotation.type: empty);
(typeAnnotation.type: 'MixedTypeAnnotation');
throw new Error(
`Unsupported return type for ${methodName}. Found: ${typeAnnotation.type}`,
);