Allow null as default value for boolean props

Summary: Some props must have their default values set by native. To be able to support this, we have to introduce a `null` as a supported default value for some types. In this diff I'm adding support for `null` default values for boolean props. Check D17260168 for the example of the usage of the nullable boolean values.

Reviewed By: rickhanlonii, TheSavior

Differential Revision: D17258234

fbshipit-source-id: 63b7864be97856704d5964230526f23c0e395a67
This commit is contained in:
Oleksandr Melnykov
2019-09-23 07:18:08 -07:00
committed by Facebook Github Bot
parent ef3b16ef6d
commit bf89d1d536
11 changed files with 65 additions and 13 deletions
@@ -52,7 +52,12 @@ function getJavaValueForProp(prop: PropTypeShape, imports): string {
switch (typeAnnotation.type) {
case 'BooleanTypeAnnotation':
return 'boolean value';
if (typeAnnotation.default === null) {
addNullable(imports);
return '@Nullable Boolean value';
} else {
return 'boolean value';
}
case 'StringTypeAnnotation':
addNullable(imports);
return '@Nullable String value';