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
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 @@ -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
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 @@ -61,7 +61,11 @@ export default class AnimatedAddition extends AnimatedWithChildren {
super.__detach();
}

__getNativeConfig(): any {
__getNativeConfig(): {
type: string,
input: [number, number],
debugID: ?string,
} {
return {
type: 'addition',
input: [this._a.__getNativeTag(), this._b.__getNativeTag()],
Expand Down
24 changes: 17 additions & 7 deletions packages/react-native/Libraries/Animated/nodes/AnimatedColor.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 @@ -90,19 +90,21 @@ function processColor(
return null;
}

function isRgbaValue(value: any): boolean {
function isRgbaValue(value: unknown): boolean {
return (
value &&
value != null &&
typeof value === 'object' &&
typeof value.r === 'number' &&
typeof value.g === 'number' &&
typeof value.b === 'number' &&
typeof value.a === 'number'
);
}

function isRgbaAnimatedValue(value: any): boolean {
function isRgbaAnimatedValue(value: unknown): boolean {
return (
value &&
value != null &&
typeof value === 'object' &&
value.r instanceof AnimatedValue &&
value.g instanceof AnimatedValue &&
value.b instanceof AnimatedValue &&
Expand Down Expand Up @@ -166,7 +168,7 @@ export default class AnimatedColor extends AnimatedWithChildren {
this.a = new AnimatedValue(initColor.a);
}

if (config?.useNativeDriver) {
if (config?.useNativeDriver === true) {
this.__makeNative();
}
}
Expand Down Expand Up @@ -325,7 +327,15 @@ export default class AnimatedColor extends AnimatedWithChildren {
super.__makeNative(platformConfig);
}

__getNativeConfig(): {...} {
__getNativeConfig(): {
type: string,
r: number,
g: number,
b: number,
a: number,
nativeColor: ?NativeColorValue,
debugID: ?string,
} {
return {
type: 'color',
r: this.r.__getNativeTag(),
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 @@ -68,7 +68,13 @@ export default class AnimatedDiffClamp extends AnimatedWithChildren {
super.__detach();
}

__getNativeConfig(): any {
__getNativeConfig(): {
type: string,
input: number,
min: number,
max: number,
debugID: ?string,
} {
return {
type: 'diffclamp',
input: this._a.__getNativeTag(),
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 @@ -77,7 +77,11 @@ export default class AnimatedDivision extends AnimatedWithChildren {
super.__detach();
}

__getNativeConfig(): any {
__getNativeConfig(): {
type: string,
input: [number, number],
debugID: ?string,
} {
return {
type: 'division',
input: [this._a.__getNativeTag(), this._b.__getNativeTag()],
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 @@ -55,7 +55,12 @@ export default class AnimatedModulo extends AnimatedWithChildren {
super.__detach();
}

__getNativeConfig(): any {
__getNativeConfig(): {
type: string,
input: number,
modulus: number,
debugID: ?string,
} {
return {
type: 'modulus',
input: this._a.__getNativeTag(),
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 @@ -60,7 +60,11 @@ export default class AnimatedMultiplication extends AnimatedWithChildren {
super.__detach();
}

__getNativeConfig(): any {
__getNativeConfig(): {
type: string,
input: [number, number],
debugID: ?string,
} {
return {
type: 'multiplication',
input: [this._a.__getNativeTag(), this._b.__getNativeTag()],
Expand Down
Loading
Loading