mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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:
committed by
Facebook GitHub Bot
parent
b2aa41578e
commit
3c569f546c
+3
-3
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user