diff --git a/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js b/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js index 7bf18a9d551..9661522c15a 100644 --- a/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js +++ b/Libraries/Components/Picker/AndroidDialogPickerNativeComponent.js @@ -12,7 +12,11 @@ import {requireNativeComponent} from 'react-native'; -import type {DirectEvent, Int32, WithDefault} from '../../Types/CodegenTypes'; +import type { + DirectEventHandler, + Int32, + WithDefault, +} from '../../Types/CodegenTypes'; import type {TextStyleProp} from '../../StyleSheet/StyleSheet'; import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; import type {NativeComponent} from '../../Renderer/shims/ReactNative'; @@ -39,7 +43,7 @@ type NativeProps = $ReadOnly<{| selected: WithDefault, // Events - onSelect?: (event: DirectEvent) => void, + onSelect?: DirectEventHandler, |}>; type ReactPicker = Class>; diff --git a/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js b/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js index 343cc1e76d2..61f4e1a5a2b 100644 --- a/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js +++ b/Libraries/Components/Picker/AndroidDropdownPickerNativeComponent.js @@ -12,7 +12,11 @@ import {requireNativeComponent} from 'react-native'; -import type {DirectEvent, Int32, WithDefault} from '../../Types/CodegenTypes'; +import type { + DirectEventHandler, + Int32, + WithDefault, +} from '../../Types/CodegenTypes'; import type {TextStyleProp} from '../../StyleSheet/StyleSheet'; import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; import type {NativeComponent} from '../../Renderer/shims/ReactNative'; @@ -39,7 +43,7 @@ type NativeProps = $ReadOnly<{| selected: WithDefault, // Events - onSelect?: (event: DirectEvent) => void, + onSelect?: DirectEventHandler, |}>; type ReactPicker = Class>; diff --git a/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js b/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js index fca375a5ca9..c1e366098dc 100644 --- a/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js +++ b/Libraries/Components/RefreshControl/AndroidSwipeRefreshLayoutNativeComponent.js @@ -13,7 +13,7 @@ import codegenNativeComponent from '../../Utilities/codegenNativeComponent'; import type { - DirectEvent, + DirectEventHandler, Float, Int32, WithDefault, @@ -56,7 +56,7 @@ type NativeProps = $ReadOnly<{| /** * Called when the view starts refreshing. */ - onRefresh?: ?(event: DirectEvent) => mixed, + onRefresh?: ?DirectEventHandler, /** * Whether the view should be indicating an active refresh. diff --git a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js index 906484dad62..1bfb10322a7 100644 --- a/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js +++ b/Libraries/Components/RefreshControl/PullToRefreshViewNativeComponent.js @@ -10,7 +10,7 @@ 'use strict'; -import type {DirectEvent, WithDefault} from '../../Types/CodegenTypes'; +import type {DirectEventHandler, WithDefault} from '../../Types/CodegenTypes'; import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; import type {ViewProps} from '../View/ViewPropTypes'; @@ -35,7 +35,7 @@ type NativeProps = $ReadOnly<{| /** * Called when the view starts refreshing. */ - onRefresh?: ?(event: DirectEvent) => mixed, + onRefresh?: ?DirectEventHandler, /** * Whether the view should be indicating an active refresh. diff --git a/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js b/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js index 7638ed29bea..9105deddd2a 100644 --- a/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js +++ b/Libraries/Components/SegmentedControlIOS/RCTSegmentedControlNativeComponent.js @@ -11,15 +11,17 @@ import codegenNativeComponent from '../../Utilities/codegenNativeComponent'; import type {ViewProps} from '../View/ViewPropTypes'; -import type {BubblingEvent, WithDefault, Int32} from '../../Types/CodegenTypes'; +import type { + BubblingEventHandler, + WithDefault, + Int32, +} from '../../Types/CodegenTypes'; import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; -export type OnChangeEvent = BubblingEvent< - $ReadOnly<{| - value: Int32, - selectedSegmentIndex: Int32, - |}>, ->; +export type OnChangeEvent = $ReadOnly<{| + value: Int32, + selectedSegmentIndex: Int32, +|}>; type NativeProps = $ReadOnly<{| ...ViewProps, @@ -32,7 +34,7 @@ type NativeProps = $ReadOnly<{| momentary?: ?WithDefault, // Events - onChange?: ?(event: OnChangeEvent) => mixed, + onChange?: ?BubblingEventHandler, |}>; export default codegenNativeComponent('RCTSegmentedControl'); diff --git a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js index ae1af947c5d..a98e26e909b 100644 --- a/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js +++ b/Libraries/Components/SegmentedControlIOS/SegmentedControlIOS.ios.js @@ -15,6 +15,7 @@ import StyleSheet from '../../StyleSheet/StyleSheet'; import type {OnChangeEvent} from './RCTSegmentedControlNativeComponent'; import type {ViewProps} from '../View/ViewPropTypes'; import RCTSegmentedControlNativeComponent from './RCTSegmentedControlNativeComponent'; +import type {SyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes'; type SegmentedControlIOSProps = $ReadOnly<{| ...ViewProps, @@ -42,7 +43,7 @@ type SegmentedControlIOSProps = $ReadOnly<{| /** * Callback that is called when the user taps a segment */ - onChange?: ?(event: OnChangeEvent) => mixed, + onChange?: ?(event: SyntheticEvent) => mixed, /** * Callback that is called when the user taps a segment; * passes the segment's value as an argument @@ -82,7 +83,7 @@ class SegmentedControlIOS extends React.Component { enabled: true, }; - _onChange = (event: OnChangeEvent) => { + _onChange = (event: SyntheticEvent) => { this.props.onChange && this.props.onChange(event); this.props.onValueChange && this.props.onValueChange(event.nativeEvent.value); diff --git a/Libraries/Components/Slider/SliderNativeComponent.js b/Libraries/Components/Slider/SliderNativeComponent.js index 50bb33d31d7..9b809e1ca65 100644 --- a/Libraries/Components/Slider/SliderNativeComponent.js +++ b/Libraries/Components/Slider/SliderNativeComponent.js @@ -12,8 +12,8 @@ import type { Float, - BubblingEvent, - DirectEvent, + BubblingEventHandler, + DirectEventHandler, WithDefault, } from '../../Types/CodegenTypes'; @@ -25,7 +25,7 @@ import type {ViewProps} from '../View/ViewPropTypes'; type Event = $ReadOnly<{| value: Float, - fromUser: boolean, + fromUser?: boolean, |}>; type NativeProps = $ReadOnly<{| @@ -48,11 +48,9 @@ type NativeProps = $ReadOnly<{| value: ?WithDefault, // Events - onChange?: ?(event: BubblingEvent) => void, - onValueChange?: ?(event: BubblingEvent) => void, - onSlidingComplete?: ?( - event: DirectEvent, - ) => void, + onChange?: ?BubblingEventHandler, + onValueChange?: ?BubblingEventHandler, + onSlidingComplete?: ?DirectEventHandler, |}>; export default codegenNativeComponent('Slider', { diff --git a/Libraries/Components/Switch/SwitchNativeComponent.js b/Libraries/Components/Switch/SwitchNativeComponent.js index cfb177aa481..ea223bbde5e 100644 --- a/Libraries/Components/Switch/SwitchNativeComponent.js +++ b/Libraries/Components/Switch/SwitchNativeComponent.js @@ -10,7 +10,7 @@ 'use strict'; -import type {BubblingEvent, WithDefault} from '../../Types/CodegenTypes'; +import type {BubblingEventHandler, WithDefault} from '../../Types/CodegenTypes'; import type {ColorValue} from '../../StyleSheet/StyleSheetTypes'; import type {ViewProps} from '../View/ViewPropTypes'; @@ -36,7 +36,7 @@ type NativeProps = $ReadOnly<{| trackColorForTrue?: ?ColorValue, // Events - onChange?: ?(event: BubblingEvent) => mixed, + onChange?: ?BubblingEventHandler, |}>; export default codegenNativeComponent('Switch', { diff --git a/Libraries/Modal/RCTModalHostViewNativeComponent.js b/Libraries/Modal/RCTModalHostViewNativeComponent.js index 8842098a288..1e305442d35 100644 --- a/Libraries/Modal/RCTModalHostViewNativeComponent.js +++ b/Libraries/Modal/RCTModalHostViewNativeComponent.js @@ -13,8 +13,8 @@ import codegenNativeComponent from '../Utilities/codegenNativeComponent'; import type { WithDefault, - BubblingEvent, - DirectEvent, + BubblingEventHandler, + DirectEventHandler, Int32, } from '../Types/CodegenTypes'; @@ -75,7 +75,7 @@ type NativeProps = $ReadOnly<{| * * See https://facebook.github.io/react-native/docs/modal.html#onrequestclose */ - onRequestClose?: ?(event?: DirectEvent) => mixed, + onRequestClose?: ?DirectEventHandler, /** * The `onShow` prop allows passing a function that will be called once the @@ -83,7 +83,7 @@ type NativeProps = $ReadOnly<{| * * See https://facebook.github.io/react-native/docs/modal.html#onshow */ - onShow?: ?(event?: DirectEvent) => mixed, + onShow?: ?DirectEventHandler, /** * The `onDismiss` prop allows passing a function that will be called once @@ -91,7 +91,7 @@ type NativeProps = $ReadOnly<{| * * See https://facebook.github.io/react-native/docs/modal.html#ondismiss */ - onDismiss?: ?(event?: BubblingEvent) => mixed, + onDismiss?: ?BubblingEventHandler, /** * Deprecated. Use the `animationType` prop instead. @@ -119,7 +119,7 @@ type NativeProps = $ReadOnly<{| * * See https://facebook.github.io/react-native/docs/modal.html#onorientationchange */ - onOrientationChange?: ?(event: DirectEvent) => mixed, + onOrientationChange?: ?DirectEventHandler, /** * The `identifier` is the unique number for identifying Modal components. diff --git a/Libraries/Types/CodegenTypes.js b/Libraries/Types/CodegenTypes.js index e235e475b0e..8a385d850f8 100644 --- a/Libraries/Types/CodegenTypes.js +++ b/Libraries/Types/CodegenTypes.js @@ -14,14 +14,15 @@ import type {SyntheticEvent} from './CoreEventTypes'; // Event types // We're not using the PaperName, it is only used to codegen view config settings -export type BubblingEvent< + +export type BubblingEventHandler< T, PaperName: string | empty = empty, // eslint-disable-line no-unused-vars -> = SyntheticEvent; -export type DirectEvent< +> = (event: SyntheticEvent) => mixed; +export type DirectEventHandler< T, PaperName: string | empty = empty, // eslint-disable-line no-unused-vars -> = SyntheticEvent; +> = (event: SyntheticEvent) => mixed; // Prop types export type Float = number; diff --git a/packages/babel-plugin-inline-view-configs/__test_fixtures__/fixtures.js b/packages/babel-plugin-inline-view-configs/__test_fixtures__/fixtures.js index 12c96cdfe4b..d4ad955d4d0 100644 --- a/packages/babel-plugin-inline-view-configs/__test_fixtures__/fixtures.js +++ b/packages/babel-plugin-inline-view-configs/__test_fixtures__/fixtures.js @@ -23,8 +23,8 @@ const codegenNativeComponent = require('codegenNativeComponent'); import type { Int32, - BubblingEvent, - DirectEvent, + BubblingEventHandler, + DirectEventHandler, WithDefault, } from 'CodegenFlowtypes'; @@ -42,8 +42,8 @@ type ModuleProps = $ReadOnly<{| boolean_default_true_optional_both?: ?WithDefault, // Events - onDirectEventDefinedInlineNull: (event: DirectEvent) => void, - onBubblingEventDefinedInlineNull: (event: BubblingEvent) => void, + onDirectEventDefinedInlineNull: DirectEventHandler, + onBubblingEventDefinedInlineNull: BubblingEventHandler, |}>; export const Commands = codegenNativeCommands(); diff --git a/packages/babel-plugin-inline-view-configs/__tests__/__snapshots__/index-test.js.snap b/packages/babel-plugin-inline-view-configs/__tests__/__snapshots__/index-test.js.snap index 73b1021cc4f..1e29afabb80 100644 --- a/packages/babel-plugin-inline-view-configs/__tests__/__snapshots__/index-test.js.snap +++ b/packages/babel-plugin-inline-view-configs/__tests__/__snapshots__/index-test.js.snap @@ -6,7 +6,7 @@ const codegenNativeCommands = require('codegenNativeCommands'); const codegenNativeComponent = require('codegenNativeComponent'); -import type { Int32, BubblingEvent, DirectEvent, WithDefault } from 'CodegenFlowtypes'; +import type { Int32, BubblingEventHandler, DirectEventHandler, WithDefault } from 'CodegenFlowtypes'; import type { ViewProps } from 'ViewPropTypes'; interface NativeCommands { +hotspotUpdate: (viewRef: React.Ref<'RCTView'>, x: Int32, y: Int32) => void, @@ -16,8 +16,8 @@ type ModuleProps = $ReadOnly<{| ...ViewProps, // Props boolean_default_true_optional_both?: ?WithDefault, // Events - onDirectEventDefinedInlineNull: (event: DirectEvent) => void, - onBubblingEventDefinedInlineNull: (event: BubblingEvent) => void, + onDirectEventDefinedInlineNull: DirectEventHandler, + onBubblingEventDefinedInlineNull: BubblingEventHandler, |}>; export const Commands = codegenNativeCommands(); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/EventNestedObjectPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/EventNestedObjectPropsNativeComponent.js index be14116d242..5e1d68f6503 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/EventNestedObjectPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/EventNestedObjectPropsNativeComponent.js @@ -12,7 +12,7 @@ import type { Int32, - BubblingEvent, + BubblingEventHandler, WithDefault, } from '../../../../Libraries/Types/CodegenTypes'; import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; @@ -35,7 +35,7 @@ type NativeProps = $ReadOnly<{| disabled?: WithDefault, // Events - onChange?: ?(event: BubblingEvent) => void, + onChange?: ?BubblingEventHandler, |}>; export default codegenNativeComponent( diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/EventPropsNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/EventPropsNativeComponent.js index 533290e251e..1ad260238c9 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/EventPropsNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/EventPropsNativeComponent.js @@ -13,8 +13,8 @@ import type { Int32, Float, - BubblingEvent, - DirectEvent, + BubblingEventHandler, + DirectEventHandler, WithDefault, } from '../../../../Libraries/Types/CodegenTypes'; import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; @@ -42,16 +42,21 @@ type NativeProps = $ReadOnly<{| disabled?: WithDefault, // Events - onChange?: ?(event: BubblingEvent) => void, - onEventDirect?: ?(event: DirectEvent) => void, - onEventDirectWithPaperName?: ?( - event: DirectEvent, - ) => void, - onOrientationChange?: ?(event: DirectEvent) => void, - onEnd?: ?(event: BubblingEvent) => void, - onEventBubblingWithPaperName?: ?( - event: BubblingEvent, - ) => void, + onChange?: ?BubblingEventHandler, + onEventDirect?: ?DirectEventHandler, + onEventDirectWithPaperName?: ?DirectEventHandler< + OnEventDirect, + 'paperDirectName', + >, + onOrientationChange?: ?DirectEventHandler< + OnOrientationChangeEvent, + 'paperBubblingName', + >, + onEnd?: ?BubblingEventHandler, + onEventBubblingWithPaperName?: ?BubblingEventHandler< + null, + 'paperBubblingName', + >, |}>; export default codegenNativeComponent('EventPropsNativeComponent'); diff --git a/packages/react-native-codegen/e2e/__test_fixtures__/InterfaceOnlyNativeComponent.js b/packages/react-native-codegen/e2e/__test_fixtures__/InterfaceOnlyNativeComponent.js index 510ae82ce2f..ec293197fb7 100644 --- a/packages/react-native-codegen/e2e/__test_fixtures__/InterfaceOnlyNativeComponent.js +++ b/packages/react-native-codegen/e2e/__test_fixtures__/InterfaceOnlyNativeComponent.js @@ -11,7 +11,7 @@ 'use strict'; import type { - BubblingEvent, + BubblingEventHandler, WithDefault, } from '../../../../Libraries/Types/CodegenTypes'; import type {ViewProps} from '../../../../Libraries/Components/View/ViewPropTypes'; @@ -24,7 +24,7 @@ type NativeProps = $ReadOnly<{| accessibilityHint?: WithDefault, // Events - onChange?: ?(event: BubblingEvent<$ReadOnly<{|value: boolean|}>>) => void, + onChange?: ?BubblingEventHandler<$ReadOnly<{|value: boolean|}>>, |}>; export default codegenNativeComponent( 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 9ee5e68f20e..45f2d3f30b2 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 @@ -78,8 +78,8 @@ const ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS = ` const codegenNativeComponent = require('codegenNativeComponent'); import type { - BubblingEvent, - DirectEvent, + BubblingEventHandler, + DirectEventHandler, WithDefault, } from 'CodegenTypes'; @@ -92,8 +92,8 @@ type ModuleProps = $ReadOnly<{| boolean_default_true_optional_both?: ?WithDefault, // Events - onDirectEventDefinedInlineNull: (event: DirectEvent) => void, - onBubblingEventDefinedInlineNull: (event: BubblingEvent) => void, + onDirectEventDefinedInlineNull: DirectEventHandler, + onBubblingEventDefinedInlineNull: BubblingEventHandler, |}>; export default codegenNativeComponent('Module', { @@ -331,8 +331,8 @@ const codegenNativeComponent = require('codegenNativeComponent'); import type { Int32, Float, - BubblingEvent, - DirectEvent, + BubblingEventHandler, + DirectEventHandler, } from 'CodegenTypes'; import type {ViewProps} from 'ViewPropTypes'; @@ -342,226 +342,77 @@ type ModuleProps = $ReadOnly<{| // No Props // Events - onDirectEventDefinedInline: ( - event: DirectEvent< + onDirectEventDefinedInline: + DirectEventHandler< $ReadOnly<{| ${EVENT_DEFINITION} |}>, >, - ) => void, - onDirectEventDefinedInlineOptionalKey?: ( - event: DirectEvent< + onDirectEventDefinedInlineOptionalKey?: + DirectEventHandler< $ReadOnly<{| ${EVENT_DEFINITION} |}>, >, - ) => void, - onDirectEventDefinedInlineOptionalValue: ?( - event: DirectEvent< + onDirectEventDefinedInlineOptionalValue: ? + DirectEventHandler< $ReadOnly<{| ${EVENT_DEFINITION} |}>, >, - ) => void, - onDirectEventDefinedInlineOptionalBoth?: ?( - event: DirectEvent< + onDirectEventDefinedInlineOptionalBoth?: ? + DirectEventHandler< $ReadOnly<{| ${EVENT_DEFINITION} |}>, >, - ) => void, - onDirectEventDefinedInlineWithPaperName?: ?( - event: DirectEvent< + onDirectEventDefinedInlineWithPaperName?: ? + DirectEventHandler< $ReadOnly<{| ${EVENT_DEFINITION} |}>, 'paperDirectEventDefinedInlineWithPaperName', >, - ) => void, - onBubblingEventDefinedInline: ( - event: BubblingEvent< + onBubblingEventDefinedInline: + BubblingEventHandler< $ReadOnly<{| ${EVENT_DEFINITION} |}>, >, - ) => void, - onBubblingEventDefinedInlineOptionalKey?: ( - event: BubblingEvent< + onBubblingEventDefinedInlineOptionalKey?: + BubblingEventHandler< $ReadOnly<{| ${EVENT_DEFINITION} |}>, >, - ) => void, - onBubblingEventDefinedInlineOptionalValue: ?( - event: BubblingEvent< + onBubblingEventDefinedInlineOptionalValue: ? + BubblingEventHandler< $ReadOnly<{| ${EVENT_DEFINITION} |}>, >, - ) => void, - onBubblingEventDefinedInlineOptionalBoth?: ?( - event: BubblingEvent< + onBubblingEventDefinedInlineOptionalBoth?: ? + BubblingEventHandler< $ReadOnly<{| ${EVENT_DEFINITION} |}>, >, - ) => void, - onBubblingEventDefinedInlineWithPaperName?: ?( - event: BubblingEvent< + onBubblingEventDefinedInlineWithPaperName?: ? + BubblingEventHandler< $ReadOnly<{| ${EVENT_DEFINITION} |}>, + 'paperBubblingEventDefinedInlineWithPaperName' >, - 'paperBubblingEventDefinedInlineWithPaperName', - ) => void, -|}>; - -export default codegenNativeComponent('Module'); -`; - -const EVENTS_DEFINED_IN_FILE_WITH_ALL_TYPES = ` -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -const codegenNativeComponent = require('codegenNativeComponent'); - -import type {Float, Int32, BubblingEvent, DirectEvent} from 'CodegenTypes'; - -import type {ViewProps} from 'ViewPropTypes'; - -type EventInFile = $ReadOnly<{| - ${EVENT_DEFINITION} -|}>; - -type DirectEventInFile = DirectEvent; -type BubblingEventInFile = BubblingEvent; - -type DirectEventInFileWithPaperName = DirectEvent< - EventInFile, - 'paperDirectEventInFileWithPaperName', ->; -type BubblingEventInFileWithPaperName = BubblingEvent< - EventInFile, - 'paperBubblingEventInFileWithPaperName', ->; - -type ModuleProps = $ReadOnly<{| - ...ViewProps, - - // No props - - // Events - // Events defined elsewhere in file - - onDirectEventDefinedInFile: (event: DirectEventInFile) => void, - onDirectEventDefinedInFileOptionalKey?: (event: DirectEventInFile) => void, - onDirectEventDefinedInFileOptionalValue: ?(event: DirectEventInFile) => void, - onDirectEventDefinedInFileOptionalBoth?: ?(event: DirectEventInFile) => void, - onDirectEventDefinedInFileWithPaperName?: ?( - event: DirectEventInFileWithPaperName, - ) => void, - - onBubblingEventDefinedInFile: (event: BubblingEventInFile) => void, - onBubblingEventDefinedInFileOptionalKey?: ( - event: BubblingEventInFile, - ) => void, - onBubblingEventDefinedInFileOptionalValue: ?( - event: BubblingEventInFile, - ) => void, - onBubblingEventDefinedInFileOptionalBoth?: ?( - event: BubblingEventInFile, - ) => void, - onBubblingEventDefinedInFileWithPaperName?: ?( - event: BubblingEventInFileWithPaperName, - ) => void, -|}>; - -export default codegenNativeComponent('Module'); -`; - -const EVENTS_DEFINED_AS_NULL_IN_FILE = ` -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -import type {BubblingEvent, DirectEvent} from 'CodegenTypes'; -import type {ViewProps} from 'ViewPropTypes'; - -const codegenNativeComponent = require('codegenNativeComponent'); - -type DirectEventDefinedInFileNull = DirectEvent; -type BubblingEventDefinedInFileNull = BubblingEvent; - -type DirectEventDefinedInFileNullWithPaperName = DirectEvent< - null, - 'paperDirectEventDefinedInFileNullWithPaperName', ->; -type BubblingEventDefinedInFileNullWithPaperName = DirectEvent< - null, - 'paperBubblingEventDefinedInFileNullWithPaperName', ->; - -type ModuleProps = $ReadOnly<{| - ...ViewProps, - - // No props - - // Events defined elsewhere in file - onDirectEventDefinedInFileNull: (event: DirectEventDefinedInFileNull) => void, - onDirectEventDefinedInFileNullOptionalKey?: ( - event: DirectEventDefinedInFileNull, - ) => void, - onDirectEventDefinedInFileNullOptionalValue: ?( - event: DirectEventDefinedInFileNull, - ) => void, - onDirectEventDefinedInFileNullOptionalBoth?: ?( - event: DirectEventDefinedInFileNull, - ) => void, - onDirectEventDefinedInFileNullWithPaperName?: ?( - event: DirectEventDefinedInFileNullWithPaperName, - ) => void, - - onBubblingEventDefinedInFileNull: ( - event: BubblingEventDefinedInFileNull, - ) => void, - onBubblingEventDefinedInFileNullOptionalKey?: ( - event: BubblingEventDefinedInFileNull, - ) => void, - onBubblingEventDefinedInFileNullOptionalValue: ?( - event: BubblingEventDefinedInFileNull, - ) => void, - onBubblingEventDefinedInFileNullOptionalBoth?: ?( - event: BubblingEventDefinedInFileNull, - ) => void, - onBubblingEventDefinedInFileNullOptionalBoth?: ?( - event: BubblingEventDefinedInFileNullWithPaperName, - ) => void, |}>; export default codegenNativeComponent('Module'); @@ -581,7 +432,13 @@ const EVENTS_DEFINED_AS_NULL_INLINE = ` 'use strict'; -import type {BubblingEvent, DirectEvent} from 'CodegenTypes'; +const codegenNativeComponent = require('codegenNativeComponent'); + +import type { + BubblingEventHandler, + DirectEventHandler, +} from 'CodegenTypese'; + import type {ViewProps} from 'ViewPropTypes'; const codegenNativeComponent = require('codegenNativeComponent'); @@ -592,36 +449,25 @@ type ModuleProps = $ReadOnly<{| // No props // Events defined inline - onDirectEventDefinedInlineNull: (event: DirectEvent) => void, - onDirectEventDefinedInlineNullOptionalKey?: ( - event: DirectEvent, - ) => void, - onDirectEventDefinedInlineNullOptionalValue: ?( - event: DirectEvent, - ) => void, - onDirectEventDefinedInlineNullOptionalBoth?: ?( - event: DirectEvent, - ) => void, - onDirectEventDefinedInlineNullWithPaperName?: ?( - event: DirectEvent, - ) => void, + onDirectEventDefinedInlineNull:DirectEventHandler, + onDirectEventDefinedInlineNullOptionalKey?: DirectEventHandler, + onDirectEventDefinedInlineNullOptionalValue: ?DirectEventHandler, + onDirectEventDefinedInlineNullOptionalBoth?: DirectEventHandler, + onDirectEventDefinedInlineNullWithPaperName?: ? + DirectEventHandler< + null, + 'paperDirectEventDefinedInlineNullWithPaperName', + >, - onBubblingEventDefinedInlineNull: (event: BubblingEvent) => void, - onBubblingEventDefinedInlineNullOptionalKey?: ( - event: BubblingEvent, - ) => void, - onBubblingEventDefinedInlineNullOptionalValue: ?( - event: BubblingEvent, - ) => void, - onBubblingEventDefinedInlineNullOptionalBoth?: ?( - event: BubblingEvent, - ) => void, - onBubblingEventDefinedInlineNullWithPaperName?: ?( - event: BubblingEvent< + onBubblingEventDefinedInlineNull: BubblingEventHandler, + onBubblingEventDefinedInlineNullOptionalKey?: BubblingEventHandler, + onBubblingEventDefinedInlineNullOptionalValue: ?BubblingEventHandler, + onBubblingEventDefinedInlineNullOptionalBoth?: ?BubblingEventHandler, + onBubblingEventDefinedInlineNullWithPaperName?: ? + BubblingEventHandler< null, 'paperBubblingEventDefinedInlineNullWithPaperName', >, - ) => void, |}>; export default codegenNativeComponent('Module'); @@ -640,7 +486,11 @@ const PROPS_AND_EVENTS_TYPES_EXPORTED = ` 'use strict'; -import type {BubblingEvent, DirectEvent} from 'CodegenTypes'; +import type { + BubblingEventHandler, + DirectEventHandler, +} from 'CodegenTypes'; + import type {ViewProps} from 'ViewPropTypes'; const codegenNativeComponent = require('codegenNativeComponent'); @@ -655,21 +505,10 @@ export type ModuleProps = $ReadOnly<{| // No props // Events defined inline - onBubblingEventDefinedInline: (event: BubblingEvent) => void, - onBubblingEventDefinedInlineWithPaperName: ( - event: BubblingEvent< - EventInFile, - 'paperBubblingEventDefinedInlineWithPaperName', - >, - ) => void, - - onDirectEventDefinedInline: (event: DirectEvent) => void, - onDirectEventDefinedInlineWithPaperName: ( - event: DirectEvent< - EventInFile, - 'paperDirectEventDefinedInlineWithPaperName', - >, - ) => void, + onBubblingEventDefinedInline: BubblingEventHandler, + onBubblingEventDefinedInlineWithPaperName: BubblingEventHandler, + onDirectEventDefinedInline: DirectEventHandler, + onDirectEventDefinedInlineWithPaperName: DirectEventHandler, |}>; export default codegenNativeComponent('Module'); @@ -693,8 +532,8 @@ const codegenNativeCommands = require('codegenNativeCommands'); import type { Int32, - BubblingEvent, - DirectEvent, + BubblingEventHandler, + DirectEventHandler, } from 'CodegenTypes'; import type {ViewProps} from 'ViewPropTypes'; @@ -720,8 +559,6 @@ module.exports = { ONE_OF_EACH_PROP_EVENT_DEFAULT_AND_OPTIONS, NO_PROPS_EVENTS_ONLY_DEPRECATED_VIEW_CONFIG_NAME_OPTION, EVENTS_DEFINED_INLINE_WITH_ALL_TYPES, - EVENTS_DEFINED_IN_FILE_WITH_ALL_TYPES, - EVENTS_DEFINED_AS_NULL_IN_FILE, EVENTS_DEFINED_AS_NULL_INLINE, PROPS_AND_EVENTS_TYPES_EXPORTED, COMMANDS_DEFINED_WITH_ALL_TYPES, 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 71e7218e5bf..92d02f2d923 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 @@ -905,151 +905,6 @@ Object { } `; -exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_AS_NULL_IN_FILE 1`] = ` -Object { - "modules": Object { - "Module": Object { - "components": Object { - "Module": Object { - "commands": Array [], - "events": Array [ - Object { - "bubblingType": "direct", - "name": "onDirectEventDefinedInFileNull", - "optional": false, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "direct", - "name": "onDirectEventDefinedInFileNullOptionalKey", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "direct", - "name": "onDirectEventDefinedInFileNullOptionalValue", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "direct", - "name": "onDirectEventDefinedInFileNullOptionalBoth", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "direct", - "name": "onDirectEventDefinedInFileNullWithPaperName", - "optional": true, - "paperTopLevelNameDeprecated": "paperDirectEventDefinedInFileNullWithPaperName", - "typeAnnotation": Object { - "argument": Object { - "properties": Array [], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "bubble", - "name": "onBubblingEventDefinedInFileNull", - "optional": false, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "bubble", - "name": "onBubblingEventDefinedInFileNullOptionalKey", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "bubble", - "name": "onBubblingEventDefinedInFileNullOptionalValue", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "bubble", - "name": "onBubblingEventDefinedInFileNullOptionalBoth", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "direct", - "name": "onBubblingEventDefinedInFileNullOptionalBoth", - "optional": true, - "paperTopLevelNameDeprecated": "paperBubblingEventDefinedInFileNullWithPaperName", - "typeAnnotation": Object { - "argument": Object { - "properties": Array [], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - ], - "extendsProps": Array [ - Object { - "knownTypeName": "ReactNativeCoreViewProps", - "type": "ReactNativeBuiltInType", - }, - ], - "props": Array [], - }, - }, - }, - }, -} -`; - exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_AS_NULL_INLINE 1`] = ` Object { "modules": Object { @@ -1195,2301 +1050,6 @@ Object { } `; -exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_IN_FILE_WITH_ALL_TYPES 1`] = ` -Object { - "modules": Object { - "Module": Object { - "components": Object { - "Module": Object { - "commands": Array [], - "events": Array [ - Object { - "bubblingType": "direct", - "name": "onDirectEventDefinedInFile", - "optional": false, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_key", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_value", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_both", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "string_required", - "optional": false, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_value", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_both", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_required", - "optional": false, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_key", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_both", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_key", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_value", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "enum_required", - "optional": false, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_key", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_value", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_both", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "object_required", - "optional": false, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_key", - "optional": true, - "properties": Array [ - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_value", - "optional": true, - "properties": Array [ - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_both", - "optional": true, - "properties": Array [ - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_required_nested_2_layers", - "optional": false, - "properties": Array [ - Object { - "name": "object_optional_nested_1_layer", - "optional": true, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "direct", - "name": "onDirectEventDefinedInFileOptionalKey", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_key", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_value", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_both", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "string_required", - "optional": false, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_value", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_both", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_required", - "optional": false, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_key", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_both", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_key", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_value", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "enum_required", - "optional": false, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_key", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_value", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_both", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "object_required", - "optional": false, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_key", - "optional": true, - "properties": Array [ - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_value", - "optional": true, - "properties": Array [ - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_both", - "optional": true, - "properties": Array [ - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_required_nested_2_layers", - "optional": false, - "properties": Array [ - Object { - "name": "object_optional_nested_1_layer", - "optional": true, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "direct", - "name": "onDirectEventDefinedInFileOptionalValue", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_key", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_value", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_both", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "string_required", - "optional": false, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_value", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_both", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_required", - "optional": false, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_key", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_both", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_key", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_value", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "enum_required", - "optional": false, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_key", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_value", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_both", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "object_required", - "optional": false, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_key", - "optional": true, - "properties": Array [ - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_value", - "optional": true, - "properties": Array [ - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_both", - "optional": true, - "properties": Array [ - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_required_nested_2_layers", - "optional": false, - "properties": Array [ - Object { - "name": "object_optional_nested_1_layer", - "optional": true, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "direct", - "name": "onDirectEventDefinedInFileOptionalBoth", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_key", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_value", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_both", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "string_required", - "optional": false, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_value", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_both", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_required", - "optional": false, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_key", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_both", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_key", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_value", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "enum_required", - "optional": false, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_key", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_value", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_both", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "object_required", - "optional": false, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_key", - "optional": true, - "properties": Array [ - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_value", - "optional": true, - "properties": Array [ - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_both", - "optional": true, - "properties": Array [ - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_required_nested_2_layers", - "optional": false, - "properties": Array [ - Object { - "name": "object_optional_nested_1_layer", - "optional": true, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "direct", - "name": "onDirectEventDefinedInFileWithPaperName", - "optional": true, - "paperTopLevelNameDeprecated": "paperDirectEventInFileWithPaperName", - "typeAnnotation": Object { - "argument": Object { - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_key", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_value", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_both", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "string_required", - "optional": false, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_value", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_both", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_required", - "optional": false, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_key", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_both", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_key", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_value", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "enum_required", - "optional": false, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_key", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_value", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_both", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "object_required", - "optional": false, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_key", - "optional": true, - "properties": Array [ - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_value", - "optional": true, - "properties": Array [ - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_both", - "optional": true, - "properties": Array [ - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_required_nested_2_layers", - "optional": false, - "properties": Array [ - Object { - "name": "object_optional_nested_1_layer", - "optional": true, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "bubble", - "name": "onBubblingEventDefinedInFile", - "optional": false, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_key", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_value", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_both", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "string_required", - "optional": false, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_value", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_both", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_required", - "optional": false, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_key", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_both", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_key", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_value", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "enum_required", - "optional": false, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_key", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_value", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_both", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "object_required", - "optional": false, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_key", - "optional": true, - "properties": Array [ - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_value", - "optional": true, - "properties": Array [ - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_both", - "optional": true, - "properties": Array [ - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_required_nested_2_layers", - "optional": false, - "properties": Array [ - Object { - "name": "object_optional_nested_1_layer", - "optional": true, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "bubble", - "name": "onBubblingEventDefinedInFileOptionalKey", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_key", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_value", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_both", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "string_required", - "optional": false, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_value", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_both", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_required", - "optional": false, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_key", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_both", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_key", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_value", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "enum_required", - "optional": false, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_key", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_value", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_both", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "object_required", - "optional": false, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_key", - "optional": true, - "properties": Array [ - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_value", - "optional": true, - "properties": Array [ - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_both", - "optional": true, - "properties": Array [ - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_required_nested_2_layers", - "optional": false, - "properties": Array [ - Object { - "name": "object_optional_nested_1_layer", - "optional": true, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "bubble", - "name": "onBubblingEventDefinedInFileOptionalValue", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_key", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_value", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_both", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "string_required", - "optional": false, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_value", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_both", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_required", - "optional": false, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_key", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_both", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_key", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_value", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "enum_required", - "optional": false, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_key", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_value", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_both", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "object_required", - "optional": false, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_key", - "optional": true, - "properties": Array [ - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_value", - "optional": true, - "properties": Array [ - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_both", - "optional": true, - "properties": Array [ - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_required_nested_2_layers", - "optional": false, - "properties": Array [ - Object { - "name": "object_optional_nested_1_layer", - "optional": true, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "bubble", - "name": "onBubblingEventDefinedInFileOptionalBoth", - "optional": true, - "typeAnnotation": Object { - "argument": Object { - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_key", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_value", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_both", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "string_required", - "optional": false, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_value", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_both", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_required", - "optional": false, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_key", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_both", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_key", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_value", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "enum_required", - "optional": false, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_key", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_value", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_both", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "object_required", - "optional": false, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_key", - "optional": true, - "properties": Array [ - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_value", - "optional": true, - "properties": Array [ - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_both", - "optional": true, - "properties": Array [ - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_required_nested_2_layers", - "optional": false, - "properties": Array [ - Object { - "name": "object_optional_nested_1_layer", - "optional": true, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - Object { - "bubblingType": "bubble", - "name": "onBubblingEventDefinedInFileWithPaperName", - "optional": true, - "paperTopLevelNameDeprecated": "paperBubblingEventInFileWithPaperName", - "typeAnnotation": Object { - "argument": Object { - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_key", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_value", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "boolean_optional_both", - "optional": true, - "type": "BooleanTypeAnnotation", - }, - Object { - "name": "string_required", - "optional": false, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_value", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "string_optional_both", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_required", - "optional": false, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_key", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "float_optional_both", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_key", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_value", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "enum_required", - "optional": false, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_key", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_value", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "enum_optional_both", - "optional": true, - "options": Array [ - Object { - "name": "small", - }, - Object { - "name": "large", - }, - ], - "type": "StringEnumTypeAnnotation", - }, - Object { - "name": "object_required", - "optional": false, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "BooleanTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_key", - "optional": true, - "properties": Array [ - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_value", - "optional": true, - "properties": Array [ - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_optional_both", - "optional": true, - "properties": Array [ - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - Object { - "name": "object_required_nested_2_layers", - "optional": false, - "properties": Array [ - Object { - "name": "object_optional_nested_1_layer", - "optional": true, - "properties": Array [ - Object { - "name": "boolean_required", - "optional": false, - "type": "Int32TypeAnnotation", - }, - Object { - "name": "string_optional_key", - "optional": true, - "type": "StringTypeAnnotation", - }, - Object { - "name": "float_optional_value", - "optional": true, - "type": "FloatTypeAnnotation", - }, - Object { - "name": "int32_optional_both", - "optional": true, - "type": "Int32TypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - ], - "type": "ObjectTypeAnnotation", - }, - "type": "EventTypeAnnotation", - }, - }, - ], - "extendsProps": Array [ - Object { - "knownTypeName": "ReactNativeCoreViewProps", - "type": "ReactNativeBuiltInType", - }, - ], - "props": Array [], - }, - }, - }, - }, -} -`; - exports[`RN Codegen Flow Parser can generate fixture EVENTS_DEFINED_INLINE_WITH_ALL_TYPES 1`] = ` Object { "modules": Object { @@ -5546,6 +3106,7 @@ Object { "bubblingType": "bubble", "name": "onBubblingEventDefinedInlineWithPaperName", "optional": true, + "paperTopLevelNameDeprecated": "paperBubblingEventDefinedInlineWithPaperName", "typeAnnotation": Object { "argument": Object { "properties": Array [ diff --git a/packages/react-native-codegen/src/parsers/flow/events.js b/packages/react-native-codegen/src/parsers/flow/events.js index 67666fb9301..edb08b02b6b 100644 --- a/packages/react-native-codegen/src/parsers/flow/events.js +++ b/packages/react-native-codegen/src/parsers/flow/events.js @@ -76,8 +76,8 @@ function findEventArgumentsAndType( paperTopLevelNameDeprecated: paperName, bubblingType, }; - } else if (name === 'BubblingEvent' || name === 'DirectEvent') { - const eventType = name === 'BubblingEvent' ? 'bubble' : 'direct'; + } else if (name === 'BubblingEventHandler' || name === 'DirectEventHandler') { + const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct'; const paperTopLevelNameDeprecated = typeAnnotation.typeParameters.params.length > 1 ? typeAnnotation.typeParameters.params[1].value @@ -146,7 +146,11 @@ function buildEventSchema( ? property.value.typeAnnotation : property.value; - if (typeAnnotation.type !== 'FunctionTypeAnnotation') { + if ( + typeAnnotation.type !== 'GenericTypeAnnotation' || + (typeAnnotation.id.name !== 'BubblingEventHandler' && + typeAnnotation.id.name !== 'DirectEventHandler') + ) { return null; } @@ -154,7 +158,7 @@ function buildEventSchema( argumentProps, bubblingType, paperTopLevelNameDeprecated, - } = findEventArgumentsAndType(typeAnnotation.params[0].typeAnnotation, types); + } = findEventArgumentsAndType(typeAnnotation, types); if (bubblingType && argumentProps) { if (paperTopLevelNameDeprecated != null) { diff --git a/packages/react-native-codegen/src/parsers/flow/props.js b/packages/react-native-codegen/src/parsers/flow/props.js index d062f25f667..327cefff6cc 100644 --- a/packages/react-native-codegen/src/parsers/flow/props.js +++ b/packages/react-native-codegen/src/parsers/flow/props.js @@ -194,7 +194,11 @@ function buildPropSchema(property): ?PropTypeShape { : property.value; let type = typeAnnotation.type; - if (type === 'FunctionTypeAnnotation') { + if ( + type === 'GenericTypeAnnotation' && + (typeAnnotation.id.name === 'DirectEventHandler' || + typeAnnotation.id.name === 'BubblingEventHandler') + ) { return null; }