Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down Expand Up @@ -49,6 +49,7 @@ export type ShareActionSheetIOSOptions = Readonly<{
export type ShareActionSheetError = Readonly<{
domain: string,
code: string,
// $FlowFixMe[unclear-type]
userInfo?: ?Object,
message: string,
}>;
Expand Down Expand Up @@ -155,7 +156,9 @@ const ActionSheetIOS = {
*/
showShareActionSheetWithOptions(
options: ShareActionSheetIOSOptions,
// $FlowFixMe[unclear-type]
failureCallback: Function | ((error: ShareActionSheetError) => void),
// $FlowFixMe[unclear-type]
successCallback: Function | ((success: boolean, method: ?string) => void),
) {
invariant(
Expand Down
9 changes: 8 additions & 1 deletion packages/react-native/Libraries/Alert/Alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand All @@ -26,6 +26,7 @@ export type AlertButtonStyle = 'default' | 'cancel' | 'destructive';

export type AlertButton = {
text?: string,
// $FlowFixMe[unclear-type]
onPress?: ?((value?: string) => any) | ?Function,
isPreferred?: boolean,
style?: AlertButtonStyle,
Expand Down Expand Up @@ -121,6 +122,7 @@ class Alert {
cancelable: false,
};

// $FlowFixMe[sketchy-null-bool]
if (options && options.cancelable) {
config.cancelable = options.cancelable;
}
Expand All @@ -141,6 +143,7 @@ class Alert {
config.buttonNegative = buttonNegative.text || '';
}
if (buttonPositive) {
// $FlowFixMe[sketchy-null-string]
config.buttonPositive = buttonPositive.text || defaultPositiveText;
}

Expand Down Expand Up @@ -186,6 +189,7 @@ class Alert {
options?: AlertOptions,
): void {
if (Platform.OS === 'ios') {
// $FlowFixMe[unclear-type]
let callbacks: Array<?any> = [];
const buttons = [];
let cancelButtonKey;
Expand All @@ -201,9 +205,11 @@ class Alert {
} else if (btn.style === 'destructive') {
destructiveButtonKey = String(index);
}
// $FlowFixMe[sketchy-null-bool]
if (btn.isPreferred) {
preferredButtonKey = String(index);
}
// $FlowFixMe[sketchy-null-string]
if (btn.text || index < (callbackOrButtons || []).length - 1) {
const btnDef: {[number]: string} = {};
btnDef[index] = btn.text || '';
Expand All @@ -215,6 +221,7 @@ class Alert {
alertWithArgs(
{
title: title || '',
// $FlowFixMe[sketchy-null-string]
message: message || undefined,
buttons,
type: type || undefined,
Expand Down
18 changes: 17 additions & 1 deletion packages/react-native/Libraries/Animated/AnimatedEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand All @@ -29,6 +29,7 @@ export type EventConfig<T> = {
};

export function attachNativeEventImpl(
// $FlowFixMe[unclear-type]
viewRef: any,
eventName: string,
argMapping: ReadonlyArray<?Mapping>,
Expand Down Expand Up @@ -57,6 +58,7 @@ export function attachNativeEventImpl(
};

invariant(
// $FlowFixMe[sketchy-null-mixed]
argMapping[0] && argMapping[0].nativeEvent,
'Native driven events only support animated values contained inside `nativeEvent`.',
);
Expand Down Expand Up @@ -91,7 +93,9 @@ export function attachNativeEventImpl(
};
}

// $FlowFixMe[unclear-type]
function validateMapping(argMapping: ReadonlyArray<?Mapping>, args: any) {
// $FlowFixMe[unclear-type]
const validate = (recMapping: ?Mapping, recEvt: any, key: string) => {
if (recMapping instanceof AnimatedValue) {
invariant(
Expand Down Expand Up @@ -145,16 +149,19 @@ function validateMapping(argMapping: ReadonlyArray<?Mapping>, args: any) {

export class AnimatedEvent {
_argMapping: ReadonlyArray<?Mapping>;
// $FlowFixMe[unclear-type]
_listeners: Array<Function> = [];
_attachedEvent: ?{detach: () => void, ...};
__isNative: boolean;
__platformConfig: ?PlatformConfig;

// $FlowFixMe[unclear-type]
constructor(argMapping: ReadonlyArray<?Mapping>, config: EventConfig<any>) {
this._argMapping = argMapping;

if (config == null) {
console.warn('Animated.event now requires a second argument for options');
// $FlowFixMe[reassign-const]
config = {useNativeDriver: false};
}

Expand All @@ -166,14 +173,17 @@ export class AnimatedEvent {
this.__platformConfig = config.platformConfig;
}

// $FlowFixMe[unclear-type]
__addListener(callback: Function): void {
this._listeners.push(callback);
}

// $FlowFixMe[unclear-type]
__removeListener(callback: Function): void {
this._listeners = this._listeners.filter(listener => listener !== callback);
}

// $FlowFixMe[unclear-type]
__attach(viewRef: any, eventName: string): void {
invariant(
this.__isNative,
Expand All @@ -188,6 +198,7 @@ export class AnimatedEvent {
);
}

// $FlowFixMe[unclear-type]
__detach(viewTag: any, eventName: string): void {
invariant(
this.__isNative,
Expand All @@ -197,10 +208,12 @@ export class AnimatedEvent {
this._attachedEvent && this._attachedEvent.detach();
}

// $FlowFixMe[unclear-type]
__getHandler(): any | ((...args: any) => void) {
if (this.__isNative) {
if (__DEV__) {
let validatedMapping = false;
// $FlowFixMe[unclear-type]
return (...args: any) => {
if (!validatedMapping) {
validateMapping(this._argMapping, args);
Expand All @@ -214,6 +227,7 @@ export class AnimatedEvent {
}

let validatedMapping = false;
// $FlowFixMe[unclear-type]
return (...args: any) => {
if (__DEV__ && !validatedMapping) {
validateMapping(this._argMapping, args);
Expand All @@ -222,6 +236,7 @@ export class AnimatedEvent {

const traverse = (
recMapping: ?(Mapping | AnimatedValue),
// $FlowFixMe[unclear-type]
recEvt: any,
) => {
if (recMapping instanceof AnimatedValue) {
Expand Down Expand Up @@ -250,6 +265,7 @@ export class AnimatedEvent {
};
}

// $FlowFixMe[unclear-type]
_callListeners = (...args: any) => {
this._listeners.forEach(listener => listener(...args));
};
Expand Down
8 changes: 5 additions & 3 deletions packages/react-native/Libraries/Animated/AnimatedExports.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

// flowlint unsafe-getters-setters:off

import typeof AnimatedFlatList from './components/AnimatedFlatList';
import typeof AnimatedImage from './components/AnimatedImage';
import typeof AnimatedScrollView from './components/AnimatedScrollView';
Expand All @@ -27,7 +29,7 @@ export default {
/**
* FlatList and SectionList infer generic Type defined under their `data` and `section` props.
*/
get FlatList(): AnimatedFlatList<any> {
get FlatList(): AnimatedFlatList<> {
return require('./components/AnimatedFlatList').default;
},
/**
Expand All @@ -47,7 +49,7 @@ export default {
/**
* FlatList and SectionList infer generic Type defined under their `data` and `section` props.
*/
get SectionList(): AnimatedSectionList<any, any> {
get SectionList(): AnimatedSectionList<> {
return require('./components/AnimatedSectionList').default;
},
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down Expand Up @@ -127,7 +127,9 @@ const _combineCallbacks = function (

const maybeVectorAnim = function (
value: AnimatedValue | AnimatedValueXY | AnimatedColor,
// $FlowFixMe[unclear-type]
config: Object,
// $FlowFixMe[unclear-type]
anim: (value: AnimatedValue, config: Object) => CompositeAnimation,
): ?CompositeAnimation {
if (value instanceof AnimatedValueXY) {
Expand Down Expand Up @@ -184,8 +186,11 @@ const springImpl = function (
configuration: SpringAnimationConfig,
callback?: ?EndCallback,
): void {
// $FlowFixMe[reassign-const]
callback = _combineCallbacks(callback, configuration);
// $FlowFixMe[unclear-type]
const singleValue: any = animatedValue;
// $FlowFixMe[unclear-type]
const singleConfig: any = configuration;
singleValue.stopTracking();
if (configuration.toValue instanceof AnimatedNode) {
Expand Down Expand Up @@ -241,8 +246,11 @@ const timingImpl = function (
configuration: TimingAnimationConfig,
callback?: ?EndCallback,
): void {
// $FlowFixMe[reassign-const]
callback = _combineCallbacks(callback, configuration);
// $FlowFixMe[unclear-type]
const singleValue: any = animatedValue;
// $FlowFixMe[unclear-type]
const singleConfig: any = configuration;
singleValue.stopTracking();
if (configuration.toValue instanceof AnimatedNode) {
Expand Down Expand Up @@ -299,8 +307,11 @@ const decayImpl = function (
configuration: DecayAnimationConfig,
callback?: ?EndCallback,
): void {
// $FlowFixMe[reassign-const]
callback = _combineCallbacks(callback, configuration);
// $FlowFixMe[unclear-type]
const singleValue: any = animatedValue;
// $FlowFixMe[unclear-type]
const singleConfig: any = configuration;
singleValue.stopTracking();
singleValue.animate(new DecayAnimation(singleConfig), callback);
Expand Down Expand Up @@ -551,8 +562,11 @@ const loopImpl = function (
};

function forkEventImpl(
// $FlowFixMe[unclear-type]
event: ?AnimatedEvent | ?Function,
// $FlowFixMe[unclear-type]
listener: Function,
// $FlowFixMe[unclear-type]
): AnimatedEvent | Function {
if (!event) {
return listener;
Expand All @@ -568,7 +582,9 @@ function forkEventImpl(
}

function unforkEventImpl(
// $FlowFixMe[unclear-type]
event: ?AnimatedEvent | ?Function,
// $FlowFixMe[unclear-type]
listener: Function,
): void {
if (event && event instanceof AnimatedEvent) {
Expand All @@ -579,6 +595,7 @@ function unforkEventImpl(
const eventImpl = function <T>(
argMapping: ReadonlyArray<?Mapping>,
config: EventConfig<T>,
// $FlowFixMe[unclear-type]
): any {
const animatedEvent = new AnimatedEvent(argMapping, config);
if (animatedEvent.__isNative) {
Expand Down
4 changes: 3 additions & 1 deletion packages/react-native/Libraries/Animated/AnimatedMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down Expand Up @@ -94,6 +94,7 @@ const spring = function (
value: AnimatedValue | AnimatedValueXY | AnimatedColor,
config: SpringAnimationConfig,
): CompositeAnimation {
// $FlowFixMe[unclear-type]
const anyValue: any = value;
return {
...emptyAnimation,
Expand All @@ -108,6 +109,7 @@ const timing = function (
value: AnimatedValue | AnimatedValueXY | AnimatedColor,
config: TimingAnimationConfig,
): CompositeAnimation {
// $FlowFixMe[unclear-type]
const anyValue: any = value;
return {
...emptyAnimation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down Expand Up @@ -64,10 +64,10 @@ type PassThroughProps = Readonly<{
passthroughAnimatedPropExplicitValues?: ViewProps | null,
}>;

type LooseOmit<O extends interface {}, K extends keyof $FlowFixMe> = Pick<
O,
Exclude<keyof O, K>,
>;
type LooseOmit<
O extends interface {},
K extends string | number | symbol,
> = Pick<O, Exclude<keyof O, K>>;

export type AnimatedProps<Props extends {...}> = LooseOmit<
{
Expand All @@ -94,7 +94,7 @@ export type AnimatedComponentType<
> = component(ref?: React.RefSetter<Instance>, ...AnimatedProps<Props>);

export default function createAnimatedComponent<
TInstance extends React.ComponentType<any>,
TInstance extends React.ComponentType<unknown>,
>(
Component: TInstance,
): AnimatedComponentType<
Expand Down Expand Up @@ -158,6 +158,7 @@ export function unstable_createAnimatedComponentWithAllowlist<
};

AnimatedComponent.displayName = `Animated(${
// $FlowFixMe[sketchy-null-string]
Component.displayName || 'Anonymous'
})`;

Expand Down
Loading
Loading