From 39ab06742942702a69786dfeaa1ae2d5dac1c56f Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Thu, 27 Aug 2026 16:21:07 +0200 Subject: [PATCH 1/3] Make generated props and style types augmentable --- .../Libraries/StyleSheet/StyleSheet.js | 9 +- .../Libraries/StyleSheet/StyleSheet.js.flow | 9 +- .../Libraries/StyleSheet/StyleSheetTypes.js | 3 + packages/react-native/ReactNativeApi.d.ts | 487 +++++++++--------- .../convertTypeAliasesToInterfaces-test.js | 26 +- .../convertTypeAliasesToInterfaces.js | 79 ++- 6 files changed, 299 insertions(+), 314 deletions(-) diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheet.js b/packages/react-native/Libraries/StyleSheet/StyleSheet.js index 38d33073acf3..244eb9817347 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheet.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheet.js @@ -136,8 +136,7 @@ export type TypeForStyleKey< * object of styles to pass to a View that can't be precomputed with * StyleSheet.create. */ -/** @build-types emit-as-interface react-native-web compatibility */ -export type ViewStyle = ____ViewStyle_Internal; +export type {____ViewStyle_Internal as ViewStyle} from './StyleSheetTypes'; /** * This type is an object of the different possible style @@ -154,8 +153,7 @@ export type ViewStyle = ____ViewStyle_Internal; * object of styles to pass to a Text that can't be precomputed with * StyleSheet.create. */ -/** @build-types emit-as-interface react-native-web compatibility */ -export type TextStyle = ____TextStyle_Internal; +export type {____TextStyle_Internal as TextStyle} from './StyleSheetTypes'; /** * This type is an object of the different possible style @@ -172,8 +170,7 @@ export type TextStyle = ____TextStyle_Internal; * object of styles to pass to an Image that can't be precomputed with * StyleSheet.create. */ -/** @build-types emit-as-interface react-native-web compatibility */ -export type ImageStyle = ____ImageStyle_Internal; +export type {____ImageStyle_Internal as ImageStyle} from './StyleSheetTypes'; /** * WARNING: You probably shouldn't be using this type. This type is an object diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow b/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow index ff4a4e48ec59..b0fb4a59471c 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow +++ b/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow @@ -137,8 +137,7 @@ export type TypeForStyleKey< * object of styles to pass to a View that can't be precomputed with * StyleSheet.create. */ -/** @build-types emit-as-interface react-native-web compatibility */ -export type ViewStyle = ____ViewStyle_Internal; +export type {____ViewStyle_Internal as ViewStyle} from './StyleSheetTypes'; /** * This type is an object of the different possible style @@ -155,8 +154,7 @@ export type ViewStyle = ____ViewStyle_Internal; * object of styles to pass to a Text that can't be precomputed with * StyleSheet.create. */ -/** @build-types emit-as-interface react-native-web compatibility */ -export type TextStyle = ____TextStyle_Internal; +export type {____TextStyle_Internal as TextStyle} from './StyleSheetTypes'; /** * This type is an object of the different possible style @@ -173,8 +171,7 @@ export type TextStyle = ____TextStyle_Internal; * object of styles to pass to an Image that can't be precomputed with * StyleSheet.create. */ -/** @build-types emit-as-interface react-native-web compatibility */ -export type ImageStyle = ____ImageStyle_Internal; +export type {____ImageStyle_Internal as ImageStyle} from './StyleSheetTypes'; /** * WARNING: You probably shouldn't be using this type. This type is an object diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js index 5a1951a1e2c6..5e4289f1b84d 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js @@ -910,6 +910,7 @@ export type ____ViewStyle_InternalCore = Readonly<{ ...____ViewStyle_InternalBase, }>; +/** @build-types emit-as-interface react-native-web compatibility */ export type ____ViewStyle_Internal = Readonly<{ ...____ViewStyle_InternalCore, ...____ViewStyle_InternalOverrides, @@ -1051,6 +1052,7 @@ export type ____TextStyle_InternalCore = Readonly<{ ...____TextStyle_InternalBase, }>; +/** @build-types emit-as-interface react-native-web compatibility */ export type ____TextStyle_Internal = Readonly<{ ...____TextStyle_InternalCore, ...____TextStyle_InternalOverrides, @@ -1065,6 +1067,7 @@ export type ____ImageStyle_InternalCore = Readonly<{ overflow?: 'visible' | 'hidden', }>; +/** @build-types emit-as-interface react-native-web compatibility */ export type ____ImageStyle_Internal = Readonly<{ ...____ImageStyle_InternalCore, ...____ImageStyle_InternalOverrides, diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index 1cda27553fbe..def7005e2fca 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -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. * - * @generated SignedSource<<0cdd169a97730ccd6c6fdb359f0eb30d>> + * @generated SignedSource<> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -517,7 +517,7 @@ declare type ____DangerouslyImpreciseStyle_Internal = Readonly< ____DangerouslyImpreciseStyle_InternalOverrides > declare type ____DangerouslyImpreciseStyle_InternalCore = Readonly< - ____TextStyle_Internal & { + TextStyle & { objectFit?: "contain" | "cover" | "fill" | "none" | "scale-down" overlayColor?: ColorValue resizeMode?: ImageResizeMode @@ -616,11 +616,8 @@ declare type ____FontWeight_Internal = | 700 | 800 | 900 -declare type ____ImageStyle_Internal = Readonly< - ____ImageStyle_InternalCore & ____ImageStyle_InternalOverrides -> declare type ____ImageStyle_InternalCore = Readonly< - Omit<____ViewStyle_Internal, "overflow"> & { + Omit & { objectFit?: "contain" | "cover" | "fill" | "none" | "scale-down" overflow?: "hidden" | "visible" overlayColor?: ColorValue @@ -630,7 +627,7 @@ declare type ____ImageStyle_InternalCore = Readonly< > declare type ____ImageStyle_InternalOverrides = {} declare type ____ImageStyleProp_Internal = StyleProp< - Readonly> + Readonly> > declare type ____LayoutStyle_Internal = { readonly alignContent?: @@ -741,9 +738,6 @@ declare type ____ShadowStyle_InternalOverrides = {} declare type ____Styles_Internal = { readonly [key: string]: Partial<____DangerouslyImpreciseStyle_Internal> } -declare type ____TextStyle_Internal = Readonly< - ____TextStyle_InternalCore & ____TextStyle_InternalOverrides -> declare type ____TextStyle_InternalBase = { readonly color?: ____ColorValue_Internal readonly fontFamily?: string @@ -775,11 +769,11 @@ declare type ____TextStyle_InternalBase = { readonly writingDirection?: "auto" | "ltr" | "rtl" } declare type ____TextStyle_InternalCore = Readonly< - ____ViewStyle_Internal & ____TextStyle_InternalBase + ViewStyle & ____TextStyle_InternalBase > declare type ____TextStyle_InternalOverrides = {} declare type ____TextStyleProp_Internal = StyleProp< - Readonly> + Readonly> > declare type ____TransformStyle_Internal = { readonly transform?: @@ -844,9 +838,6 @@ declare type ____TransformStyle_Internal = { readonly transformOrigin?: [number | string, number | string, number | string] | string } -declare type ____ViewStyle_Internal = Readonly< - ____ViewStyle_InternalCore & ____ViewStyle_InternalOverrides -> declare type ____ViewStyle_InternalBase = { readonly backfaceVisibility?: "hidden" | "visible" readonly backgroundColor?: ____ColorValue_Internal @@ -907,7 +898,7 @@ declare type ____ViewStyle_InternalCore = Readonly< > declare type ____ViewStyle_InternalOverrides = {} declare type ____ViewStyleProp_Internal = StyleProp< - Readonly> + Readonly> > declare class _TextInputInstance extends ReactNativeElement_default { clear(): void @@ -982,28 +973,29 @@ declare type AccessibilityEventTypes = "click" | "focus" | "viewHoverEnter" | "windowStateChange" declare type AccessibilityInfo = typeof AccessibilityInfo declare interface AccessibilityProps extends Readonly< - AccessibilityPropsAndroid & AccessibilityPropsIOS -> { - readonly accessibilityActions?: ReadonlyArray - readonly accessibilityHint?: string - readonly accessibilityLabel?: string - readonly accessibilityRole?: AccessibilityRole - readonly accessibilityState?: AccessibilityState - readonly accessibilityValue?: AccessibilityValue - readonly accessible?: boolean - readonly "aria-busy"?: boolean - readonly "aria-checked"?: "mixed" | (boolean | undefined) - readonly "aria-disabled"?: boolean - readonly "aria-expanded"?: boolean - readonly "aria-hidden"?: boolean - readonly "aria-label"?: string - readonly "aria-selected"?: boolean - readonly "aria-valuemax"?: AccessibilityValue["max"] - readonly "aria-valuemin"?: AccessibilityValue["min"] - readonly "aria-valuenow"?: AccessibilityValue["now"] - readonly "aria-valuetext"?: AccessibilityValue["text"] - readonly role?: Role -} + AccessibilityPropsAndroid & + AccessibilityPropsIOS & { + accessibilityActions?: ReadonlyArray + accessibilityHint?: string + accessibilityLabel?: string + accessibilityRole?: AccessibilityRole + accessibilityState?: AccessibilityState + accessibilityValue?: AccessibilityValue + accessible?: boolean + "aria-busy"?: boolean + "aria-checked"?: "mixed" | (boolean | undefined) + "aria-disabled"?: boolean + "aria-expanded"?: boolean + "aria-hidden"?: boolean + "aria-label"?: string + "aria-selected"?: boolean + "aria-valuemax"?: AccessibilityValue["max"] + "aria-valuemin"?: AccessibilityValue["min"] + "aria-valuenow"?: AccessibilityValue["now"] + "aria-valuetext"?: AccessibilityValue["text"] + role?: Role + } +> {} declare type AccessibilityPropsAndroid = { readonly accessibilityLabelledBy?: (Array | undefined) | (string | undefined) @@ -1104,12 +1096,13 @@ declare type ActivityIndicatorIOSProps = { readonly hidesWhenStopped?: boolean } declare interface ActivityIndicatorProps extends Readonly< - ViewProps & ActivityIndicatorIOSProps -> { - readonly animating?: boolean - readonly color?: ColorValue - readonly size?: IndicatorSize -} + ViewProps & + ActivityIndicatorIOSProps & { + animating?: boolean + color?: ColorValue + size?: IndicatorSize + } +> {} declare type add = typeof add declare function addChangeListener( listener: (preferences: AppearancePreferences) => void, @@ -1662,35 +1655,34 @@ declare type Builtin = ( ) => Date | Error | RegExp | unknown declare type Button = typeof Button declare type ButtonInstance = React.ComponentRef -declare interface ButtonProps { - readonly accessibilityActions?: ReadonlyArray - readonly accessibilityHint?: string - readonly accessibilityLabel?: string - readonly accessibilityLanguage?: string - readonly accessibilityState?: AccessibilityState - readonly accessible?: boolean - readonly "aria-busy"?: boolean - readonly "aria-checked"?: "mixed" | (boolean | undefined) - readonly "aria-disabled"?: boolean - readonly "aria-expanded"?: boolean - readonly "aria-label"?: string - readonly "aria-selected"?: boolean - readonly color?: ColorValue - readonly disabled?: boolean - readonly hasTVPreferredFocus?: boolean - readonly importantForAccessibility?: - "auto" | "no-hide-descendants" | "no" | "yes" - readonly nextFocusDown?: number - readonly nextFocusForward?: number - readonly nextFocusLeft?: number - readonly nextFocusRight?: number - readonly nextFocusUp?: number - readonly onAccessibilityAction?: (event: AccessibilityActionEvent) => unknown - readonly onPress?: (event?: GestureResponderEvent) => unknown - readonly testID?: string - readonly title: string - readonly touchSoundDisabled?: boolean -} +declare interface ButtonProps extends Readonly<{ + accessibilityActions?: ReadonlyArray + accessibilityHint?: string + accessibilityLabel?: string + accessibilityLanguage?: string + accessibilityState?: AccessibilityState + accessible?: boolean + "aria-busy"?: boolean + "aria-checked"?: "mixed" | (boolean | undefined) + "aria-disabled"?: boolean + "aria-expanded"?: boolean + "aria-label"?: string + "aria-selected"?: boolean + color?: ColorValue + disabled?: boolean + hasTVPreferredFocus?: boolean + importantForAccessibility?: "auto" | "no-hide-descendants" | "no" | "yes" + nextFocusDown?: number + nextFocusForward?: number + nextFocusLeft?: number + nextFocusRight?: number + nextFocusUp?: number + onAccessibilityAction?: (event: AccessibilityActionEvent) => unknown + onPress?: (event?: GestureResponderEvent) => unknown + testID?: string + title: string + touchSoundDisabled?: boolean +}> {} declare function cancelHeadlessTask(taskId: number, taskKey: string): void declare type Category = string declare type CellMetricProps = { @@ -2426,13 +2418,13 @@ declare class ImageBackground extends React.Component { } declare type ImageBackgroundInstance = ImageBackground declare interface ImageBackgroundProps extends Readonly< - Omit -> { - readonly children?: React.ReactNode - readonly imageRef?: React.Ref> - readonly imageStyle?: ImageStyleProp - readonly style?: ViewStyleProp -} + Omit & { + children?: React.ReactNode + imageRef?: React.Ref> + imageStyle?: ImageStyleProp + style?: ViewStyleProp + } +> {} declare type ImageComponentStaticsAndroid = Readonly< ImageComponentStaticsIOS & { abortPrefetch(requestId: number): void @@ -2494,10 +2486,12 @@ declare type ImageProgressEventIOS = NativeSyntheticEvent< Readonly > declare interface ImageProps extends Readonly< - ImagePropsIOS & ImagePropsAndroid & Omit -> { - readonly style?: ImageStyleProp -} + ImagePropsIOS & + ImagePropsAndroid & + Omit & { + style?: ImageStyleProp + } +> {} declare type ImagePropsAndroid = { readonly fadeDuration?: number readonly loadingIndicatorSource?: number | Readonly @@ -2515,41 +2509,41 @@ declare interface ImagePropsBase extends Readonly< | "children" | "onLayout" | "testID" - > -> { - readonly accessibilityLabel?: string - readonly accessible?: boolean - readonly alt?: string - readonly "aria-label"?: string - readonly "aria-labelledby"?: string - readonly blurRadius?: number - readonly capInsets?: EdgeInsetsProp - readonly children?: never - readonly crossOrigin?: "anonymous" | "use-credentials" - readonly height?: number - readonly internal_analyticTag?: string - readonly onError?: (event: ImageErrorEvent) => void - readonly onLayout?: (event: LayoutChangeEvent) => unknown - readonly onLoad?: (event: ImageLoadEvent) => void - readonly onLoadEnd?: () => void - readonly onLoadStart?: () => void - readonly referrerPolicy?: - | "no-referrer-when-downgrade" - | "no-referrer" - | "origin-when-cross-origin" - | "origin" - | "same-origin" - | "strict-origin-when-cross-origin" - | "strict-origin" - | "unsafe-url" - readonly resizeMode?: ImageResizeMode - readonly source?: ImageSource - readonly src?: string - readonly srcSet?: string - readonly testID?: string - readonly tintColor?: ColorValue - readonly width?: number -} + > & { + accessibilityLabel?: string + accessible?: boolean + alt?: string + "aria-label"?: string + "aria-labelledby"?: string + blurRadius?: number + capInsets?: EdgeInsetsProp + children?: never + crossOrigin?: "anonymous" | "use-credentials" + height?: number + internal_analyticTag?: string + onError?: (event: ImageErrorEvent) => void + onLayout?: (event: LayoutChangeEvent) => unknown + onLoad?: (event: ImageLoadEvent) => void + onLoadEnd?: () => void + onLoadStart?: () => void + referrerPolicy?: + | "no-referrer-when-downgrade" + | "no-referrer" + | "origin-when-cross-origin" + | "origin" + | "same-origin" + | "strict-origin-when-cross-origin" + | "strict-origin" + | "unsafe-url" + resizeMode?: ImageResizeMode + source?: ImageSource + src?: string + srcSet?: string + testID?: string + tintColor?: ColorValue + width?: number + } +> {} declare type ImagePropsIOS = { readonly defaultSource?: ImageSource readonly onPartialLoad?: () => void @@ -2566,7 +2560,9 @@ declare type ImageSize = { declare type ImageSource = ImageRequireSource | ImageURISource | ReadonlyArray declare type ImageSourcePropType = ImageSource -declare interface ImageStyle extends ____ImageStyle_Internal {} +declare interface ImageStyle extends Readonly< + ____ImageStyle_InternalCore & ____ImageStyle_InternalOverrides +> {} declare type ImageStyleProp = ____ImageStyleProp_Internal declare type ImageType = ImageAndroid | ImageIOS declare interface ImageURISource { @@ -2608,12 +2604,12 @@ declare class Info { } declare type InnerViewInstance = React.ComponentRef declare type InputAccessoryView = typeof InputAccessoryView -declare interface InputAccessoryViewProps { - readonly backgroundColor?: ColorValue +declare interface InputAccessoryViewProps extends Readonly<{ + backgroundColor?: ColorValue readonly children: React.ReactNode - readonly nativeID?: string - readonly style?: ViewStyleProp -} + nativeID?: string + style?: ViewStyleProp +}> {} declare type InputModeOptions = "decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url" declare type InputValue = @@ -2731,12 +2727,14 @@ declare class KeyboardAvoidingView extends React.Component< render(): React.ReactNode } declare type KeyboardAvoidingViewInstance = KeyboardAvoidingView -declare interface KeyboardAvoidingViewProps extends Readonly { - readonly behavior?: "height" | "padding" | "position" - readonly contentContainerStyle?: ViewStyleProp - readonly enabled?: boolean - readonly keyboardVerticalOffset?: number -} +declare interface KeyboardAvoidingViewProps extends Readonly< + ViewProps & { + behavior?: "height" | "padding" | "position" + contentContainerStyle?: ViewStyleProp + enabled?: boolean + keyboardVerticalOffset?: number + } +> {} declare type KeyboardAvoidingViewState = { bottom: number } @@ -3009,15 +3007,18 @@ declare type Message = { }> } declare type Modal = typeof Modal -declare interface ModalBaseProps { - animationType?: "fade" | "none" | "slide" - backdropColor?: ColorValue - modalRef?: React.Ref - onRequestClose?: DirectEventHandler - onShow?: DirectEventHandler - transparent?: boolean - visible?: boolean -} +declare interface ModalBaseProps extends Omit< + { + animationType?: "fade" | "none" | "slide" + backdropColor?: ColorValue + modalRef?: React.Ref + onRequestClose?: DirectEventHandler + onShow?: DirectEventHandler + transparent?: boolean + visible?: boolean + }, + never +> {} declare type ModalInstance = HostInstance declare type ModalProps = ModalBaseProps & ModalPropsIOS & @@ -3669,9 +3670,9 @@ declare type PressableInstance = HostInstance declare interface PressableProps extends Readonly< Omit & PressableBaseProps > {} -declare interface PressableStateCallbackType { - readonly pressed: boolean -} +declare interface PressableStateCallbackType extends Readonly<{ + pressed: boolean +}> {} declare type PressRetentionOffset = { readonly bottom: number readonly left: number @@ -4438,13 +4439,14 @@ declare type SectionListInstance = SectionList declare interface SectionListProps< ItemT, SectionT = DefaultSectionT, -> extends Readonly< +> extends Omit< Omit< VirtualizedSectionListProps, "getItem" | "getItemCount" | "keyExtractor" | "renderItem" > & RequiredSectionListProps & - OptionalSectionListProps + OptionalSectionListProps, + never > {} declare type SectionListRenderItem = ( info: SectionListRenderItemInfo, @@ -5195,7 +5197,9 @@ declare type TextPropsIOS = { lineBreakStrategyIOS?: "hangul-word" | "none" | "push-out" | "standard" suppressHighlighting?: boolean } -declare interface TextStyle extends ____TextStyle_Internal {} +declare interface TextStyle extends Readonly< + ____TextStyle_InternalCore & ____TextStyle_InternalOverrides +> {} declare type TextStyleProp = ____TextStyleProp_Internal declare type Timespan = { endExtras?: Extras @@ -5334,32 +5338,31 @@ declare function TouchableWithoutFeedback( declare interface TouchableWithoutFeedbackProps extends Readonly< TouchableWithoutFeedbackPropsAndroid & TouchableWithoutFeedbackPropsIOS & - AccessibilityProps -> { - readonly children?: React.ReactNode - readonly delayLongPress?: number - readonly delayPressIn?: number - readonly delayPressOut?: number - readonly disabled?: boolean - readonly focusable?: boolean - readonly hitSlop?: EdgeInsetsOrSizeProp - readonly id?: string - readonly importantForAccessibility?: - "auto" | "no-hide-descendants" | "no" | "yes" - readonly nativeID?: string - readonly onAccessibilityAction?: (event: AccessibilityActionEvent) => unknown - readonly onBlur?: (event: BlurEvent) => unknown - readonly onFocus?: (event: FocusEvent) => unknown - readonly onLayout?: (event: LayoutChangeEvent) => unknown - readonly onLongPress?: (event: GestureResponderEvent) => unknown - readonly onPress?: (event: GestureResponderEvent) => unknown - readonly onPressIn?: (event: GestureResponderEvent) => unknown - readonly onPressOut?: (event: GestureResponderEvent) => unknown - readonly pressRetentionOffset?: EdgeInsetsOrSizeProp - readonly rejectResponderTermination?: boolean - readonly style?: ViewStyleProp - readonly testID?: string -} + AccessibilityProps & { + children?: React.ReactNode + delayLongPress?: number + delayPressIn?: number + delayPressOut?: number + disabled?: boolean + focusable?: boolean + hitSlop?: EdgeInsetsOrSizeProp + id?: string + importantForAccessibility?: "auto" | "no-hide-descendants" | "no" | "yes" + nativeID?: string + onAccessibilityAction?: (event: AccessibilityActionEvent) => unknown + onBlur?: (event: BlurEvent) => unknown + onFocus?: (event: FocusEvent) => unknown + onLayout?: (event: LayoutChangeEvent) => unknown + onLongPress?: (event: GestureResponderEvent) => unknown + onPress?: (event: GestureResponderEvent) => unknown + onPressIn?: (event: GestureResponderEvent) => unknown + onPressOut?: (event: GestureResponderEvent) => unknown + pressRetentionOffset?: EdgeInsetsOrSizeProp + rejectResponderTermination?: boolean + style?: ViewStyleProp + testID?: string + } +> {} declare type TouchableWithoutFeedbackPropsAndroid = { touchSoundDisabled?: boolean } @@ -5571,7 +5574,9 @@ declare type ViewPropsAndroid = { declare type ViewPropsIOS = { readonly shouldRasterizeIOS?: boolean } -declare interface ViewStyle extends ____ViewStyle_Internal {} +declare interface ViewStyle extends Readonly< + ____ViewStyle_InternalCore & ____ViewStyle_InternalOverrides +> {} declare type ViewStyleProp = ____ViewStyleProp_Internal declare type VirtualizedList = typeof VirtualizedList declare class VirtualizedList_default extends StateSafePureComponent_default< @@ -5743,24 +5748,24 @@ export { AccessibilityActionEvent, // a0d4daa0 AccessibilityActionInfo, // db47a917 AccessibilityInfo, // 23a3aa9b - AccessibilityProps, // b703f8d9 + AccessibilityProps, // 38fadc29 AccessibilityRole, // f2f2e066 AccessibilityState, // b0c2b3f7 AccessibilityValue, // cf8bcb74 ActionSheetIOS, // b558559e ActionSheetIOSOptions, // 1756eb5a - ActivityIndicator, // 7bb76795 + ActivityIndicator, // 262ca482 ActivityIndicatorInstance, // a82dd4e7 - ActivityIndicatorProps, // e3c81e37 + ActivityIndicatorProps, // 35ad74c3 Alert, // a398a509 AlertButton, // bf1a3b60 AlertButtonStyle, // ec9fb242 AlertOptions, // 8a116d2a AlertType, // 5ab91217 AndroidKeyboardEvent, // e03becc8 - Animated, // e99db73c + Animated, // f8125d9a AppConfig, // 35c0ca70 - AppRegistry, // 5bc2bced + AppRegistry, // 831f9c19 AppState, // 12012be5 AppStateEvent, // 80f034c3 AppStateStatus, // 447e5ef2 @@ -5772,9 +5777,9 @@ export { BackPressEventName, // 4620fb76 BlurEvent, // 4ba4f941 BoxShadowValue, // b679703f - Button, // 78a75446 - ButtonInstance, // aecdca9d - ButtonProps, // 21c5780c + Button, // 9a214973 + ButtonInstance, // 548918b2 + ButtonProps, // e48830f2 Clipboard, // 41addb89 CodegenTypes, // ab4986cc ColorSchemeName, // 6615edd6 @@ -5792,9 +5797,9 @@ export { DimensionsPayload, // 653bc26c DisplayMetrics, // 1dc35cef DisplayMetricsAndroid, // 872e62eb - DrawerLayoutAndroid, // a1445452 + DrawerLayoutAndroid, // 2d6a492a DrawerLayoutAndroidInstance, // c0694352 - DrawerLayoutAndroidProps, // 8144971b + DrawerLayoutAndroidProps, // 24b20710 DrawerSlideEvent, // c4ab8fba DropShadowValue, // e9df2606 DynamicColorIOS, // d96c228c @@ -5810,9 +5815,9 @@ export { EventSubscription, // b8d084aa ExtendedExceptionData, // 5a6ccf5a FilterFunction, // bf24c0e3 - FlatList, // ff6fd4b9 - FlatListInstance, // 930e6e0d - FlatListProps, // b77a3695 + FlatList, // 36f5a90b + FlatListInstance, // 40594c62 + FlatListProps, // 065a6050 FocusEvent, // 850f1517 FontVariant, // 7c7558bb GestureResponderEvent, // 14d3e77a @@ -5823,17 +5828,17 @@ export { IEventEmitter, // fbef6131 IOSKeyboardEvent, // e67bfe3a IgnorePattern, // ec6f6ece - Image, // 70beaf51 - ImageBackground, // 125f114f - ImageBackgroundInstance, // b32a44b1 - ImageBackgroundProps, // 58c484ed + Image, // 305c77ac + ImageBackground, // 0b0db336 + ImageBackgroundInstance, // 9299c8f6 + ImageBackgroundProps, // 26ac5fb5 ImageErrorEvent, // 978933f4 ImageInstance, // 9a100753 ImageLoadEvent, // 77f0b718 ImageProgressEventIOS, // 445331a4 - ImageProps, // 0b057370 + ImageProps, // 7ba1bee7 ImagePropsAndroid, // ee00e1d5 - ImagePropsBase, // 360c2972 + ImagePropsBase, // 17d8c928 ImagePropsIOS, // 9e19c85d ImageRequireSource, // 681d683b ImageResizeMode, // d51106e2 @@ -5841,19 +5846,19 @@ export { ImageSize, // 1c47cf88 ImageSource, // ea31cf4a ImageSourcePropType, // f522e093 - ImageStyle, // 23278d38 + ImageStyle, // 85dc694a ImageURISource, // 443d047c - InputAccessoryView, // 69da97d8 - InputAccessoryViewProps, // 6c4ba417 + InputAccessoryView, // f4ef0505 + InputAccessoryViewProps, // 30a87786 InputModeOptions, // 4e8581b9 Insets, // e7fe432a KeyDownEvent, // 5b147614 KeyEvent, // 20fa4267 KeyUpEvent, // 57f832c5 Keyboard, // 49414c97 - KeyboardAvoidingView, // 86ce3237 - KeyboardAvoidingViewInstance, // 39e5e0cb - KeyboardAvoidingViewProps, // 5ea2df10 + KeyboardAvoidingView, // 9f1248af + KeyboardAvoidingViewInstance, // 72381ee5 + KeyboardAvoidingViewProps, // 59b3d65a KeyboardEvent, // c3f895d4 KeyboardEventEasing, // af4091c8 KeyboardEventName, // 59299ad6 @@ -5878,10 +5883,10 @@ export { MeasureInWindowOnSuccessCallback, // a285f598 MeasureLayoutOnSuccessCallback, // 3592502a MeasureOnSuccessCallback, // 82824e59 - Modal, // ddb43746 - ModalBaseProps, // c294cc46 + Modal, // 85dfed67 + ModalBaseProps, // 050be772 ModalInstance, // d466ce77 - ModalProps, // a073d560 + ModalProps, // 8e98212a ModalPropsAndroid, // 515fb173 ModalPropsIOS, // 664ecb7e ModeChangeEvent, // f64bf69d @@ -5917,15 +5922,15 @@ export { PointerEvent, // ff599afe PressabilityConfig, // fea539a5 PressabilityEventHandlers, // c222648b - Pressable, // 73cbe498 + Pressable, // 7b7692a2 PressableAndroidRippleConfig, // ee32eaca PressableInstance, // eebfe911 - PressableProps, // 573ac60a - PressableStateCallbackType, // 5e0cfa78 + PressableProps, // a7055901 + PressableStateCallbackType, // 2a3a68be ProcessedColorValue, // 33f74304 - ProgressBarAndroid, // db8f6a6b + ProgressBarAndroid, // c91ddd55 ProgressBarAndroidInstance, // ab545ef1 - ProgressBarAndroidProps, // 6484d368 + ProgressBarAndroidProps, // 5df4b67c PublicRootInstance, // 8040afd7 PublicTextInstance, // 6937c7bf PushNotificationEventName, // 84e7e150 @@ -5933,9 +5938,9 @@ export { PushNotificationPermissions, // c2e7ae4f Rationale, // 5df1b1c1 ReactNativeVersion, // abd76827 - RefreshControl, // 1fc5c032 - RefreshControlInstance, // 7cef228c - RefreshControlProps, // c03c6dd3 + RefreshControl, // c98bcc4d + RefreshControlInstance, // cc20e6bc + RefreshControlProps, // e4998b72 RefreshControlPropsAndroid, // 8ac931ca RefreshControlPropsIOS, // 72a36381 Registry, // 6c39216d @@ -5944,27 +5949,27 @@ export { Role, // af7b889d RootTag, // 3cd10504 RootTagContext, // 38bfc8f6 - RootViewStyleProvider, // a4547094 + RootViewStyleProvider, // eaff83cc Runnable, // 594dd93a Runnables, // 4367c557 - SafeAreaView, // 2a5620cd + SafeAreaView, // f54b63d3 SafeAreaViewInstance, // 21dba39c ScaledSize, // 07e417c7 ScrollEvent, // d7abdd0a - ScrollResponderType, // 4fb54e25 + ScrollResponderType, // fdbfa43c ScrollToLocationParamsType, // d7ecdad1 - ScrollView, // 5b9149bf - ScrollViewImperativeMethods, // 308dd401 - ScrollViewInstance, // b86e49e8 - ScrollViewProps, // 40e3563d + ScrollView, // 8a8c17b6 + ScrollViewImperativeMethods, // ef0ef67e + ScrollViewInstance, // d576e5d5 + ScrollViewProps, // 0a695363 ScrollViewPropsAndroid, // 02f3df2e ScrollViewPropsIOS, // 807cb4f6 ScrollViewScrollToOptions, // 3313411e SectionBase, // 9f13db00 - SectionList, // 5ad78704 + SectionList, // d4eb0477 SectionListData, // 1a4de01a - SectionListInstance, // ce15f61c - SectionListProps, // 3b9f4d91 + SectionListInstance, // 2679fa93 + SectionListProps, // 9fbd4914 SectionListRenderItem, // 715b2086 SectionListRenderItemInfo, // 4a48a922 Separators, // 6a45f7e3 @@ -5981,19 +5986,19 @@ export { StatusBarProps, // c2a44d88 StatusBarStyle, // 78f53eea StyleProp, // fa0e9b4a - StyleSheet, // f7fe407a + StyleSheet, // 9ed7a5d4 SubmitBehavior, // c4ddf490 - Switch, // cf0d6ce5 + Switch, // a3f62002 SwitchChangeEvent, // 899635b1 SwitchInstance, // 3c50eec5 - SwitchProps, // 9efb522c + SwitchProps, // b7ba0235 Systrace, // 626d178c TVViewPropsIOS, // 330ce7b5 TargetedEvent, // 16e98910 TaskProvider, // 266dedf2 - Text, // 3ccd8020 + Text, // 603f50be TextContentType, // 239b3ecc - TextInput, // 89af456b + TextInput, // 0783b85a TextInputAndroidProps, // 9ebbc103 TextInputBlurEvent, // b77af40e TextInputChangeEvent, // f55eef98 @@ -6003,44 +6008,44 @@ export { TextInputIOSProps, // fb3c9327 TextInputInstance, // 5a0c0e0d TextInputKeyPressEvent, // 546c5d07 - TextInputProps, // a93c2e69 + TextInputProps, // 073d3a32 TextInputSelectionChangeEvent, // e58f2abc TextInputSubmitEditingEvent, // 6bcb2aa5 TextInstance, // 05463a96 TextLayoutEvent, // 3f54186f - TextProps, // 2e3336ca - TextStyle, // d7678842 + TextProps, // 96b843ff + TextStyle, // 898adfd1 ToastAndroid, // 88a8969a - TouchableHighlight, // edab1b07 + TouchableHighlight, // 46b69b76 TouchableHighlightInstance, // b510c0eb - TouchableHighlightProps, // 08cd59e1 - TouchableNativeFeedback, // e2791ad5 - TouchableNativeFeedbackInstance, // ce1ad7e9 - TouchableNativeFeedbackProps, // ffc9c1d4 - TouchableOpacity, // fac1cc91 + TouchableHighlightProps, // f0306678 + TouchableNativeFeedback, // 4fac050d + TouchableNativeFeedbackInstance, // a5a97aba + TouchableNativeFeedbackProps, // e68e0720 + TouchableOpacity, // 488a7c7f TouchableOpacityInstance, // b186055b - TouchableOpacityProps, // 9e3eeec9 - TouchableWithoutFeedback, // da544b16 - TouchableWithoutFeedbackProps, // a14626e7 + TouchableOpacityProps, // f0e05d03 + TouchableWithoutFeedback, // 657d20f4 + TouchableWithoutFeedbackProps, // 4ac02994 TransformsStyle, // 65e70f18 TurboModule, // dfe29706 TurboModuleRegistry, // 4ace6db2 UIManager, // afbcdf05 UTFSequence, // ad625158 Vibration, // 31e4bbf8 - View, // 14779d0c + View, // 6a318aac ViewInstance, // ffde5573 - ViewProps, // 46cb2061 + ViewProps, // 855ca063 ViewPropsAndroid, // 55e81851 ViewPropsIOS, // 58ee19bf - ViewStyle, // e75eec1e + ViewStyle, // 4e2746d6 VirtualViewMode, // 6be59722 VirtualizedList, // 68c7345e VirtualizedListInstance, // 423ee7c0 - VirtualizedListProps, // 5dded4a1 + VirtualizedListProps, // 60ce2b77 VirtualizedSectionList, // 9fd9cd61 VirtualizedSectionListInstance, // 12b706d5 - VirtualizedSectionListProps, // ef311473 + VirtualizedSectionListProps, // bbbf2933 WrapperComponentProvider, // 9ef54e61 codegenNativeCommands, // 628a7c0a codegenNativeComponent, // 520daa94 diff --git a/scripts/js-api/build-types/transforms/typescript/__tests__/convertTypeAliasesToInterfaces-test.js b/scripts/js-api/build-types/transforms/typescript/__tests__/convertTypeAliasesToInterfaces-test.js index fe63bb35aa10..a15111440a1c 100644 --- a/scripts/js-api/build-types/transforms/typescript/__tests__/convertTypeAliasesToInterfaces-test.js +++ b/scripts/js-api/build-types/transforms/typescript/__tests__/convertTypeAliasesToInterfaces-test.js @@ -46,10 +46,10 @@ declare type ViewProps = Readonly`, declare type Props = Readonly`, ); expect(result).toMatchInlineSnapshot(` -"declare interface Props extends Readonly { - readonly x?: string; - readonly y: number; -}" +"declare interface Props extends Readonly {}" `); }); @@ -59,10 +59,10 @@ declare type Props = Readonly`, declare type Props = Readonly<{ a: string; b?: number }>`, ); expect(result).toMatchInlineSnapshot(` -"declare interface Props { - readonly a: string; - readonly b?: number; -}" +"declare interface Props extends Readonly<{ + a: string; + b?: number; +}> {}" `); }); @@ -72,10 +72,10 @@ declare type Props = Readonly<{ a: string; b?: number }>`, declare type Props = { readonly a: string; readonly b?: number }`, ); expect(result).toMatchInlineSnapshot(` -"declare interface Props { +"declare interface Props extends Omit<{ readonly a: string; readonly b?: number; -}" +}, never> {}" `); }); @@ -105,9 +105,9 @@ declare type FlatListProps = Omit & BaseProps`, declare type Props = Readonly & { alt?: string }>`, ); expect(result).toMatchInlineSnapshot(` -"declare interface Props extends Readonly> { - readonly alt?: string; -}" +"declare interface Props extends Readonly & { + alt?: string; +}> {}" `); }); diff --git a/scripts/js-api/build-types/transforms/typescript/convertTypeAliasesToInterfaces.js b/scripts/js-api/build-types/transforms/typescript/convertTypeAliasesToInterfaces.js index c33238180983..59d5c4cbe3ab 100644 --- a/scripts/js-api/build-types/transforms/typescript/convertTypeAliasesToInterfaces.js +++ b/scripts/js-api/build-types/transforms/typescript/convertTypeAliasesToInterfaces.js @@ -44,59 +44,50 @@ function convertToInterface(path: $FlowFixMe): void { innerType = typeAnnotation.typeParameters.params[0]; } - const extendsClauses: Array = []; - const bodyMembers: Array = []; + let members: Array; if (t.isTSIntersectionType(innerType)) { - const refMembers: Array = []; - for (const member of innerType.types) { - if (t.isTSTypeLiteral(member)) { - const clonedMembers = t.cloneDeep(member).members; - if (isReadonly) { - makePropertiesReadonly(clonedMembers); - } - bodyMembers.push(...clonedMembers); - } else { - refMembers.push(t.cloneDeep(member)); - } - } - if (refMembers.length > 0) { - const refsType = - refMembers.length === 1 - ? refMembers[0] - : t.tsIntersectionType(refMembers); - if (isReadonly) { - extendsClauses.push( - t.tsExpressionWithTypeArguments( - t.identifier('Readonly'), - t.tsTypeParameterInstantiation([refsType]), - ), - ); - } else { - extendsClauses.push(typeToExtendsClause(refsType, false)); - } - } - } else if (t.isTSTypeLiteral(innerType)) { - const clonedMembers = t.cloneDeep(innerType).members; - if (isReadonly) { - makePropertiesReadonly(clonedMembers); - } - bodyMembers.push(...clonedMembers); - } else if (t.isTSTypeReference(innerType)) { - extendsClauses.push(typeToExtendsClause(innerType, isReadonly)); + members = innerType.types.map(member => t.cloneDeep(member)); + } else if (t.isTSTypeLiteral(innerType) || t.isTSTypeReference(innerType)) { + members = [t.cloneDeep(innerType)]; } else { throw new Error( `Unsupported type structure for @build-types emit-as-interface on '${path.node.id.name}'. Only object literals, type references, and intersections of these are supported.`, ); } + const combined = + members.length === 1 ? members[0] : t.tsIntersectionType(members); + const hasObjectLiteral = members.some(member => t.isTSTypeLiteral(member)); + + // Members declared in the body of an interface cannot be overridden by a + // module augmentation: a second declaration is a merge conflict, and the + // original wins. Keeping every member in the extends clause makes them all + // inherited, and so all overridable. + const extendsClauses = [ + isReadonly + ? t.tsExpressionWithTypeArguments( + t.identifier('Readonly'), + t.tsTypeParameterInstantiation([combined]), + ) + : hasObjectLiteral + ? // An object literal cannot appear in an extends clause on its own, + // and wrapping it in Readonly would add modifiers the source does + // not have. Omit<_, never> preserves them. + t.tsExpressionWithTypeArguments( + t.identifier('Omit'), + t.tsTypeParameterInstantiation([combined, t.tsNeverKeyword()]), + ) + : typeToExtendsClause(combined, false), + ]; + const interfaceNode = t.tsInterfaceDeclaration( t.cloneDeep(path.node.id), path.node.typeParameters ? t.cloneDeep(path.node.typeParameters) : undefined, - extendsClauses.length > 0 ? extendsClauses : undefined, - t.tsInterfaceBody(bodyMembers), + extendsClauses, + t.tsInterfaceBody([]), ); interfaceNode.declare = path.node.declare ?? false; @@ -127,14 +118,6 @@ function typeToExtendsClause( ); } -function makePropertiesReadonly(members: Array): void { - for (const member of members) { - if (t.isTSPropertySignature(member)) { - member.readonly = true; - } - } -} - const visitor: PluginObj = { visitor: { TSTypeAliasDeclaration(path) { From e35a309ae72fc5d07ba3dcaf8cb4a9766893c6d9 Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Thu, 27 Aug 2026 17:02:51 +0200 Subject: [PATCH 2/3] Remove unused imports --- packages/react-native/Libraries/StyleSheet/StyleSheet.js | 3 --- packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow | 3 --- 2 files changed, 6 deletions(-) diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheet.js b/packages/react-native/Libraries/StyleSheet/StyleSheet.js index 244eb9817347..097a6e500e85 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheet.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheet.js @@ -16,12 +16,9 @@ import type { ____DangerouslyImpreciseStyle_Internal, ____DangerouslyImpreciseStyleProp_Internal, ____FontVariant_Internal, - ____ImageStyle_Internal, ____ImageStyleProp_Internal, - ____TextStyle_Internal, ____TextStyleProp_Internal, ____TransformStyle_Internal, - ____ViewStyle_Internal, ____ViewStyleProp_Internal, NativeColorValue, } from './StyleSheetTypes'; diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow b/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow index b0fb4a59471c..0a25841a93a7 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow +++ b/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow @@ -15,12 +15,9 @@ import type { ____DangerouslyImpreciseStyle_Internal, ____DangerouslyImpreciseStyleProp_Internal, ____FontVariant_Internal, - ____ImageStyle_Internal, ____ImageStyleProp_Internal, - ____TextStyle_Internal, ____TextStyleProp_Internal, ____TransformStyle_Internal, - ____ViewStyle_Internal, ____ViewStyleProp_Internal, NativeColorValue, } from './StyleSheetTypes'; From 25739b40231fc555c29a8e456c97a0506f2e9ae1 Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Thu, 27 Aug 2026 18:09:54 +0200 Subject: [PATCH 3/3] Make types augmentable from the sources, not the build-types transform Revert convertTypeAliasesToInterfaces to its original form. Get the same emitted types from the Flow sources instead. Styles: rename ____ViewStyle_Internal, ____TextStyle_Internal and ____ImageStyle_Internal to ViewStyle, TextStyle and ImageStyle. StyleSheet now re-exports each name unchanged, with no alias. Props: 11 annotated types still emitted members in the interface body. Each one now moves its inline members into a private Core alias. All members are inherited through the extends clause, so a module augmentation can refine them. ImagePropsBase and ImageBackgroundProps declare members that shadow keys of the type they spread. An explicit Omit removes those keys, because a Flow spread of an optional property unions the two types instead of replacing the member. Co-Authored-By: Claude Opus 5 (1M context) --- .../Animated/components/AnimatedScrollView.js | 4 +- .../ActivityIndicator/ActivityIndicator.js | 13 +- .../Libraries/Components/Button.js | 6 +- .../Keyboard/KeyboardAvoidingView.js | 11 +- .../Components/Pressable/Pressable.js | 6 +- .../TextInput/InputAccessoryView.js | 14 +- .../Components/TextInput/TextInput.js | 10 +- .../Touchable/TouchableWithoutFeedback.js | 169 +++---- .../Components/View/ViewAccessibility.js | 12 +- .../Libraries/Image/ImageProps.js | 56 ++- .../react-native/Libraries/Modal/Modal.js | 6 +- .../Libraries/StyleSheet/StyleSheet.js | 6 +- .../Libraries/StyleSheet/StyleSheet.js.flow | 6 +- .../Libraries/StyleSheet/StyleSheetTypes.js | 18 +- .../Libraries/StyleSheet/splitLayoutProps.js | 12 +- packages/react-native/Libraries/Text/Text.js | 12 +- packages/react-native/ReactNativeApi.d.ts | 445 +++++++++--------- .../convertTypeAliasesToInterfaces-test.js | 26 +- .../convertTypeAliasesToInterfaces.js | 79 ++-- 19 files changed, 487 insertions(+), 424 deletions(-) diff --git a/packages/react-native/Libraries/Animated/components/AnimatedScrollView.js b/packages/react-native/Libraries/Animated/components/AnimatedScrollView.js index 7a1a1d7b32ec..8d65e4c3fd24 100644 --- a/packages/react-native/Libraries/Animated/components/AnimatedScrollView.js +++ b/packages/react-native/Libraries/Animated/components/AnimatedScrollView.js @@ -8,7 +8,7 @@ * @format */ -import type {____ViewStyle_Internal} from '../../StyleSheet/StyleSheetTypes'; +import type {ViewStyle} from '../../StyleSheet/StyleSheetTypes'; import type { AnimatedComponentType, AnimatedProps, @@ -100,7 +100,7 @@ const AnimatedScrollViewWithInvertedRefreshControl = // Handle animated props on `refreshControl`. const [refreshControlAnimatedProps, refreshControlRef] = useAnimatedProps< - {style: ?____ViewStyle_Internal}, + {style: ?ViewStyle}, $FlowFixMe, >(intermediatePropsForRefreshControl); // NOTE: Assumes that refreshControl.ref` and `refreshControl.style` can be diff --git a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 3200bb8afc56..396deb24ee93 100644 --- a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -38,11 +38,7 @@ type ActivityIndicatorIOSProps = Readonly<{ hidesWhenStopped?: ?boolean, }>; -/** @build-types emit-as-interface Uniwind compatibility */ -export type ActivityIndicatorProps = Readonly<{ - ...ViewProps, - ...ActivityIndicatorIOSProps, - +type ActivityIndicatorPropsCore = Readonly<{ /** * Whether to show the indicator (`true`) or hide it (`false`). */ @@ -67,6 +63,13 @@ export type ActivityIndicatorProps = Readonly<{ size?: ?IndicatorSize, }>; +/** @build-types emit-as-interface Uniwind compatibility */ +export type ActivityIndicatorProps = Readonly<{ + ...ViewProps, + ...ActivityIndicatorIOSProps, + ...ActivityIndicatorPropsCore, +}>; + /** * Displays a circular loading indicator. * diff --git a/packages/react-native/Libraries/Components/Button.js b/packages/react-native/Libraries/Components/Button.js index c1bec4b65edf..7a37c6382c2e 100644 --- a/packages/react-native/Libraries/Components/Button.js +++ b/packages/react-native/Libraries/Components/Button.js @@ -27,8 +27,7 @@ import View from './View/View'; import invariant from 'invariant'; import * as React from 'react'; -/** @build-types emit-as-interface Uniwind compatibility */ -export type ButtonProps = Readonly<{ +type ButtonPropsCore = Readonly<{ /** * Text to display inside the button. On Android the given title will be * converted to the uppercased form. @@ -167,6 +166,9 @@ export type ButtonProps = Readonly<{ accessibilityLanguage?: ?Stringish, }>; +/** @build-types emit-as-interface Uniwind compatibility */ +export type ButtonProps = ButtonPropsCore; + const NativeTouchable: typeof TouchableNativeFeedback | typeof TouchableOpacity = Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity; diff --git a/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js b/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js index c2a22df4b347..d2fff116cc32 100644 --- a/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js +++ b/packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js @@ -26,10 +26,7 @@ import Keyboard from './Keyboard'; import * as React from 'react'; import {createRef} from 'react'; -/** @build-types emit-as-interface Uniwind compatibility */ -export type KeyboardAvoidingViewProps = Readonly<{ - ...ViewProps, - +type KeyboardAvoidingViewPropsCore = Readonly<{ /** * Specify how to react to the presence of the keyboard. */ @@ -56,6 +53,12 @@ export type KeyboardAvoidingViewProps = Readonly<{ keyboardVerticalOffset?: number, }>; +/** @build-types emit-as-interface Uniwind compatibility */ +export type KeyboardAvoidingViewProps = Readonly<{ + ...ViewProps, + ...KeyboardAvoidingViewPropsCore, +}>; + type KeyboardAvoidingViewState = { bottom: number, }; diff --git a/packages/react-native/Libraries/Components/Pressable/Pressable.js b/packages/react-native/Libraries/Components/Pressable/Pressable.js index c96e0c7001ce..ba26272d9304 100644 --- a/packages/react-native/Libraries/Components/Pressable/Pressable.js +++ b/packages/react-native/Libraries/Components/Pressable/Pressable.js @@ -32,11 +32,13 @@ export type PressableInstance = HostInstance; export type {PressableAndroidRippleConfig}; -/** @build-types emit-as-interface react-native-web compatibility */ -export type PressableStateCallbackType = Readonly<{ +type PressableStateCallbackTypeCore = Readonly<{ pressed: boolean, }>; +/** @build-types emit-as-interface react-native-web compatibility */ +export type PressableStateCallbackType = PressableStateCallbackTypeCore; + type PressableBaseProps = Readonly<{ /** * Whether a press gesture can be interrupted by a parent gesture such as a diff --git a/packages/react-native/Libraries/Components/TextInput/InputAccessoryView.js b/packages/react-native/Libraries/Components/TextInput/InputAccessoryView.js index e00db0a1fa35..5ded8e707aed 100644 --- a/packages/react-native/Libraries/Components/TextInput/InputAccessoryView.js +++ b/packages/react-native/Libraries/Components/TextInput/InputAccessoryView.js @@ -18,12 +18,7 @@ import useWindowDimensions from '../../Utilities/useWindowDimensions'; import RCTInputAccessoryViewNativeComponent from './RCTInputAccessoryViewNativeComponent'; import * as React from 'react'; -/** - * InputAccessoryView is deprecated and will be removed in a future release. - * @deprecated - * @build-types emit-as-interface Expo compatibility - */ -export type InputAccessoryViewProps = Readonly<{ +type InputAccessoryViewPropsCore = Readonly<{ readonly children: React.Node, /** * An ID used to associate this `InputAccessoryView` to specified `TextInput`(s). @@ -33,6 +28,13 @@ export type InputAccessoryViewProps = Readonly<{ backgroundColor?: ?ColorValue, }>; +/** + * InputAccessoryView is deprecated and will be removed in a future release. + * @deprecated + * @build-types emit-as-interface Expo compatibility + */ +export type InputAccessoryViewProps = InputAccessoryViewPropsCore; + /** * A component which enables customization of the keyboard input accessory view on iOS. The input accessory view is displayed above the keyboard whenever a `TextInput` has focus. This component can be used to create custom toolbars. * diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.js b/packages/react-native/Libraries/Components/TextInput/TextInput.js index ee48b398c125..abcc3d815d36 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.js @@ -9,7 +9,7 @@ */ import type {HostInstance} from '../../../src/private/types/HostInstance'; -import type {____TextStyle_Internal as TextStyleInternal} from '../../StyleSheet/StyleSheetTypes'; +import type {TextStyle} from '../../StyleSheet/StyleSheetTypes'; import type { BlurEvent, FocusEvent, @@ -543,16 +543,16 @@ function InternalTextInput(props: TextInputProps): React.Node { let _style = props.style; const flattenedStyle = flattenStyle(props.style); if (flattenedStyle != null) { - let overrides: ?{...TextStyleInternal} = null; + let overrides: ?{...TextStyle} = null; if (typeof flattenedStyle?.fontWeight === 'number') { - overrides = overrides || ({} as {...TextStyleInternal}); + overrides = overrides || ({} as {...TextStyle}); overrides.fontWeight = // $FlowFixMe[incompatible-type] - flattenedStyle.fontWeight.toString() as TextStyleInternal['fontWeight']; + flattenedStyle.fontWeight.toString() as TextStyle['fontWeight']; } if (flattenedStyle.verticalAlign != null) { - overrides = overrides || ({} as {...TextStyleInternal}); + overrides = overrides || ({} as {...TextStyle}); overrides.textAlignVertical = verticalAlignToTextAlignVerticalMap[flattenedStyle.verticalAlign]; overrides.verticalAlign = undefined; diff --git a/packages/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/packages/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js index 3e9b92ad06b1..92c4ba114b7f 100755 --- a/packages/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ b/packages/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js @@ -36,92 +36,93 @@ export type TouchableWithoutFeedbackPropsAndroid = { touchSoundDisabled?: ?boolean, }; +type TouchableWithoutFeedbackPropsCore = { + children?: ?React.Node, + /** + * Delay in ms, from onPressIn, before onLongPress is called. + */ + delayLongPress?: ?number, + /** + * Delay in ms, from the start of the touch, before onPressIn is called. + */ + delayPressIn?: ?number, + /** + * Delay in ms, from the release of the touch, before onPressOut is called. + */ + delayPressOut?: ?number, + /** + * If true, disable all interactions for this component. + */ + disabled?: ?boolean, + /** + * Whether this View should be focusable with a non-touch input device, + * eg. receive focus with a hardware keyboard / TV remote. + */ + focusable?: ?boolean, + /** + * This defines how far your touch can start away from the button. + * This is added to pressRetentionOffset when moving off of the button. + * NOTE The touch area never extends past the parent view bounds and + * the Z-index of sibling views always takes precedence if a touch hits + * two overlapping views. + */ + hitSlop?: ?EdgeInsetsOrSizeProp, + /** + * Used to reference react managed views from native code. + */ + id?: string, + importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'), + nativeID?: ?string, + onAccessibilityAction?: ?(event: AccessibilityActionEvent) => unknown, + /** + * When `accessible` is true (which is the default) this may be called when + * the OS-specific concept of "blur" occurs, meaning the element lost focus. + * Some platforms may not have the concept of blur. + */ + onBlur?: ?(event: BlurEvent) => unknown, + /** + * When `accessible` is true (which is the default) this may be called when + * the OS-specific concept of "focus" occurs. Some platforms may not have + * the concept of focus. + */ + onFocus?: ?(event: FocusEvent) => unknown, + /** + * Invoked on mount and layout changes with + * {nativeEvent: {layout: {x, y, width, height}}} + */ + onLayout?: ?(event: LayoutChangeEvent) => unknown, + onLongPress?: ?(event: GestureResponderEvent) => unknown, + /** + * Called when the touch is released, + * but not if cancelled (e.g. by a scroll that steals the responder lock). + */ + onPress?: ?(event: GestureResponderEvent) => unknown, + onPressIn?: ?(event: GestureResponderEvent) => unknown, + onPressOut?: ?(event: GestureResponderEvent) => unknown, + /** + * When the scroll view is disabled, this defines how far your + * touch may move off of the button, before deactivating the button. + * Once deactivated, try moving it back and you'll see that the button + * is once again reactivated! Move it back and forth several times + * while the scroll view is disabled. Ensure you pass in a constant + * to reduce memory allocations. + */ + pressRetentionOffset?: ?EdgeInsetsOrSizeProp, + rejectResponderTermination?: ?boolean, + /** + * Used to locate this view in end-to-end tests. + */ + testID?: ?string, + /** + * //FIXME: not in doc but available in examples + */ + style?: ?ViewStyleProp, +}; + /** @build-types emit-as-interface Expo compatibility */ export type TouchableWithoutFeedbackProps = Readonly< - { - children?: ?React.Node, - /** - * Delay in ms, from onPressIn, before onLongPress is called. - */ - delayLongPress?: ?number, - /** - * Delay in ms, from the start of the touch, before onPressIn is called. - */ - delayPressIn?: ?number, - /** - * Delay in ms, from the release of the touch, before onPressOut is called. - */ - delayPressOut?: ?number, - /** - * If true, disable all interactions for this component. - */ - disabled?: ?boolean, - /** - * Whether this View should be focusable with a non-touch input device, - * eg. receive focus with a hardware keyboard / TV remote. - */ - focusable?: ?boolean, - /** - * This defines how far your touch can start away from the button. - * This is added to pressRetentionOffset when moving off of the button. - * NOTE The touch area never extends past the parent view bounds and - * the Z-index of sibling views always takes precedence if a touch hits - * two overlapping views. - */ - hitSlop?: ?EdgeInsetsOrSizeProp, - /** - * Used to reference react managed views from native code. - */ - id?: string, - importantForAccessibility?: ?( - 'auto' | 'yes' | 'no' | 'no-hide-descendants' - ), - nativeID?: ?string, - onAccessibilityAction?: ?(event: AccessibilityActionEvent) => unknown, - /** - * When `accessible` is true (which is the default) this may be called when - * the OS-specific concept of "blur" occurs, meaning the element lost focus. - * Some platforms may not have the concept of blur. - */ - onBlur?: ?(event: BlurEvent) => unknown, - /** - * When `accessible` is true (which is the default) this may be called when - * the OS-specific concept of "focus" occurs. Some platforms may not have - * the concept of focus. - */ - onFocus?: ?(event: FocusEvent) => unknown, - /** - * Invoked on mount and layout changes with - * {nativeEvent: {layout: {x, y, width, height}}} - */ - onLayout?: ?(event: LayoutChangeEvent) => unknown, - onLongPress?: ?(event: GestureResponderEvent) => unknown, - /** - * Called when the touch is released, - * but not if cancelled (e.g. by a scroll that steals the responder lock). - */ - onPress?: ?(event: GestureResponderEvent) => unknown, - onPressIn?: ?(event: GestureResponderEvent) => unknown, - onPressOut?: ?(event: GestureResponderEvent) => unknown, - /** - * When the scroll view is disabled, this defines how far your - * touch may move off of the button, before deactivating the button. - * Once deactivated, try moving it back and you'll see that the button - * is once again reactivated! Move it back and forth several times - * while the scroll view is disabled. Ensure you pass in a constant - * to reduce memory allocations. - */ - pressRetentionOffset?: ?EdgeInsetsOrSizeProp, - rejectResponderTermination?: ?boolean, - /** - * Used to locate this view in end-to-end tests. - */ - testID?: ?string, - /** - * //FIXME: not in doc but available in examples - */ - style?: ?ViewStyleProp, - } & TouchableWithoutFeedbackPropsAndroid & + TouchableWithoutFeedbackPropsCore & + TouchableWithoutFeedbackPropsAndroid & TouchableWithoutFeedbackPropsIOS & AccessibilityProps, >; diff --git a/packages/react-native/Libraries/Components/View/ViewAccessibility.js b/packages/react-native/Libraries/Components/View/ViewAccessibility.js index 369388635674..5c1b250a1462 100644 --- a/packages/react-native/Libraries/Components/View/ViewAccessibility.js +++ b/packages/react-native/Libraries/Components/View/ViewAccessibility.js @@ -349,10 +349,7 @@ export type AccessibilityPropsIOS = Readonly<{ accessibilityRespondsToUserInteraction?: ?boolean, }>; -/** @build-types emit-as-interface react-native-web compatibility */ -export type AccessibilityProps = Readonly<{ - ...AccessibilityPropsAndroid, - ...AccessibilityPropsIOS, +type AccessibilityPropsCore = Readonly<{ /** * When `true`, indicates that the view is an accessibility element. * By default, all the touchable elements are accessible. @@ -434,3 +431,10 @@ export type AccessibilityProps = Readonly<{ */ 'aria-hidden'?: ?boolean, }>; + +/** @build-types emit-as-interface react-native-web compatibility */ +export type AccessibilityProps = Readonly<{ + ...AccessibilityPropsAndroid, + ...AccessibilityPropsIOS, + ...AccessibilityPropsCore, +}>; diff --git a/packages/react-native/Libraries/Image/ImageProps.js b/packages/react-native/Libraries/Image/ImageProps.js index 124ffe9a4e2b..3dd4213e92c1 100644 --- a/packages/react-native/Libraries/Image/ImageProps.js +++ b/packages/react-native/Libraries/Image/ImageProps.js @@ -147,10 +147,7 @@ export type ImagePropsAndroid = Readonly<{ resizeMultiplier?: ?number, }>; -/** @build-types emit-as-interface Expo compatibility */ -export type ImagePropsBase = Readonly<{ - ...Omit, - +type ImagePropsBaseCore = Readonly<{ /** * When `true`, indicates the image is an accessibility element. */ @@ -327,27 +324,38 @@ export type ImagePropsBase = Readonly<{ children?: empty, }>; -/** @build-types emit-as-interface react-native-web compatibility */ -export type ImageProps = Readonly<{ - ...ImagePropsIOS, - ...ImagePropsAndroid, - ...ImagePropsBase, +/** @build-types emit-as-interface Expo compatibility */ +export type ImagePropsBase = Readonly<{ + ...Omit< + ViewProps, + | 'accessibilityLabel' + | 'accessible' + | 'aria-label' + | 'aria-labelledby' + | 'children' + | 'onLayout' + | 'style' + | 'testID', + >, + ...ImagePropsBaseCore, +}>; +type ImagePropsCore = Readonly<{ /** * Style applied to the `Image` component. */ style?: ?ImageStyleProp, }>; -/** - * ImageBackground is deprecated and will be removed in a future release. - * Use a `View` with an absolutely positioned `Image` instead. - * @see https://reactnative.dev/docs/imagebackground - * @deprecated - * @build-types emit-as-interface Uniwind compatibility - */ -export type ImageBackgroundProps = Readonly<{ - ...ImageProps, +/** @build-types emit-as-interface react-native-web compatibility */ +export type ImageProps = Readonly<{ + ...ImagePropsIOS, + ...ImagePropsAndroid, + ...ImagePropsBase, + ...ImagePropsCore, +}>; + +type ImageBackgroundPropsCore = Readonly<{ children?: React.Node, /** @@ -367,3 +375,15 @@ export type ImageBackgroundProps = Readonly<{ */ imageRef?: React.RefSetter>, }>; + +/** + * ImageBackground is deprecated and will be removed in a future release. + * Use a `View` with an absolutely positioned `Image` instead. + * @see https://reactnative.dev/docs/imagebackground + * @deprecated + * @build-types emit-as-interface Uniwind compatibility + */ +export type ImageBackgroundProps = Readonly<{ + ...Omit, + ...ImageBackgroundPropsCore, +}>; diff --git a/packages/react-native/Libraries/Modal/Modal.js b/packages/react-native/Libraries/Modal/Modal.js index e011fc20763e..67d5cab2d6b4 100644 --- a/packages/react-native/Libraries/Modal/Modal.js +++ b/packages/react-native/Libraries/Modal/Modal.js @@ -41,8 +41,7 @@ type OrientationChangeEvent = Readonly<{ orientation: 'portrait' | 'landscape', }>; -/** @build-types emit-as-interface Uniwind compatibility */ -export type ModalBaseProps = { +type ModalBasePropsCore = { /** * Controls how the modal animates. `'slide'` slides in from the bottom, * `'fade'` fades into view, `'none'` appears without animation. @@ -92,6 +91,9 @@ export type ModalBaseProps = { modalRef?: React.RefSetter, }; +/** @build-types emit-as-interface Uniwind compatibility */ +export type ModalBaseProps = ModalBasePropsCore; + export type ModalPropsIOS = { /** * Controls how the modal appears. diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheet.js b/packages/react-native/Libraries/StyleSheet/StyleSheet.js index 097a6e500e85..cb7995224fad 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheet.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheet.js @@ -133,7 +133,7 @@ export type TypeForStyleKey< * object of styles to pass to a View that can't be precomputed with * StyleSheet.create. */ -export type {____ViewStyle_Internal as ViewStyle} from './StyleSheetTypes'; +export type {ViewStyle} from './StyleSheetTypes'; /** * This type is an object of the different possible style @@ -150,7 +150,7 @@ export type {____ViewStyle_Internal as ViewStyle} from './StyleSheetTypes'; * object of styles to pass to a Text that can't be precomputed with * StyleSheet.create. */ -export type {____TextStyle_Internal as TextStyle} from './StyleSheetTypes'; +export type {TextStyle} from './StyleSheetTypes'; /** * This type is an object of the different possible style @@ -167,7 +167,7 @@ export type {____TextStyle_Internal as TextStyle} from './StyleSheetTypes'; * object of styles to pass to an Image that can't be precomputed with * StyleSheet.create. */ -export type {____ImageStyle_Internal as ImageStyle} from './StyleSheetTypes'; +export type {ImageStyle} from './StyleSheetTypes'; /** * WARNING: You probably shouldn't be using this type. This type is an object diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow b/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow index 0a25841a93a7..dca8e05c6c66 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow +++ b/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow @@ -134,7 +134,7 @@ export type TypeForStyleKey< * object of styles to pass to a View that can't be precomputed with * StyleSheet.create. */ -export type {____ViewStyle_Internal as ViewStyle} from './StyleSheetTypes'; +export type {ViewStyle} from './StyleSheetTypes'; /** * This type is an object of the different possible style @@ -151,7 +151,7 @@ export type {____ViewStyle_Internal as ViewStyle} from './StyleSheetTypes'; * object of styles to pass to a Text that can't be precomputed with * StyleSheet.create. */ -export type {____TextStyle_Internal as TextStyle} from './StyleSheetTypes'; +export type {TextStyle} from './StyleSheetTypes'; /** * This type is an object of the different possible style @@ -168,7 +168,7 @@ export type {____TextStyle_Internal as TextStyle} from './StyleSheetTypes'; * object of styles to pass to an Image that can't be precomputed with * StyleSheet.create. */ -export type {____ImageStyle_Internal as ImageStyle} from './StyleSheetTypes'; +export type {ImageStyle} from './StyleSheetTypes'; /** * WARNING: You probably shouldn't be using this type. This type is an object diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js index 5e4289f1b84d..13b5b4c095d8 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js @@ -911,7 +911,7 @@ export type ____ViewStyle_InternalCore = Readonly<{ }>; /** @build-types emit-as-interface react-native-web compatibility */ -export type ____ViewStyle_Internal = Readonly<{ +export type ViewStyle = Readonly<{ ...____ViewStyle_InternalCore, ...____ViewStyle_InternalOverrides, }>; @@ -1048,18 +1048,18 @@ type ____TextStyle_InternalBase = Readonly<{ }>; export type ____TextStyle_InternalCore = Readonly<{ - ...$Exact<____ViewStyle_Internal>, + ...$Exact, ...____TextStyle_InternalBase, }>; /** @build-types emit-as-interface react-native-web compatibility */ -export type ____TextStyle_Internal = Readonly<{ +export type TextStyle = Readonly<{ ...____TextStyle_InternalCore, ...____TextStyle_InternalOverrides, }>; export type ____ImageStyle_InternalCore = Readonly<{ - ...$Exact<____ViewStyle_Internal>, + ...$Exact, resizeMode?: ImageResizeMode, objectFit?: 'cover' | 'contain' | 'fill' | 'scale-down' | 'none', tintColor?: ____ColorValue_Internal, @@ -1068,13 +1068,13 @@ export type ____ImageStyle_InternalCore = Readonly<{ }>; /** @build-types emit-as-interface react-native-web compatibility */ -export type ____ImageStyle_Internal = Readonly<{ +export type ImageStyle = Readonly<{ ...____ImageStyle_InternalCore, ...____ImageStyle_InternalOverrides, }>; export type ____DangerouslyImpreciseStyle_InternalCore = Readonly<{ - ...$Exact<____TextStyle_Internal>, + ...$Exact, resizeMode?: ImageResizeMode, objectFit?: 'cover' | 'contain' | 'fill' | 'scale-down' | 'none', tintColor?: ____ColorValue_Internal, @@ -1098,13 +1098,13 @@ export type ____DangerouslyImpreciseAnimatedStyleProp_Internal = WithAnimatedValue>>; export type ____ViewStyleProp_Internal = StyleProp< - Readonly>, + Readonly>, >; export type ____TextStyleProp_Internal = StyleProp< - Readonly>, + Readonly>, >; export type ____ImageStyleProp_Internal = StyleProp< - Readonly>, + Readonly>, >; export type ____Styles_Internal = { diff --git a/packages/react-native/Libraries/StyleSheet/splitLayoutProps.js b/packages/react-native/Libraries/StyleSheet/splitLayoutProps.js index acf2dbbeedb8..e37b9b749d0b 100644 --- a/packages/react-native/Libraries/StyleSheet/splitLayoutProps.js +++ b/packages/react-native/Libraries/StyleSheet/splitLayoutProps.js @@ -8,14 +8,14 @@ * @format */ -import type {____ViewStyle_Internal} from './StyleSheetTypes'; +import type {ViewStyle} from './StyleSheetTypes'; -export default function splitLayoutProps(props: ?____ViewStyle_Internal): { - outer: ?____ViewStyle_Internal, - inner: ?____ViewStyle_Internal, +export default function splitLayoutProps(props: ?ViewStyle): { + outer: ?ViewStyle, + inner: ?ViewStyle, } { - let outer: ?____ViewStyle_Internal = null; - let inner: ?____ViewStyle_Internal = null; + let outer: ?ViewStyle = null; + let inner: ?ViewStyle = null; if (props != null) { // $FlowFixMe[incompatible-exact] Will contain a subset of keys from `props`. diff --git a/packages/react-native/Libraries/Text/Text.js b/packages/react-native/Libraries/Text/Text.js index 902fcaba8bdf..c4011095e9de 100644 --- a/packages/react-native/Libraries/Text/Text.js +++ b/packages/react-native/Libraries/Text/Text.js @@ -10,7 +10,7 @@ import type {HostInstance} from '../../src/private/types/HostInstance'; import type {TextStyleProp} from '../StyleSheet/StyleSheet'; -import type {____TextStyle_Internal as TextStyleInternal} from '../StyleSheet/StyleSheetTypes'; +import type {TextStyle} from '../StyleSheet/StyleSheetTypes'; import type {GestureResponderEvent} from '../Types/CoreEventTypes'; import type {NativeTextProps} from './TextNativeComponent'; import type {PressRetentionOffset, TextProps} from './TextProps'; @@ -191,22 +191,22 @@ const TextImpl: component( let processedStyle = flattenStyle(_style); if (processedStyle != null) { - let overrides: ?{...TextStyleInternal} = null; + let overrides: ?{...TextStyle} = null; if (typeof processedStyle.fontWeight === 'number') { - overrides = overrides || ({} as {...TextStyleInternal}); + overrides = overrides || ({} as {...TextStyle}); overrides.fontWeight = // $FlowFixMe[incompatible-type] - String(processedStyle.fontWeight) as TextStyleInternal['fontWeight']; + String(processedStyle.fontWeight) as TextStyle['fontWeight']; } if (processedStyle.userSelect != null) { _selectable = userSelectToSelectableMap[processedStyle.userSelect]; - overrides = overrides || ({} as {...TextStyleInternal}); + overrides = overrides || ({} as {...TextStyle}); overrides.userSelect = undefined; } if (processedStyle.verticalAlign != null) { - overrides = overrides || ({} as {...TextStyleInternal}); + overrides = overrides || ({} as {...TextStyle}); overrides.textAlignVertical = verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign]; overrides.verticalAlign = undefined; diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index def7005e2fca..fb3f2b24acef 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -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. * - * @generated SignedSource<> + * @generated SignedSource<<30a2cb72e1b9998ec25ba50a2cd85205>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -973,28 +973,7 @@ declare type AccessibilityEventTypes = "click" | "focus" | "viewHoverEnter" | "windowStateChange" declare type AccessibilityInfo = typeof AccessibilityInfo declare interface AccessibilityProps extends Readonly< - AccessibilityPropsAndroid & - AccessibilityPropsIOS & { - accessibilityActions?: ReadonlyArray - accessibilityHint?: string - accessibilityLabel?: string - accessibilityRole?: AccessibilityRole - accessibilityState?: AccessibilityState - accessibilityValue?: AccessibilityValue - accessible?: boolean - "aria-busy"?: boolean - "aria-checked"?: "mixed" | (boolean | undefined) - "aria-disabled"?: boolean - "aria-expanded"?: boolean - "aria-hidden"?: boolean - "aria-label"?: string - "aria-selected"?: boolean - "aria-valuemax"?: AccessibilityValue["max"] - "aria-valuemin"?: AccessibilityValue["min"] - "aria-valuenow"?: AccessibilityValue["now"] - "aria-valuetext"?: AccessibilityValue["text"] - role?: Role - } + AccessibilityPropsAndroid & AccessibilityPropsIOS & AccessibilityPropsCore > {} declare type AccessibilityPropsAndroid = { readonly accessibilityLabelledBy?: @@ -1006,6 +985,27 @@ declare type AccessibilityPropsAndroid = { "auto" | "no-hide-descendants" | "no" | "yes" readonly screenReaderFocusable?: boolean } +declare type AccessibilityPropsCore = { + readonly accessibilityActions?: ReadonlyArray + readonly accessibilityHint?: string + readonly accessibilityLabel?: string + readonly accessibilityRole?: AccessibilityRole + readonly accessibilityState?: AccessibilityState + readonly accessibilityValue?: AccessibilityValue + readonly accessible?: boolean + readonly "aria-busy"?: boolean + readonly "aria-checked"?: "mixed" | (boolean | undefined) + readonly "aria-disabled"?: boolean + readonly "aria-expanded"?: boolean + readonly "aria-hidden"?: boolean + readonly "aria-label"?: string + readonly "aria-selected"?: boolean + readonly "aria-valuemax"?: AccessibilityValue["max"] + readonly "aria-valuemin"?: AccessibilityValue["min"] + readonly "aria-valuenow"?: AccessibilityValue["now"] + readonly "aria-valuetext"?: AccessibilityValue["text"] + readonly role?: Role +} declare type AccessibilityPropsIOS = { readonly accessibilityElementsHidden?: boolean readonly accessibilityIgnoresInvertColors?: boolean @@ -1096,13 +1096,13 @@ declare type ActivityIndicatorIOSProps = { readonly hidesWhenStopped?: boolean } declare interface ActivityIndicatorProps extends Readonly< - ViewProps & - ActivityIndicatorIOSProps & { - animating?: boolean - color?: ColorValue - size?: IndicatorSize - } + ViewProps & ActivityIndicatorIOSProps & ActivityIndicatorPropsCore > {} +declare type ActivityIndicatorPropsCore = { + readonly animating?: boolean + readonly color?: ColorValue + readonly size?: IndicatorSize +} declare type add = typeof add declare function addChangeListener( listener: (preferences: AppearancePreferences) => void, @@ -1655,34 +1655,36 @@ declare type Builtin = ( ) => Date | Error | RegExp | unknown declare type Button = typeof Button declare type ButtonInstance = React.ComponentRef -declare interface ButtonProps extends Readonly<{ - accessibilityActions?: ReadonlyArray - accessibilityHint?: string - accessibilityLabel?: string - accessibilityLanguage?: string - accessibilityState?: AccessibilityState - accessible?: boolean - "aria-busy"?: boolean - "aria-checked"?: "mixed" | (boolean | undefined) - "aria-disabled"?: boolean - "aria-expanded"?: boolean - "aria-label"?: string - "aria-selected"?: boolean - color?: ColorValue - disabled?: boolean - hasTVPreferredFocus?: boolean - importantForAccessibility?: "auto" | "no-hide-descendants" | "no" | "yes" - nextFocusDown?: number - nextFocusForward?: number - nextFocusLeft?: number - nextFocusRight?: number - nextFocusUp?: number - onAccessibilityAction?: (event: AccessibilityActionEvent) => unknown - onPress?: (event?: GestureResponderEvent) => unknown - testID?: string - title: string - touchSoundDisabled?: boolean -}> {} +declare interface ButtonProps extends ButtonPropsCore {} +declare type ButtonPropsCore = { + readonly accessibilityActions?: ReadonlyArray + readonly accessibilityHint?: string + readonly accessibilityLabel?: string + readonly accessibilityLanguage?: string + readonly accessibilityState?: AccessibilityState + readonly accessible?: boolean + readonly "aria-busy"?: boolean + readonly "aria-checked"?: "mixed" | (boolean | undefined) + readonly "aria-disabled"?: boolean + readonly "aria-expanded"?: boolean + readonly "aria-label"?: string + readonly "aria-selected"?: boolean + readonly color?: ColorValue + readonly disabled?: boolean + readonly hasTVPreferredFocus?: boolean + readonly importantForAccessibility?: + "auto" | "no-hide-descendants" | "no" | "yes" + readonly nextFocusDown?: number + readonly nextFocusForward?: number + readonly nextFocusLeft?: number + readonly nextFocusRight?: number + readonly nextFocusUp?: number + readonly onAccessibilityAction?: (event: AccessibilityActionEvent) => unknown + readonly onPress?: (event?: GestureResponderEvent) => unknown + readonly testID?: string + readonly title: string + readonly touchSoundDisabled?: boolean +} declare function cancelHeadlessTask(taskId: number, taskKey: string): void declare type Category = string declare type CellMetricProps = { @@ -2418,13 +2420,14 @@ declare class ImageBackground extends React.Component { } declare type ImageBackgroundInstance = ImageBackground declare interface ImageBackgroundProps extends Readonly< - Omit & { - children?: React.ReactNode - imageRef?: React.Ref> - imageStyle?: ImageStyleProp - style?: ViewStyleProp - } + Omit & ImageBackgroundPropsCore > {} +declare type ImageBackgroundPropsCore = { + readonly children?: React.ReactNode + readonly imageRef?: React.Ref> + readonly imageStyle?: ImageStyleProp + readonly style?: ViewStyleProp +} declare type ImageComponentStaticsAndroid = Readonly< ImageComponentStaticsIOS & { abortPrefetch(requestId: number): void @@ -2486,11 +2489,7 @@ declare type ImageProgressEventIOS = NativeSyntheticEvent< Readonly > declare interface ImageProps extends Readonly< - ImagePropsIOS & - ImagePropsAndroid & - Omit & { - style?: ImageStyleProp - } + ImagePropsIOS & ImagePropsAndroid & ImagePropsBase & ImagePropsCore > {} declare type ImagePropsAndroid = { readonly fadeDuration?: number @@ -2501,49 +2500,55 @@ declare type ImagePropsAndroid = { } declare interface ImagePropsBase extends Readonly< Omit< - Omit, + ViewProps, | "accessibilityLabel" | "accessible" | "aria-label" | "aria-labelledby" | "children" | "onLayout" + | "style" | "testID" - > & { - accessibilityLabel?: string - accessible?: boolean - alt?: string - "aria-label"?: string - "aria-labelledby"?: string - blurRadius?: number - capInsets?: EdgeInsetsProp - children?: never - crossOrigin?: "anonymous" | "use-credentials" - height?: number - internal_analyticTag?: string - onError?: (event: ImageErrorEvent) => void - onLayout?: (event: LayoutChangeEvent) => unknown - onLoad?: (event: ImageLoadEvent) => void - onLoadEnd?: () => void - onLoadStart?: () => void - referrerPolicy?: - | "no-referrer-when-downgrade" - | "no-referrer" - | "origin-when-cross-origin" - | "origin" - | "same-origin" - | "strict-origin-when-cross-origin" - | "strict-origin" - | "unsafe-url" - resizeMode?: ImageResizeMode - source?: ImageSource - src?: string - srcSet?: string - testID?: string - tintColor?: ColorValue - width?: number - } + > & + ImagePropsBaseCore > {} +declare type ImagePropsBaseCore = { + readonly accessibilityLabel?: string + readonly accessible?: boolean + readonly alt?: string + readonly "aria-label"?: string + readonly "aria-labelledby"?: string + readonly blurRadius?: number + readonly capInsets?: EdgeInsetsProp + readonly children?: never + readonly crossOrigin?: "anonymous" | "use-credentials" + readonly height?: number + readonly internal_analyticTag?: string + readonly onError?: (event: ImageErrorEvent) => void + readonly onLayout?: (event: LayoutChangeEvent) => unknown + readonly onLoad?: (event: ImageLoadEvent) => void + readonly onLoadEnd?: () => void + readonly onLoadStart?: () => void + readonly referrerPolicy?: + | "no-referrer-when-downgrade" + | "no-referrer" + | "origin-when-cross-origin" + | "origin" + | "same-origin" + | "strict-origin-when-cross-origin" + | "strict-origin" + | "unsafe-url" + readonly resizeMode?: ImageResizeMode + readonly source?: ImageSource + readonly src?: string + readonly srcSet?: string + readonly testID?: string + readonly tintColor?: ColorValue + readonly width?: number +} +declare type ImagePropsCore = { + readonly style?: ImageStyleProp +} declare type ImagePropsIOS = { readonly defaultSource?: ImageSource readonly onPartialLoad?: () => void @@ -2604,12 +2609,13 @@ declare class Info { } declare type InnerViewInstance = React.ComponentRef declare type InputAccessoryView = typeof InputAccessoryView -declare interface InputAccessoryViewProps extends Readonly<{ - backgroundColor?: ColorValue +declare interface InputAccessoryViewProps extends InputAccessoryViewPropsCore {} +declare type InputAccessoryViewPropsCore = { + readonly backgroundColor?: ColorValue readonly children: React.ReactNode - nativeID?: string - style?: ViewStyleProp -}> {} + readonly nativeID?: string + readonly style?: ViewStyleProp +} declare type InputModeOptions = "decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url" declare type InputValue = @@ -2728,13 +2734,14 @@ declare class KeyboardAvoidingView extends React.Component< } declare type KeyboardAvoidingViewInstance = KeyboardAvoidingView declare interface KeyboardAvoidingViewProps extends Readonly< - ViewProps & { - behavior?: "height" | "padding" | "position" - contentContainerStyle?: ViewStyleProp - enabled?: boolean - keyboardVerticalOffset?: number - } + ViewProps & KeyboardAvoidingViewPropsCore > {} +declare type KeyboardAvoidingViewPropsCore = { + readonly behavior?: "height" | "padding" | "position" + readonly contentContainerStyle?: ViewStyleProp + readonly enabled?: boolean + readonly keyboardVerticalOffset?: number +} declare type KeyboardAvoidingViewState = { bottom: number } @@ -3007,18 +3014,16 @@ declare type Message = { }> } declare type Modal = typeof Modal -declare interface ModalBaseProps extends Omit< - { - animationType?: "fade" | "none" | "slide" - backdropColor?: ColorValue - modalRef?: React.Ref - onRequestClose?: DirectEventHandler - onShow?: DirectEventHandler - transparent?: boolean - visible?: boolean - }, - never -> {} +declare interface ModalBaseProps extends ModalBasePropsCore {} +declare type ModalBasePropsCore = { + animationType?: "fade" | "none" | "slide" + backdropColor?: ColorValue + modalRef?: React.Ref + onRequestClose?: DirectEventHandler + onShow?: DirectEventHandler + transparent?: boolean + visible?: boolean +} declare type ModalInstance = HostInstance declare type ModalProps = ModalBaseProps & ModalPropsIOS & @@ -3670,9 +3675,10 @@ declare type PressableInstance = HostInstance declare interface PressableProps extends Readonly< Omit & PressableBaseProps > {} -declare interface PressableStateCallbackType extends Readonly<{ - pressed: boolean -}> {} +declare interface PressableStateCallbackType extends PressableStateCallbackTypeCore {} +declare type PressableStateCallbackTypeCore = { + readonly pressed: boolean +} declare type PressRetentionOffset = { readonly bottom: number readonly left: number @@ -4439,14 +4445,13 @@ declare type SectionListInstance = SectionList declare interface SectionListProps< ItemT, SectionT = DefaultSectionT, -> extends Omit< +> extends Readonly< Omit< VirtualizedSectionListProps, "getItem" | "getItemCount" | "keyExtractor" | "renderItem" > & RequiredSectionListProps & - OptionalSectionListProps, - never + OptionalSectionListProps > {} declare type SectionListRenderItem = ( info: SectionListRenderItemInfo, @@ -5336,36 +5341,38 @@ declare function TouchableWithoutFeedback( props: TouchableWithoutFeedbackProps, ): React.ReactNode declare interface TouchableWithoutFeedbackProps extends Readonly< - TouchableWithoutFeedbackPropsAndroid & + TouchableWithoutFeedbackPropsCore & + TouchableWithoutFeedbackPropsAndroid & TouchableWithoutFeedbackPropsIOS & - AccessibilityProps & { - children?: React.ReactNode - delayLongPress?: number - delayPressIn?: number - delayPressOut?: number - disabled?: boolean - focusable?: boolean - hitSlop?: EdgeInsetsOrSizeProp - id?: string - importantForAccessibility?: "auto" | "no-hide-descendants" | "no" | "yes" - nativeID?: string - onAccessibilityAction?: (event: AccessibilityActionEvent) => unknown - onBlur?: (event: BlurEvent) => unknown - onFocus?: (event: FocusEvent) => unknown - onLayout?: (event: LayoutChangeEvent) => unknown - onLongPress?: (event: GestureResponderEvent) => unknown - onPress?: (event: GestureResponderEvent) => unknown - onPressIn?: (event: GestureResponderEvent) => unknown - onPressOut?: (event: GestureResponderEvent) => unknown - pressRetentionOffset?: EdgeInsetsOrSizeProp - rejectResponderTermination?: boolean - style?: ViewStyleProp - testID?: string - } + AccessibilityProps > {} declare type TouchableWithoutFeedbackPropsAndroid = { touchSoundDisabled?: boolean } +declare type TouchableWithoutFeedbackPropsCore = { + children?: React.ReactNode + delayLongPress?: number + delayPressIn?: number + delayPressOut?: number + disabled?: boolean + focusable?: boolean + hitSlop?: EdgeInsetsOrSizeProp + id?: string + importantForAccessibility?: "auto" | "no-hide-descendants" | "no" | "yes" + nativeID?: string + onAccessibilityAction?: (event: AccessibilityActionEvent) => unknown + onBlur?: (event: BlurEvent) => unknown + onFocus?: (event: FocusEvent) => unknown + onLayout?: (event: LayoutChangeEvent) => unknown + onLongPress?: (event: GestureResponderEvent) => unknown + onPress?: (event: GestureResponderEvent) => unknown + onPressIn?: (event: GestureResponderEvent) => unknown + onPressOut?: (event: GestureResponderEvent) => unknown + pressRetentionOffset?: EdgeInsetsOrSizeProp + rejectResponderTermination?: boolean + style?: ViewStyleProp + testID?: string +} declare type TouchableWithoutFeedbackPropsIOS = {} declare type TouchEventProps = { readonly onTouchCancel?: (e: GestureResponderEvent) => void @@ -5748,22 +5755,22 @@ export { AccessibilityActionEvent, // a0d4daa0 AccessibilityActionInfo, // db47a917 AccessibilityInfo, // 23a3aa9b - AccessibilityProps, // 38fadc29 + AccessibilityProps, // db9967d1 AccessibilityRole, // f2f2e066 AccessibilityState, // b0c2b3f7 AccessibilityValue, // cf8bcb74 ActionSheetIOS, // b558559e ActionSheetIOSOptions, // 1756eb5a - ActivityIndicator, // 262ca482 + ActivityIndicator, // 35880f07 ActivityIndicatorInstance, // a82dd4e7 - ActivityIndicatorProps, // 35ad74c3 + ActivityIndicatorProps, // 1f6982d0 Alert, // a398a509 AlertButton, // bf1a3b60 AlertButtonStyle, // ec9fb242 AlertOptions, // 8a116d2a AlertType, // 5ab91217 AndroidKeyboardEvent, // e03becc8 - Animated, // f8125d9a + Animated, // 121c9395 AppConfig, // 35c0ca70 AppRegistry, // 831f9c19 AppState, // 12012be5 @@ -5777,9 +5784,9 @@ export { BackPressEventName, // 4620fb76 BlurEvent, // 4ba4f941 BoxShadowValue, // b679703f - Button, // 9a214973 - ButtonInstance, // 548918b2 - ButtonProps, // e48830f2 + Button, // b924773c + ButtonInstance, // 87304eda + ButtonProps, // ac8c2275 Clipboard, // 41addb89 CodegenTypes, // ab4986cc ColorSchemeName, // 6615edd6 @@ -5797,9 +5804,9 @@ export { DimensionsPayload, // 653bc26c DisplayMetrics, // 1dc35cef DisplayMetricsAndroid, // 872e62eb - DrawerLayoutAndroid, // 2d6a492a + DrawerLayoutAndroid, // 6342195b DrawerLayoutAndroidInstance, // c0694352 - DrawerLayoutAndroidProps, // 24b20710 + DrawerLayoutAndroidProps, // 34a48ed7 DrawerSlideEvent, // c4ab8fba DropShadowValue, // e9df2606 DynamicColorIOS, // d96c228c @@ -5815,9 +5822,9 @@ export { EventSubscription, // b8d084aa ExtendedExceptionData, // 5a6ccf5a FilterFunction, // bf24c0e3 - FlatList, // 36f5a90b - FlatListInstance, // 40594c62 - FlatListProps, // 065a6050 + FlatList, // 5bc6589c + FlatListInstance, // 1b8b5636 + FlatListProps, // be53039d FocusEvent, // 850f1517 FontVariant, // 7c7558bb GestureResponderEvent, // 14d3e77a @@ -5828,17 +5835,17 @@ export { IEventEmitter, // fbef6131 IOSKeyboardEvent, // e67bfe3a IgnorePattern, // ec6f6ece - Image, // 305c77ac - ImageBackground, // 0b0db336 - ImageBackgroundInstance, // 9299c8f6 - ImageBackgroundProps, // 26ac5fb5 + Image, // 4993d598 + ImageBackground, // ae70e62b + ImageBackgroundInstance, // 94ac9674 + ImageBackgroundProps, // e4415bdf ImageErrorEvent, // 978933f4 ImageInstance, // 9a100753 ImageLoadEvent, // 77f0b718 ImageProgressEventIOS, // 445331a4 - ImageProps, // 7ba1bee7 + ImageProps, // c2c6542a ImagePropsAndroid, // ee00e1d5 - ImagePropsBase, // 17d8c928 + ImagePropsBase, // e8c813d3 ImagePropsIOS, // 9e19c85d ImageRequireSource, // 681d683b ImageResizeMode, // d51106e2 @@ -5848,17 +5855,17 @@ export { ImageSourcePropType, // f522e093 ImageStyle, // 85dc694a ImageURISource, // 443d047c - InputAccessoryView, // f4ef0505 - InputAccessoryViewProps, // 30a87786 + InputAccessoryView, // ab6e2a66 + InputAccessoryViewProps, // 73685b83 InputModeOptions, // 4e8581b9 Insets, // e7fe432a KeyDownEvent, // 5b147614 KeyEvent, // 20fa4267 KeyUpEvent, // 57f832c5 Keyboard, // 49414c97 - KeyboardAvoidingView, // 9f1248af - KeyboardAvoidingViewInstance, // 72381ee5 - KeyboardAvoidingViewProps, // 59b3d65a + KeyboardAvoidingView, // a4f59a6a + KeyboardAvoidingViewInstance, // a5422c5e + KeyboardAvoidingViewProps, // 3516e037 KeyboardEvent, // c3f895d4 KeyboardEventEasing, // af4091c8 KeyboardEventName, // 59299ad6 @@ -5883,10 +5890,10 @@ export { MeasureInWindowOnSuccessCallback, // a285f598 MeasureLayoutOnSuccessCallback, // 3592502a MeasureOnSuccessCallback, // 82824e59 - Modal, // 85dfed67 - ModalBaseProps, // 050be772 + Modal, // d02a82e4 + ModalBaseProps, // f42d5e75 ModalInstance, // d466ce77 - ModalProps, // 8e98212a + ModalProps, // fb675cc4 ModalPropsAndroid, // 515fb173 ModalPropsIOS, // 664ecb7e ModeChangeEvent, // f64bf69d @@ -5922,15 +5929,15 @@ export { PointerEvent, // ff599afe PressabilityConfig, // fea539a5 PressabilityEventHandlers, // c222648b - Pressable, // 7b7692a2 + Pressable, // 2ebf23a3 PressableAndroidRippleConfig, // ee32eaca PressableInstance, // eebfe911 - PressableProps, // a7055901 - PressableStateCallbackType, // 2a3a68be + PressableProps, // d3b90ef3 + PressableStateCallbackType, // f83728cd ProcessedColorValue, // 33f74304 - ProgressBarAndroid, // c91ddd55 + ProgressBarAndroid, // b8ae77e8 ProgressBarAndroidInstance, // ab545ef1 - ProgressBarAndroidProps, // 5df4b67c + ProgressBarAndroidProps, // 9b7241c1 PublicRootInstance, // 8040afd7 PublicTextInstance, // 6937c7bf PushNotificationEventName, // 84e7e150 @@ -5938,9 +5945,9 @@ export { PushNotificationPermissions, // c2e7ae4f Rationale, // 5df1b1c1 ReactNativeVersion, // abd76827 - RefreshControl, // c98bcc4d - RefreshControlInstance, // cc20e6bc - RefreshControlProps, // e4998b72 + RefreshControl, // c4dc78df + RefreshControlInstance, // 14c393da + RefreshControlProps, // 76a43e28 RefreshControlPropsAndroid, // 8ac931ca RefreshControlPropsIOS, // 72a36381 Registry, // 6c39216d @@ -5952,24 +5959,24 @@ export { RootViewStyleProvider, // eaff83cc Runnable, // 594dd93a Runnables, // 4367c557 - SafeAreaView, // f54b63d3 + SafeAreaView, // eb3edf8f SafeAreaViewInstance, // 21dba39c ScaledSize, // 07e417c7 ScrollEvent, // d7abdd0a - ScrollResponderType, // fdbfa43c + ScrollResponderType, // 28dbceda ScrollToLocationParamsType, // d7ecdad1 - ScrollView, // 8a8c17b6 - ScrollViewImperativeMethods, // ef0ef67e - ScrollViewInstance, // d576e5d5 - ScrollViewProps, // 0a695363 + ScrollView, // 2a7bae63 + ScrollViewImperativeMethods, // 6fa109b3 + ScrollViewInstance, // b3717858 + ScrollViewProps, // 54251f82 ScrollViewPropsAndroid, // 02f3df2e ScrollViewPropsIOS, // 807cb4f6 ScrollViewScrollToOptions, // 3313411e SectionBase, // 9f13db00 - SectionList, // d4eb0477 + SectionList, // a72a2a80 SectionListData, // 1a4de01a - SectionListInstance, // 2679fa93 - SectionListProps, // 9fbd4914 + SectionListInstance, // 25def257 + SectionListProps, // a64551d6 SectionListRenderItem, // 715b2086 SectionListRenderItemInfo, // 4a48a922 Separators, // 6a45f7e3 @@ -5988,17 +5995,17 @@ export { StyleProp, // fa0e9b4a StyleSheet, // 9ed7a5d4 SubmitBehavior, // c4ddf490 - Switch, // a3f62002 + Switch, // 7e2b771a SwitchChangeEvent, // 899635b1 SwitchInstance, // 3c50eec5 - SwitchProps, // b7ba0235 + SwitchProps, // 1de46724 Systrace, // 626d178c TVViewPropsIOS, // 330ce7b5 TargetedEvent, // 16e98910 TaskProvider, // 266dedf2 - Text, // 603f50be + Text, // ac56bf90 TextContentType, // 239b3ecc - TextInput, // 0783b85a + TextInput, // 38d9b4cf TextInputAndroidProps, // 9ebbc103 TextInputBlurEvent, // b77af40e TextInputChangeEvent, // f55eef98 @@ -6008,44 +6015,44 @@ export { TextInputIOSProps, // fb3c9327 TextInputInstance, // 5a0c0e0d TextInputKeyPressEvent, // 546c5d07 - TextInputProps, // 073d3a32 + TextInputProps, // 87d0121d TextInputSelectionChangeEvent, // e58f2abc TextInputSubmitEditingEvent, // 6bcb2aa5 TextInstance, // 05463a96 TextLayoutEvent, // 3f54186f - TextProps, // 96b843ff + TextProps, // 9407ed78 TextStyle, // 898adfd1 ToastAndroid, // 88a8969a - TouchableHighlight, // 46b69b76 + TouchableHighlight, // 2be0ef10 TouchableHighlightInstance, // b510c0eb - TouchableHighlightProps, // f0306678 - TouchableNativeFeedback, // 4fac050d - TouchableNativeFeedbackInstance, // a5a97aba - TouchableNativeFeedbackProps, // e68e0720 - TouchableOpacity, // 488a7c7f + TouchableHighlightProps, // ff78d31e + TouchableNativeFeedback, // 4797811e + TouchableNativeFeedbackInstance, // 0e808653 + TouchableNativeFeedbackProps, // 0976e241 + TouchableOpacity, // 2c3a069c TouchableOpacityInstance, // b186055b - TouchableOpacityProps, // f0e05d03 - TouchableWithoutFeedback, // 657d20f4 - TouchableWithoutFeedbackProps, // 4ac02994 + TouchableOpacityProps, // cb396fbf + TouchableWithoutFeedback, // 630a4cef + TouchableWithoutFeedbackProps, // e8d95570 TransformsStyle, // 65e70f18 TurboModule, // dfe29706 TurboModuleRegistry, // 4ace6db2 UIManager, // afbcdf05 UTFSequence, // ad625158 Vibration, // 31e4bbf8 - View, // 6a318aac + View, // 97793c47 ViewInstance, // ffde5573 - ViewProps, // 855ca063 + ViewProps, // 329828d7 ViewPropsAndroid, // 55e81851 ViewPropsIOS, // 58ee19bf ViewStyle, // 4e2746d6 VirtualViewMode, // 6be59722 VirtualizedList, // 68c7345e VirtualizedListInstance, // 423ee7c0 - VirtualizedListProps, // 60ce2b77 + VirtualizedListProps, // 136fd699 VirtualizedSectionList, // 9fd9cd61 VirtualizedSectionListInstance, // 12b706d5 - VirtualizedSectionListProps, // bbbf2933 + VirtualizedSectionListProps, // b197a54a WrapperComponentProvider, // 9ef54e61 codegenNativeCommands, // 628a7c0a codegenNativeComponent, // 520daa94 diff --git a/scripts/js-api/build-types/transforms/typescript/__tests__/convertTypeAliasesToInterfaces-test.js b/scripts/js-api/build-types/transforms/typescript/__tests__/convertTypeAliasesToInterfaces-test.js index a15111440a1c..fe63bb35aa10 100644 --- a/scripts/js-api/build-types/transforms/typescript/__tests__/convertTypeAliasesToInterfaces-test.js +++ b/scripts/js-api/build-types/transforms/typescript/__tests__/convertTypeAliasesToInterfaces-test.js @@ -46,10 +46,10 @@ declare type ViewProps = Readonly`, declare type Props = Readonly`, ); expect(result).toMatchInlineSnapshot(` -"declare interface Props extends Readonly {}" +"declare interface Props extends Readonly { + readonly x?: string; + readonly y: number; +}" `); }); @@ -59,10 +59,10 @@ declare type Props = Readonly`, declare type Props = Readonly<{ a: string; b?: number }>`, ); expect(result).toMatchInlineSnapshot(` -"declare interface Props extends Readonly<{ - a: string; - b?: number; -}> {}" +"declare interface Props { + readonly a: string; + readonly b?: number; +}" `); }); @@ -72,10 +72,10 @@ declare type Props = Readonly<{ a: string; b?: number }>`, declare type Props = { readonly a: string; readonly b?: number }`, ); expect(result).toMatchInlineSnapshot(` -"declare interface Props extends Omit<{ +"declare interface Props { readonly a: string; readonly b?: number; -}, never> {}" +}" `); }); @@ -105,9 +105,9 @@ declare type FlatListProps = Omit & BaseProps`, declare type Props = Readonly & { alt?: string }>`, ); expect(result).toMatchInlineSnapshot(` -"declare interface Props extends Readonly & { - alt?: string; -}> {}" +"declare interface Props extends Readonly> { + readonly alt?: string; +}" `); }); diff --git a/scripts/js-api/build-types/transforms/typescript/convertTypeAliasesToInterfaces.js b/scripts/js-api/build-types/transforms/typescript/convertTypeAliasesToInterfaces.js index 59d5c4cbe3ab..c33238180983 100644 --- a/scripts/js-api/build-types/transforms/typescript/convertTypeAliasesToInterfaces.js +++ b/scripts/js-api/build-types/transforms/typescript/convertTypeAliasesToInterfaces.js @@ -44,50 +44,59 @@ function convertToInterface(path: $FlowFixMe): void { innerType = typeAnnotation.typeParameters.params[0]; } - let members: Array; + const extendsClauses: Array = []; + const bodyMembers: Array = []; if (t.isTSIntersectionType(innerType)) { - members = innerType.types.map(member => t.cloneDeep(member)); - } else if (t.isTSTypeLiteral(innerType) || t.isTSTypeReference(innerType)) { - members = [t.cloneDeep(innerType)]; + const refMembers: Array = []; + for (const member of innerType.types) { + if (t.isTSTypeLiteral(member)) { + const clonedMembers = t.cloneDeep(member).members; + if (isReadonly) { + makePropertiesReadonly(clonedMembers); + } + bodyMembers.push(...clonedMembers); + } else { + refMembers.push(t.cloneDeep(member)); + } + } + if (refMembers.length > 0) { + const refsType = + refMembers.length === 1 + ? refMembers[0] + : t.tsIntersectionType(refMembers); + if (isReadonly) { + extendsClauses.push( + t.tsExpressionWithTypeArguments( + t.identifier('Readonly'), + t.tsTypeParameterInstantiation([refsType]), + ), + ); + } else { + extendsClauses.push(typeToExtendsClause(refsType, false)); + } + } + } else if (t.isTSTypeLiteral(innerType)) { + const clonedMembers = t.cloneDeep(innerType).members; + if (isReadonly) { + makePropertiesReadonly(clonedMembers); + } + bodyMembers.push(...clonedMembers); + } else if (t.isTSTypeReference(innerType)) { + extendsClauses.push(typeToExtendsClause(innerType, isReadonly)); } else { throw new Error( `Unsupported type structure for @build-types emit-as-interface on '${path.node.id.name}'. Only object literals, type references, and intersections of these are supported.`, ); } - const combined = - members.length === 1 ? members[0] : t.tsIntersectionType(members); - const hasObjectLiteral = members.some(member => t.isTSTypeLiteral(member)); - - // Members declared in the body of an interface cannot be overridden by a - // module augmentation: a second declaration is a merge conflict, and the - // original wins. Keeping every member in the extends clause makes them all - // inherited, and so all overridable. - const extendsClauses = [ - isReadonly - ? t.tsExpressionWithTypeArguments( - t.identifier('Readonly'), - t.tsTypeParameterInstantiation([combined]), - ) - : hasObjectLiteral - ? // An object literal cannot appear in an extends clause on its own, - // and wrapping it in Readonly would add modifiers the source does - // not have. Omit<_, never> preserves them. - t.tsExpressionWithTypeArguments( - t.identifier('Omit'), - t.tsTypeParameterInstantiation([combined, t.tsNeverKeyword()]), - ) - : typeToExtendsClause(combined, false), - ]; - const interfaceNode = t.tsInterfaceDeclaration( t.cloneDeep(path.node.id), path.node.typeParameters ? t.cloneDeep(path.node.typeParameters) : undefined, - extendsClauses, - t.tsInterfaceBody([]), + extendsClauses.length > 0 ? extendsClauses : undefined, + t.tsInterfaceBody(bodyMembers), ); interfaceNode.declare = path.node.declare ?? false; @@ -118,6 +127,14 @@ function typeToExtendsClause( ); } +function makePropertiesReadonly(members: Array): void { + for (const member of members) { + if (t.isTSPropertySignature(member)) { + member.readonly = true; + } + } +} + const visitor: PluginObj = { visitor: { TSTypeAliasDeclaration(path) {