From 3dc547cf6566a397db6240772e7e880fc54150f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Wed, 4 Jun 2025 04:04:52 -0700 Subject: [PATCH] Bring back @flow strict to composeStyles and fix Flow errors Summary: The `flow strict` annotation was accidently removed in D74574293. This diff brings it back and fixes flow errors caused by this change. This makes generated TS types for `composeStyles` more relaxed but the main idea of inferring inputs base on output type annotation is preserved. Changelog: [Internal] Reviewed By: huntie Differential Revision: D75945388 --- .../src/private/styles/composeStyles.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/react-native/src/private/styles/composeStyles.js b/packages/react-native/src/private/styles/composeStyles.js index 6ae46a75ce58..a0e90e92a0ac 100644 --- a/packages/react-native/src/private/styles/composeStyles.js +++ b/packages/react-native/src/private/styles/composeStyles.js @@ -4,26 +4,19 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * + * @flow strict * @format */ -import type { - ImageStyle, - TextStyle, - ViewStyle, -} from '../../../Libraries/StyleSheet/StyleSheet'; -import type {StyleProp} from '../../../Libraries/StyleSheet/StyleSheetTypes'; - /** * Combines two styles such that `style2` will override any styles in `style1`. * If either style is null or undefined, the other one is returned without * allocating an array, saving allocations and enabling memoization. */ -export default function composeStyles< - T: ViewStyle | ImageStyle | TextStyle, - U: T, - V: T, ->(style1: ?StyleProp, style2: ?StyleProp): ?StyleProp { +export default function composeStyles( + style1: ?U, + style2: ?V, +): ?(T | $ReadOnlyArray) { if (style1 == null) { return style2; }