From 62ee5c9b81b38b7968420a09dfb1837723196c9a Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Wed, 4 Sep 2024 18:33:20 -0700 Subject: [PATCH] Replace final $ObjMap in react-native with mapped type (#46335) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46335 Changelog: [Internal] Reviewed By: panagosg7 Differential Revision: D62208265 fbshipit-source-id: f7c72f7239b49fbaee626c3572c116e26b698300 --- .../Animated/components/AnimatedScrollView.js | 1 + .../Animated/createAnimatedComponent.js | 17 +++++++++-------- .../__snapshots__/public-api-test.js.snap | 15 ++++++++------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/packages/react-native/Libraries/Animated/components/AnimatedScrollView.js b/packages/react-native/Libraries/Animated/components/AnimatedScrollView.js index f5375653125367..cd87f75be3854f 100644 --- a/packages/react-native/Libraries/Animated/components/AnimatedScrollView.js +++ b/packages/react-native/Libraries/Animated/components/AnimatedScrollView.js @@ -46,6 +46,7 @@ const AnimatedScrollView: AnimatedComponentType = props.style != null ) { return ( + // $FlowFixMe[prop-missing] = $ObjMap< - Props & - $ReadOnly<{ - passthroughAnimatedPropExplicitValues?: React.ElementConfig, - }>, - () => any, ->; +export type AnimatedProps = { + // eslint-disable-next-line no-unused-vars + +[_K in keyof (Props & + $ReadOnly<{ + passthroughAnimatedPropExplicitValues?: React.ElementConfig< + typeof View, + >, + }>)]: any, +}; export type AnimatedComponentType< Props: {...}, 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 1c51017ab8a4ac..5eb59f565101e2 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 @@ -712,13 +712,14 @@ 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 = $ObjMap< - Props & - $ReadOnly<{ - passthroughAnimatedPropExplicitValues?: React.ElementConfig, - }>, - () => any, ->; +"export type AnimatedProps = { + +[_K in keyof (Props & + $ReadOnly<{ + passthroughAnimatedPropExplicitValues?: React.ElementConfig< + typeof View, + >, + }>)]: any, +}; export type AnimatedComponentType< Props: { ... }, +Instance = mixed,