Add @Nullable to WritableMap and WritableArray for Android Java spec generator

Summary:
We're adding a native module that returns a Nullable type. This makes the Java spec and the implementation to be the same.

Changelog:
[Android][Added] - Generate `Nullable` for optional objects and arrays in module codegen.

Reviewed By: yungsters

Differential Revision: D35651333

fbshipit-source-id: d73c87340e33cf79831915ce6892e457ef369175
This commit is contained in:
John Wang
2022-04-22 16:55:29 -07:00
committed by Facebook GitHub Bot
parent 6958bbb28c
commit ffaa5d69bc
8 changed files with 138 additions and 3 deletions
@@ -212,13 +212,13 @@ function translateFunctionReturnTypeToJavaType(
return nullable ? 'Boolean' : 'boolean';
case 'ObjectTypeAnnotation':
imports.add('com.facebook.react.bridge.WritableMap');
return 'WritableMap';
return wrapIntoNullableIfNeeded('WritableMap');
case 'GenericObjectTypeAnnotation':
imports.add('com.facebook.react.bridge.WritableMap');
return 'WritableMap';
return wrapIntoNullableIfNeeded('WritableMap');
case 'ArrayTypeAnnotation':
imports.add('com.facebook.react.bridge.WritableArray');
return 'WritableArray';
return wrapIntoNullableIfNeeded('WritableArray');
default:
(realTypeAnnotation.type: empty);
throw new Error(createErrorMessage(realTypeAnnotation.type));