Codegen Android: handle nullable getConstants() properties generation.

Summary:
The GenerateModuleJavaSpec.js mistakenly treated nullable getConstants() properties as required, such that the Java spec will throw an exception when the properties are missing. This fixed it.

Note that the JavaPoet-based generator got this correct already.

Changelog: [Internal]

Differential Revision: D24381941

fbshipit-source-id: c95d2181c66443e2191318f09b6454a5296009e4
This commit is contained in:
Kevin Gozali
2020-10-19 09:31:22 -07:00
committed by Facebook GitHub Bot
parent 4e8326a82e
commit 4dfa3be871
@@ -203,8 +203,7 @@ function buildGetConstantsMethod(
const rawProperties =
methodTypeAnnotation.returnTypeAnnotation.properties || [];
rawProperties.forEach(p => {
// TODO(T76712813): Should we push to optionalProps if the constant is nullable?
if (p.optional) {
if (p.optional || p.typeAnnotation.type === 'NullableTypeAnnotation') {
optionalProps.push(p.name);
} else {
requiredProps.push(p.name);