diff --git a/packages/react-native/Libraries/Animated/createAnimatedComponent.js b/packages/react-native/Libraries/Animated/createAnimatedComponent.js index d922718c672..e7314d925d5 100644 --- a/packages/react-native/Libraries/Animated/createAnimatedComponent.js +++ b/packages/react-native/Libraries/Animated/createAnimatedComponent.js @@ -17,14 +17,17 @@ import useMergeRefs from '../Utilities/useMergeRefs'; import * as React from 'react'; import {useMemo} from 'react'; +type Nullable = void | null; +type Builtin = (...$ReadOnlyArray) => mixed | Date | Error | RegExp; + +export type WithAnimatedValue<+T> = T extends Builtin | Nullable ? T : any; + export type AnimatedProps = { - // eslint-disable-next-line no-unused-vars - +[_K in keyof (Props & - $ReadOnly<{ - passthroughAnimatedPropExplicitValues?: React.ElementConfig< - typeof View, - >, - }>)]: any, + +[K in keyof Props]: WithAnimatedValue, +} & { + passthroughAnimatedPropExplicitValues?: React.ElementConfig< + typeof View, + > | null, }; // We could use a mapped type here to introduce acceptable Animated variants @@ -53,7 +56,10 @@ export default function createAnimatedComponent< $ReadOnly>, React.ElementRef, > { - return unstable_createAnimatedComponentWithAllowlist(Component, null); + return unstable_createAnimatedComponentWithAllowlist( + Component, + null, + ) as $FlowFixMe; } export function unstable_createAnimatedComponentWithAllowlist< diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 2f48c75eb0d..9dcad1f1850 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -644,13 +644,15 @@ exports[`public API should not change unintentionally Libraries/Animated/compone `; exports[`public API should not change unintentionally Libraries/Animated/createAnimatedComponent.js 1`] = ` -"export type AnimatedProps = { - +[_K in keyof (Props & - $ReadOnly<{ - passthroughAnimatedPropExplicitValues?: React.ElementConfig< - typeof View, - >, - }>)]: any, +"type Nullable = void | null; +type Builtin = (...$ReadOnlyArray) => mixed | Date | Error | RegExp; +export type WithAnimatedValue<+T> = T extends Builtin | Nullable ? T : any; +export type AnimatedProps = { + +[K in keyof Props]: WithAnimatedValue, +} & { + passthroughAnimatedPropExplicitValues?: React.ElementConfig< + typeof View, + > | null, }; export type StrictAnimatedProps = $ReadOnly<{ ...$Exact, diff --git a/packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js b/packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js index 87492a5e109..b4cf44c276a 100644 --- a/packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js +++ b/packages/rn-tester/js/examples/SectionList/SectionList-scrollable.js @@ -143,8 +143,9 @@ const renderItemComponent = const onScrollToIndexFailed = (info: { index: number, - c: number, + highestMeasuredFrameIndex: number, averageItemLength: number, + ... }) => { console.warn('onScrollToIndexFailed. See comment in callback', info); /**