[flow] Update Flow libdef with Feb 2019 changes (#5599)

This corresponds to three `flow-typed` PRs:

1. https://github.com/flow-typed/flow-typed/pull/3140 Get rid of deprecated Navigator exports in 3.0
2. https://github.com/flow-typed/flow-typed/pull/3147 Refine AnimatedValue type
3. https://github.com/flow-typed/flow-typed/pull/3148 Introduce SafeAreaViewInsets type
This commit is contained in:
Ashoat Tevosyan 2019-02-16 19:30:36 -05:00 committed by Brent Vatne
parent 9e36d3e4c9
commit d3040e52b3

View File

@ -44,18 +44,68 @@ declare module 'react-navigation' {
}; };
declare type ImageSource = ImageURISource | number | Array<ImageURISource>; declare type ImageSource = ImageURISource | number | Array<ImageURISource>;
// This one is too large to copy. Actual definition is in // This is copied from
// react-native/Libraries/Animated/src/nodes/AnimatedValue.js // react-native/Libraries/Animated/src/nodes/AnimatedInterpolation.js
declare type AnimatedValue = Object; declare type ExtrapolateType = 'extend' | 'identity' | 'clamp';
declare type InterpolationConfigType = {
declare type HeaderForceInset = { inputRange: Array<number>,
horizontal?: string, outputRange: Array<number> | Array<string>,
vertical?: string, easing?: (input: number) => number,
left?: string, extrapolate?: ExtrapolateType,
right?: string, extrapolateLeft?: ExtrapolateType,
top?: string, extrapolateRight?: ExtrapolateType,
bottom?: string,
}; };
declare class AnimatedInterpolation {
interpolate(config: InterpolationConfigType): AnimatedInterpolation;
}
// This is copied from
// react-native/Libraries/Animated/src/animations/Animation.js
declare type EndResult = { finished: boolean };
declare type EndCallback = (result: EndResult) => void;
declare class Animation {
start(
fromValue: number,
onUpdate: (value: number) => void,
onEnd: ?EndCallback,
previousAnimation: ?Animation,
animatedValue: AnimatedValue
): void;
stop(): void;
}
// This is vaguely copied from
// react-native/Libraries/Animated/src/nodes/AnimatedTracking.js
declare class AnimatedTracking {
constructor(
value: AnimatedValue,
parent: any,
animationClass: any,
animationConfig: Object,
callback?: ?EndCallback
): void;
update(): void;
}
// This is vaguely copied from
// react-native/Libraries/Animated/src/nodes/AnimatedValue.js
declare type ValueListenerCallback = (state: { value: number }) => void;
declare class AnimatedValue {
constructor(value: number): void;
setValue(value: number): void;
setOffset(offset: number): void;
flattenOffset(): void;
extractOffset(): void;
addListener(callback: ValueListenerCallback): string;
removeListener(id: string): void;
removeAllListeners(): void;
stopAnimation(callback?: ?(value: number) => void): void;
resetAnimation(callback?: ?(value: number) => void): void;
interpolate(config: InterpolationConfigType): AnimatedInterpolation;
animate(animation: Animation, callback: ?EndCallback): void;
stopTracking(): void;
track(tracking: AnimatedTracking): void;
}
/** /**
* Next, all the type declarations * Next, all the type declarations
@ -385,7 +435,7 @@ declare module 'react-navigation' {
headerPressColorAndroid?: string, headerPressColorAndroid?: string,
headerRight?: React$Node, headerRight?: React$Node,
headerStyle?: ViewStyleProp, headerStyle?: ViewStyleProp,
headerForceInset?: HeaderForceInset, headerForceInset?: _SafeAreaViewInsets,
headerBackground?: React$Node | React$ElementType, headerBackground?: React$Node | React$ElementType,
gesturesEnabled?: boolean, gesturesEnabled?: boolean,
gestureResponseDistance?: { vertical?: number, horizontal?: number }, gestureResponseDistance?: { vertical?: number, horizontal?: number },
@ -892,10 +942,6 @@ declare module 'react-navigation' {
navigatorConfig?: NavigatorConfig navigatorConfig?: NavigatorConfig
): NavigationNavigator<S, O, *>; ): NavigationNavigator<S, O, *>;
declare export function StackNavigator(
routeConfigMap: NavigationRouteConfigMap,
stackConfig?: StackNavigatorConfig
): NavigationNavigator<*, *, *>;
declare export function createStackNavigator( declare export function createStackNavigator(
routeConfigMap: NavigationRouteConfigMap, routeConfigMap: NavigationRouteConfigMap,
stackConfig?: StackNavigatorConfig stackConfig?: StackNavigatorConfig
@ -920,14 +966,6 @@ declare module 'react-navigation' {
removeClippedSubviews?: boolean, removeClippedSubviews?: boolean,
containerOptions?: void, containerOptions?: void,
|}; |};
declare export function TabNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _TabNavigatorConfig
): NavigationNavigator<*, *, *>;
declare export function createTabNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _TabNavigatorConfig
): NavigationNavigator<*, *, *>;
/* TODO: fix the config for each of these tab navigator types */ /* TODO: fix the config for each of these tab navigator types */
declare export function createBottomTabNavigator( declare export function createBottomTabNavigator(
routeConfigs: NavigationRouteConfigMap, routeConfigs: NavigationRouteConfigMap,
@ -940,10 +978,6 @@ declare module 'react-navigation' {
declare type _SwitchNavigatorConfig = {| declare type _SwitchNavigatorConfig = {|
...NavigationSwitchRouterConfig, ...NavigationSwitchRouterConfig,
|}; |};
declare export function SwitchNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _SwitchNavigatorConfig
): NavigationNavigator<*, *, *>;
declare export function createSwitchNavigator( declare export function createSwitchNavigator(
routeConfigs: NavigationRouteConfigMap, routeConfigs: NavigationRouteConfigMap,
config?: _SwitchNavigatorConfig config?: _SwitchNavigatorConfig
@ -965,10 +999,6 @@ declare module 'react-navigation' {
..._DrawerViewConfig, ..._DrawerViewConfig,
containerConfig?: void, containerConfig?: void,
}>; }>;
declare export function DrawerNavigator(
routeConfigs: NavigationRouteConfigMap,
config?: _DrawerNavigatorConfig
): NavigationNavigator<*, *, *>;
declare export function createDrawerNavigator( declare export function createDrawerNavigator(
routeConfigs: NavigationRouteConfigMap, routeConfigs: NavigationRouteConfigMap,
config?: _DrawerNavigatorConfig config?: _DrawerNavigatorConfig
@ -1049,15 +1079,16 @@ declare module 'react-navigation' {
declare export var Card: React$ComponentType<_CardProps>; declare export var Card: React$ComponentType<_CardProps>;
declare type _SafeAreaViewForceInsetValue = 'always' | 'never' | number; declare type _SafeAreaViewForceInsetValue = 'always' | 'never' | number;
declare type _SafeAreaViewInsets = $Shape<{
top: _SafeAreaViewForceInsetValue,
bottom: _SafeAreaViewForceInsetValue,
left: _SafeAreaViewForceInsetValue,
right: _SafeAreaViewForceInsetValue,
vertical: _SafeAreaViewForceInsetValue,
horizontal: _SafeAreaViewForceInsetValue,
}>;
declare type _SafeAreaViewProps = { declare type _SafeAreaViewProps = {
forceInset?: { forceInset?: _SafeAreaViewInsets,
top?: _SafeAreaViewForceInsetValue,
bottom?: _SafeAreaViewForceInsetValue,
left?: _SafeAreaViewForceInsetValue,
right?: _SafeAreaViewForceInsetValue,
vertical?: _SafeAreaViewForceInsetValue,
horizontal?: _SafeAreaViewForceInsetValue,
},
children?: React$Node, children?: React$Node,
style?: AnimatedViewStyleProp, style?: AnimatedViewStyleProp,
}; };
@ -1208,7 +1239,10 @@ declare module 'react-navigation' {
}; };
declare export var TabBarBottom: React$ComponentType<_TabBarBottomProps>; declare export var TabBarBottom: React$ComponentType<_TabBarBottomProps>;
declare export function withNavigation<Props: {}, ComponentType: React$ComponentType<Props>>( declare export function withNavigation<
Props: {},
ComponentType: React$ComponentType<Props>
>(
Component: ComponentType Component: ComponentType
): React$ComponentType< ): React$ComponentType<
$Diff< $Diff<
@ -1218,9 +1252,14 @@ declare module 'react-navigation' {
} }
> >
>; >;
declare export function withNavigationFocus<Props: {}, ComponentType: React$ComponentType<Props>>( declare export function withNavigationFocus<
Props: {},
ComponentType: React$ComponentType<Props>
>(
Component: ComponentType Component: ComponentType
): React$ComponentType<$Diff<React$ElementConfig<ComponentType>, { isFocused: boolean | void }>>; ): React$ComponentType<
$Diff<React$ElementConfig<ComponentType>, { isFocused: boolean | void }>
>;
declare export function getNavigation<State: NavigationState, Options: {}>( declare export function getNavigation<State: NavigationState, Options: {}>(
router: NavigationRouter<State, Options>, router: NavigationRouter<State, Options>,