mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Allow map type objects in Java/ObjC TM EventEmitter (#45271)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45271 Changelog: [Internal] Allow map type objects in Java/ObjC TM EventEmitter Reviewed By: rshest Differential Revision: D59360044 fbshipit-source-id: 6fce094586ed2ad55a0d83a8a83ff554e2ba000e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
504240caad
commit
85dc2e393f
@@ -368,6 +368,7 @@ export type NativeModuleEventEmitterBaseTypeAnnotation =
|
||||
| NativeModuleNumberTypeAnnotation
|
||||
| NativeModuleStringTypeAnnotation
|
||||
| NativeModuleTypeAliasTypeAnnotation
|
||||
| NativeModuleGenericObjectTypeAnnotation
|
||||
| VoidTypeAnnotation;
|
||||
|
||||
export type NativeModuleEventEmitterTypeAnnotation =
|
||||
|
||||
@@ -374,6 +374,7 @@ type NativeModuleEventEmitterBaseTypeAnnotation =
|
||||
| NativeModuleNumberTypeAnnotation
|
||||
| NativeModuleStringTypeAnnotation
|
||||
| NativeModuleTypeAliasTypeAnnotation
|
||||
| NativeModuleGenericObjectTypeAnnotation
|
||||
| VoidTypeAnnotation;
|
||||
|
||||
export type NativeModuleEventEmitterTypeAnnotation =
|
||||
|
||||
+1
@@ -137,6 +137,7 @@ function translateEventEmitterTypeToJavaType(
|
||||
return 'double';
|
||||
case 'BooleanTypeAnnotation':
|
||||
return 'boolean';
|
||||
case 'GenericObjectTypeAnnotation':
|
||||
case 'ObjectTypeAnnotation':
|
||||
case 'TypeAliasTypeAnnotation':
|
||||
imports.add('com.facebook.react.bridge.ReadableMap');
|
||||
|
||||
Vendored
+1
@@ -22,6 +22,7 @@ function getEventEmitterTypeObjCType(
|
||||
return 'NSNumber *_Nonnull';
|
||||
case 'BooleanTypeAnnotation':
|
||||
return 'BOOL';
|
||||
case 'GenericObjectTypeAnnotation':
|
||||
case 'ObjectTypeAnnotation':
|
||||
case 'TypeAliasTypeAnnotation':
|
||||
return 'NSDictionary *';
|
||||
|
||||
+3
@@ -643,6 +643,8 @@ export type ObjectStruct = {
|
||||
c?: ?string,
|
||||
};
|
||||
|
||||
export type MappedObject = {[string]: string};
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
+onEvent1: EventEmitter<void>;
|
||||
+onEvent2: EventEmitter<string>;
|
||||
@@ -650,6 +652,7 @@ export interface Spec extends TurboModule {
|
||||
+onEvent4: EventEmitter<boolean>;
|
||||
+onEvent5: EventEmitter<ObjectStruct>;
|
||||
+onEvent6: EventEmitter<ObjectStruct[]>;
|
||||
+onEvent7: EventEmitter<MappedObject>;
|
||||
}
|
||||
|
||||
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
||||
|
||||
+13
@@ -1527,6 +1527,19 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_EVENT_EM
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'onEvent7',
|
||||
'optional': false,
|
||||
'typeAnnotation': {
|
||||
'type': 'EventEmitterTypeAnnotation',
|
||||
'typeAnnotation': {
|
||||
'type': 'GenericObjectTypeAnnotation',
|
||||
'dictionaryValueType': {
|
||||
'type': 'StringTypeAnnotation'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
'methods': []
|
||||
|
||||
+3
@@ -742,6 +742,8 @@ export type ObjectStruct = {
|
||||
c?: string | null;
|
||||
};
|
||||
|
||||
export type MappedObject = {[key: string]: string};
|
||||
|
||||
export interface Spec extends TurboModule {
|
||||
readonly onEvent1: EventEmitter<void>;
|
||||
readonly onEvent2: EventEmitter<string>;
|
||||
@@ -749,6 +751,7 @@ export interface Spec extends TurboModule {
|
||||
readonly onEvent4: EventEmitter<boolean>;
|
||||
readonly onEvent5: EventEmitter<ObjectStruct>;
|
||||
readonly onEvent6: EventEmitter<ObjectStruct[]>;
|
||||
readonly onEvent7: EventEmitter<MappedObject>;
|
||||
}
|
||||
|
||||
export default TurboModuleRegistry.getEnforcing<Spec>('SampleTurboModule');
|
||||
|
||||
+13
@@ -1727,6 +1727,19 @@ exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_EV
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'name': 'onEvent7',
|
||||
'optional': false,
|
||||
'typeAnnotation': {
|
||||
'type': 'EventEmitterTypeAnnotation',
|
||||
'typeAnnotation': {
|
||||
'type': 'GenericObjectTypeAnnotation',
|
||||
'dictionaryValueType': {
|
||||
'type': 'StringTypeAnnotation'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
'methods': []
|
||||
|
||||
Reference in New Issue
Block a user