RN: View Type Refinement for Events

Summary:
Adds some missing props to the type definition for `View`.

Also, changed some of the callbacks to return `mixed`. (Sometime in the near future, we should align on this for event callbacks.)

Changelog:
[Changed] Revised View Event Callback Types

Reviewed By: TheSavior

Differential Revision: D18278877

fbshipit-source-id: a36d5c1c9b9aed6718bd2abb024700a08a9deaeb
This commit is contained in:
Tim Yung 2019-11-02 16:54:07 -07:00 коммит произвёл Facebook Github Bot
Родитель 5a943ec235
Коммит 654d9d07c3
1 изменённых файлов: 26 добавлений и 7 удалений

Просмотреть файл

@ -10,7 +10,14 @@
'use strict';
import type {PressEvent, Layout, LayoutEvent} from '../../Types/CoreEventTypes';
import type {
BlurEvent,
FocusEvent,
MouseEvent,
PressEvent,
Layout,
LayoutEvent,
} from '../../Types/CoreEventTypes';
import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType';
import type {Node} from 'react';
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
@ -25,13 +32,18 @@ import type {
export type ViewLayout = Layout;
export type ViewLayoutEvent = LayoutEvent;
type BubblingEventProps = $ReadOnly<{|
onBlur?: ?(event: BlurEvent) => mixed,
onFocus?: ?(event: FocusEvent) => mixed,
|}>;
type DirectEventProps = $ReadOnly<{|
/**
* When `accessible` is true, the system will try to invoke this function
* when the user performs an accessibility custom action.
*
*/
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => void,
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
/**
* When `accessible` is true, the system will try to invoke this function
@ -39,7 +51,7 @@ type DirectEventProps = $ReadOnly<{|
*
* See http://facebook.github.io/react-native/docs/view.html#onaccessibilitytap
*/
onAccessibilityTap?: ?() => void,
onAccessibilityTap?: ?() => mixed,
/**
* Invoked on mount and layout changes with:
@ -60,7 +72,7 @@ type DirectEventProps = $ReadOnly<{|
*
* See http://facebook.github.io/react-native/docs/view.html#onmagictap
*/
onMagicTap?: ?() => void,
onMagicTap?: ?() => mixed,
/**
* When `accessible` is `true`, the system will invoke this function when the
@ -68,7 +80,12 @@ type DirectEventProps = $ReadOnly<{|
*
* See http://facebook.github.io/react-native/docs/view.html#onaccessibilityescape
*/
onAccessibilityEscape?: ?() => void,
onAccessibilityEscape?: ?() => mixed,
|}>;
type MouseEventProps = $ReadOnly<{|
onMouseEnter?: (event: MouseEvent) => void,
onMouseLeave?: (event: MouseEvent) => void,
|}>;
type TouchEventProps = $ReadOnly<{|
@ -279,7 +296,7 @@ type AndroidViewProps = $ReadOnly<{|
*
* @platform android
*/
hasTVPreferredFocus?: boolean,
hasTVPreferredFocus?: ?boolean,
/**
* TV next focus down (see documentation for the View component).
@ -328,7 +345,7 @@ type AndroidViewProps = $ReadOnly<{|
*
* @platform android
*/
onClick?: () => void,
onClick?: ?(event: PressEvent) => mixed,
|}>;
type IOSViewProps = $ReadOnly<{|
@ -371,8 +388,10 @@ type IOSViewProps = $ReadOnly<{|
|}>;
export type ViewProps = $ReadOnly<{|
...BubblingEventProps,
...DirectEventProps,
...GestureResponderEventProps,
...MouseEventProps,
...TouchEventProps,
...AndroidViewProps,
...IOSViewProps,