diff --git a/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js b/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js index 9661522c15a..77444816ef3 100644 --- a/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js +++ b/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js @@ -40,7 +40,7 @@ type NativeProps = $ReadOnly<{| enabled?: ?WithDefault, items: $ReadOnlyArray, prompt?: ?WithDefault, - selected: WithDefault, + selected: Int32, // Events onSelect?: DirectEventHandler, diff --git a/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js b/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js index 61f4e1a5a2b..2b0e1773ef2 100644 --- a/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js +++ b/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js @@ -40,7 +40,7 @@ type NativeProps = $ReadOnly<{| enabled?: ?WithDefault, items: $ReadOnlyArray, prompt?: ?WithDefault, - selected: WithDefault, + selected: Int32, // Events onSelect?: DirectEventHandler, diff --git a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js index 9d257b1b7a4..fffa7c3f2c6 100644 --- a/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js +++ b/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidNativeComponent.js @@ -22,7 +22,7 @@ type NativeProps = $ReadOnly<{| //Props styleAttr?: string, typeAttr?: string, - indeterminate: WithDefault, + indeterminate: boolean, progress?: WithDefault, animating?: ?WithDefault, color?: ?ColorValue, diff --git a/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js b/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js index c1e366098dc..9e8f0ea583b 100644 --- a/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +++ b/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js @@ -61,7 +61,7 @@ type NativeProps = $ReadOnly<{| /** * Whether the view should be indicating an active refresh. */ - refreshing: WithDefault, + refreshing: boolean, |}>; export default codegenNativeComponent('AndroidSwipeRefreshLayout'); diff --git a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js index 1bfb10322a7..a38f28b4695 100644 --- a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +++ b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js @@ -40,7 +40,7 @@ type NativeProps = $ReadOnly<{| /** * Whether the view should be indicating an active refresh. */ - refreshing: WithDefault, + refreshing: boolean, |}>; export default codegenNativeComponent('PullToRefreshView', { diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/StringPropNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/StringPropNativeComponent.js index 5b50a97537a..02a4a08b58e 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/StringPropNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/StringPropNativeComponent.js @@ -19,7 +19,7 @@ type NativeProps = $ReadOnly<{| // Props accessibilityHint?: WithDefault, - accessibilityRole?: WithDefault, + accessibilityRole?: string, |}>; export default codegenNativeComponent('StringPropNativeComponent'); diff --git a/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/fixtures.js index 45f2d3f30b2..de6e81d7d7b 100644 --- a/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/parsers/flow/__test_fixtures__/fixtures.js @@ -158,43 +158,41 @@ type ModuleProps = $ReadOnly<{| // Props // Boolean props - boolean_required: WithDefault, + boolean_required: boolean, boolean_optional_key?: WithDefault, boolean_optional_value: ?WithDefault, boolean_optional_both?: ?WithDefault, // String props - string_required: WithDefault, + string_required: string, string_optional_key?: WithDefault, string_optional_value: ?WithDefault, string_optional_both?: ?WithDefault, // String props, null default - string_null_required: WithDefault, string_null_optional_key?: WithDefault, string_null_optional_value: ?WithDefault, string_null_optional_both?: ?WithDefault, // Stringish props - stringish_required: WithDefault, + stringish_required: Stringish, stringish_optional_key?: WithDefault, stringish_optional_value: ?WithDefault, stringish_optional_both?: ?WithDefault, // Stringish props, null default - stringish_null_required: WithDefault, stringish_null_optional_key?: WithDefault, stringish_null_optional_value: ?WithDefault, stringish_null_optional_both?: ?WithDefault, // Float props - float_required: WithDefault, + float_required: Float, float_optional_key?: WithDefault, float_optional_value: ?WithDefault, float_optional_both?: ?WithDefault, // Int32 props - int32_required: WithDefault, + int32_required: Int32, int32_optional_key?: WithDefault, int32_optional_value: ?WithDefault, int32_optional_both?: ?WithDefault, diff --git a/packages/react-native-codegen/src/parsers/flow/__tests__/__snapshots__/parser-test.js.snap b/packages/react-native-codegen/src/parsers/flow/__tests__/__snapshots__/parser-test.js.snap index 92d02f2d923..db03605d833 100644 --- a/packages/react-native-codegen/src/parsers/flow/__tests__/__snapshots__/parser-test.js.snap +++ b/packages/react-native-codegen/src/parsers/flow/__tests__/__snapshots__/parser-test.js.snap @@ -25,7 +25,7 @@ Object { "name": "boolean_required", "optional": false, "typeAnnotation": Object { - "default": true, + "default": false, "type": "BooleanTypeAnnotation", }, }, @@ -57,7 +57,7 @@ Object { "name": "string_required", "optional": false, "typeAnnotation": Object { - "default": "", + "default": null, "type": "StringTypeAnnotation", }, }, @@ -85,14 +85,6 @@ Object { "type": "StringTypeAnnotation", }, }, - Object { - "name": "string_null_required", - "optional": false, - "typeAnnotation": Object { - "default": null, - "type": "StringTypeAnnotation", - }, - }, Object { "name": "string_null_optional_key", "optional": true, @@ -121,7 +113,7 @@ Object { "name": "stringish_required", "optional": false, "typeAnnotation": Object { - "default": "", + "default": null, "type": "StringTypeAnnotation", }, }, @@ -149,14 +141,6 @@ Object { "type": "StringTypeAnnotation", }, }, - Object { - "name": "stringish_null_required", - "optional": false, - "typeAnnotation": Object { - "default": null, - "type": "StringTypeAnnotation", - }, - }, Object { "name": "stringish_null_optional_key", "optional": true, @@ -185,7 +169,7 @@ Object { "name": "float_required", "optional": false, "typeAnnotation": Object { - "default": 1.1, + "default": 0, "type": "FloatTypeAnnotation", }, }, @@ -217,7 +201,7 @@ Object { "name": "int32_required", "optional": false, "typeAnnotation": Object { - "default": 1, + "default": 0, "type": "Int32TypeAnnotation", }, }, diff --git a/packages/react-native-codegen/src/parsers/flow/props.js b/packages/react-native-codegen/src/parsers/flow/props.js index 327cefff6cc..b07c444777a 100644 --- a/packages/react-native-codegen/src/parsers/flow/props.js +++ b/packages/react-native-codegen/src/parsers/flow/props.js @@ -129,29 +129,20 @@ function getTypeAnnotation(name, typeAnnotation, defaultValue) { name: 'PointPrimitive', }; case 'Int32': - if (defaultValue != null) { - return { - type: 'Int32TypeAnnotation', - default: (defaultValue: number), - }; - } - throw new Error(`A default int is required for "${name}"`); + return { + type: 'Int32TypeAnnotation', + default: ((defaultValue ? defaultValue : 0): number), + }; case 'Float': - if (defaultValue != null) { - return { - type: 'FloatTypeAnnotation', - default: (defaultValue: number), - }; - } - throw new Error(`A default float is required for "${name}"`); + return { + type: 'FloatTypeAnnotation', + default: ((defaultValue ? defaultValue : 0): number), + }; case 'BooleanTypeAnnotation': - if (defaultValue != null) { - return { - type: 'BooleanTypeAnnotation', - default: (defaultValue: boolean), - }; - } - throw new Error(`A default boolean is required for "${name}"`); + return { + type: 'BooleanTypeAnnotation', + default: ((defaultValue == null ? false : defaultValue): boolean), + }; case 'StringTypeAnnotation': if (typeof defaultValue !== 'undefined') { return {