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
2022-05-24 19:35:29 -07:00
committed by Facebook GitHub Bot
parent b2aa41578e
commit 3c569f546c
21 changed files with 415 additions and 22 deletions
@@ -156,7 +156,7 @@ function translateFunctionParamToJavaType(
imports.add('com.facebook.react.bridge.Callback');
return 'Callback';
default:
(realTypeAnnotation.type: empty);
(realTypeAnnotation.type: 'MixedTypeAnnotation');
throw new Error(createErrorMessage(realTypeAnnotation.type));
}
}
@@ -220,7 +220,7 @@ function translateFunctionReturnTypeToJavaType(
imports.add('com.facebook.react.bridge.WritableArray');
return wrapIntoNullableIfNeeded('WritableArray');
default:
(realTypeAnnotation.type: empty);
(realTypeAnnotation.type: 'MixedTypeAnnotation');
throw new Error(createErrorMessage(realTypeAnnotation.type));
}
}
@@ -272,7 +272,7 @@ function getFalsyReturnStatementFromReturnType(
case 'ArrayTypeAnnotation':
return 'return null;';
default:
(realTypeAnnotation.type: empty);
(realTypeAnnotation.type: 'MixedTypeAnnotation');
throw new Error(createErrorMessage(realTypeAnnotation.type));
}
}