Convert additional Props/Style types to interface (#58062)

Summary:
In response to this comment: https://github.com/react/react-native/pull/57490#issuecomment-5338526433

The DefinitelyTyped `react-native-web` types augment the `react-native` module to layer web-only props and style values onto React Native's types. Module augmentation only works against `interface` declarations, so these hit `error TS2300: Duplicate identifier`.

This was solved in https://github.com/facebook/react-native/pull/56809 — this diff extends `interface` emission to additional types as below.

**Changes**

Annotate the remaining types that `types/react-native-web` augments with `build-types emit-as-interface`:

- `AccessibilityProps`
- `ImageProps`
- `PressableStateCallbackType`
- `ViewStyle`, `TextStyle`, `ImageStyle`

**Source for matched `types/react-native-web` conflicts**

| Type | Declared in | Augmented by `types/react-native-web` |
| --- | --- | --- |
| `AccessibilityProps` | `Libraries/Components/View/ViewAccessibility.js:342` | [index.d.ts#L1272](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1272) |
| `ImageProps` | `Libraries/Image/ImageProps.js:336` | [index.d.ts#L1422](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1422) |
| `PressableStateCallbackType` | `Libraries/Components/Pressable/Pressable.js:36` | [index.d.ts#L1444](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1444) |
| `ViewStyle` | `Libraries/StyleSheet/StyleSheet.js.flow:141` | [index.d.ts#L1458](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1458) |
| `TextStyle` | `Libraries/StyleSheet/StyleSheet.js.flow:159` | [index.d.ts#L1486](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1486) |
| `ImageStyle` | `Libraries/StyleSheet/StyleSheet.js.flow:177` | [index.d.ts#L1514](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/df17ec34853e80dac955a0c2649cec989d90b2b5/types/react-native-web/index.d.ts#L1514) |

**Not fixed**

The remaining DT failures (parsed from https://github.com/DefinitelyTyped/DefinitelyTyped/actions/runs/32138113480) aren't interface issues:

- `InteractionManager` has no export in the Strict API at all.
- `VirtualizedListProps` is genuinely non-generic in the Flow source (`packages/virtualized-lists/Lists/VirtualizedListProps.js:287`), and `getItem` / `getItemCount` are required there. DT's `VirtualizedListProps<ItemT>` with those omitted is an assumption carried over from the old hand-written types.
- The `ViewStyle` / `TextStyle` / `ImageStyle` "incorrectly extends `WebStyle`" errors **will persist**. RN's `DimensionValue` includes `null`, and DT redefines `bottom?: CSSProperties["bottom"] | DimensionValue` on an interface extending `WebStyle`, whose `bottom` does not accept `null`. DT needs `Exclude<DimensionValue, null>` there. Expect 3 of the 16 reported errors to remain once the duplicate-identifier ones clear.

cc rjbailey

Changelog:
[General][Fixed] - **JS API**: Additional Props/Style types are now defined as `interface`, fixing compatibility with certain DefinitelyTyped packages

Pull Request resolved: https://github.com/react/react-native/pull/58062

Test Plan:
- `node ./scripts/js-api/build-types` — snapshot regenerated; `--validate` passes
- `yarn test-generated-typescript`, `yarn test-typescript` — pass
- `yarn jest scripts/js-api` — 141 tests pass
- Scratch project replaying react-native-web's augmentations against `types_generated`: all six now merge cleanly. As a control, augmenting `ImagePropsAndroid` (still a type alias) in the same harness reproduces `error TS2300: Duplicate identifier`, confirming the harness detects the failure mode.

Reviewed By: cipolleschi

Differential Revision: D117534044

Pulled By: cortinico

fbshipit-source-id: 8fc37375f7a3d9ea86e1a206059d365b38658231
This commit is contained in:
Alex Hunt authored and meta-codesync[bot] committed 2026-08-27 04:21:53 -07:00
1 parent 4eee1cd4f1
commit 593ae0258d
6 files changed
+103 -97

No files matched your search

@@ -32,6 +32,7 @@ export type PressableInstance = HostInstance;
export type {PressableAndroidRippleConfig};
/** @build-types emit-as-interface react-native-web compatibility */
export type PressableStateCallbackType = Readonly<{
pressed: boolean,
}>;
@@ -349,6 +349,7 @@ export type AccessibilityPropsIOS = Readonly<{
accessibilityRespondsToUserInteraction?: ?boolean,
}>;
/** @build-types emit-as-interface react-native-web compatibility */
export type AccessibilityProps = Readonly<{
...AccessibilityPropsAndroid,
...AccessibilityPropsIOS,
+1
View File
@@ -327,6 +327,7 @@ export type ImagePropsBase = Readonly<{
children?: empty,
}>;
/** @build-types emit-as-interface react-native-web compatibility */
export type ImageProps = Readonly<{
...ImagePropsIOS,
...ImagePropsAndroid,
@@ -136,6 +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;
/**
@@ -153,6 +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;
/**
@@ -170,6 +172,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;
/**
@@ -137,6 +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;
/**
@@ -154,6 +155,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;
/**
@@ -171,6 +173,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;
/**
+94 -97
View File
@@ -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<<ac7ab1ffce99d02fd6c918a6ed1fb85c>>
* @generated SignedSource<<0cdd169a97730ccd6c6fdb359f0eb30d>>
*
* This file was generated by scripts/js-api/build-types/index.js.
*/
@@ -981,30 +981,29 @@ declare type AccessibilityEventDefinitionsIOS = {
declare type AccessibilityEventTypes =
"click" | "focus" | "viewHoverEnter" | "windowStateChange"
declare type AccessibilityInfo = typeof AccessibilityInfo
declare type AccessibilityProps = Readonly<
AccessibilityPropsAndroid &
AccessibilityPropsIOS & {
accessibilityActions?: ReadonlyArray<AccessibilityActionInfo>
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 interface AccessibilityProps extends Readonly<
AccessibilityPropsAndroid & AccessibilityPropsIOS
> {
readonly accessibilityActions?: ReadonlyArray<AccessibilityActionInfo>
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 AccessibilityPropsAndroid = {
readonly accessibilityLabelledBy?:
(Array<string> | undefined) | (string | undefined)
@@ -2494,13 +2493,11 @@ declare type ImageProgressEventDataIOS = {
declare type ImageProgressEventIOS = NativeSyntheticEvent<
Readonly<ImageProgressEventDataIOS>
>
declare type ImageProps = Readonly<
ImagePropsIOS &
ImagePropsAndroid &
Omit<ImagePropsBase, "style"> & {
style?: ImageStyleProp
}
>
declare interface ImageProps extends Readonly<
ImagePropsIOS & ImagePropsAndroid & Omit<ImagePropsBase, "style">
> {
readonly style?: ImageStyleProp
}
declare type ImagePropsAndroid = {
readonly fadeDuration?: number
readonly loadingIndicatorSource?: number | Readonly<ImageURISource>
@@ -2569,7 +2566,7 @@ declare type ImageSize = {
declare type ImageSource =
ImageRequireSource | ImageURISource | ReadonlyArray<ImageURISource>
declare type ImageSourcePropType = ImageSource
declare type ImageStyle = ____ImageStyle_Internal
declare interface ImageStyle extends ____ImageStyle_Internal {}
declare type ImageStyleProp = ____ImageStyleProp_Internal
declare type ImageType = ImageAndroid | ImageIOS
declare interface ImageURISource {
@@ -3672,7 +3669,7 @@ declare type PressableInstance = HostInstance
declare interface PressableProps extends Readonly<
Omit<ViewProps, "onMouseEnter" | "onMouseLeave"> & PressableBaseProps
> {}
declare type PressableStateCallbackType = {
declare interface PressableStateCallbackType {
readonly pressed: boolean
}
declare type PressRetentionOffset = {
@@ -5198,7 +5195,7 @@ declare type TextPropsIOS = {
lineBreakStrategyIOS?: "hangul-word" | "none" | "push-out" | "standard"
suppressHighlighting?: boolean
}
declare type TextStyle = ____TextStyle_Internal
declare interface TextStyle extends ____TextStyle_Internal {}
declare type TextStyleProp = ____TextStyleProp_Internal
declare type Timespan = {
endExtras?: Extras
@@ -5574,7 +5571,7 @@ declare type ViewPropsAndroid = {
declare type ViewPropsIOS = {
readonly shouldRasterizeIOS?: boolean
}
declare type ViewStyle = ____ViewStyle_Internal
declare interface ViewStyle extends ____ViewStyle_Internal {}
declare type ViewStyleProp = ____ViewStyleProp_Internal
declare type VirtualizedList = typeof VirtualizedList
declare class VirtualizedList_default extends StateSafePureComponent_default<
@@ -5746,22 +5743,22 @@ export {
AccessibilityActionEvent, // a0d4daa0
AccessibilityActionInfo, // db47a917
AccessibilityInfo, // 23a3aa9b
AccessibilityProps, // eda80653
AccessibilityProps, // b703f8d9
AccessibilityRole, // f2f2e066
AccessibilityState, // b0c2b3f7
AccessibilityValue, // cf8bcb74
ActionSheetIOS, // b558559e
ActionSheetIOSOptions, // 1756eb5a
ActivityIndicator, // 085c0bdd
ActivityIndicator, // 7bb76795
ActivityIndicatorInstance, // a82dd4e7
ActivityIndicatorProps, // 7597a087
ActivityIndicatorProps, // e3c81e37
Alert, // a398a509
AlertButton, // bf1a3b60
AlertButtonStyle, // ec9fb242
AlertOptions, // 8a116d2a
AlertType, // 5ab91217
AndroidKeyboardEvent, // e03becc8
Animated, // 8ed2ff0a
Animated, // e99db73c
AppConfig, // 35c0ca70
AppRegistry, // 5bc2bced
AppState, // 12012be5
@@ -5775,8 +5772,8 @@ export {
BackPressEventName, // 4620fb76
BlurEvent, // 4ba4f941
BoxShadowValue, // b679703f
Button, // af384e38
ButtonInstance, // 3f6e29ea
Button, // 78a75446
ButtonInstance, // aecdca9d
ButtonProps, // 21c5780c
Clipboard, // 41addb89
CodegenTypes, // ab4986cc
@@ -5795,9 +5792,9 @@ export {
DimensionsPayload, // 653bc26c
DisplayMetrics, // 1dc35cef
DisplayMetricsAndroid, // 872e62eb
DrawerLayoutAndroid, // 787ba7e2
DrawerLayoutAndroid, // a1445452
DrawerLayoutAndroidInstance, // c0694352
DrawerLayoutAndroidProps, // 658000f3
DrawerLayoutAndroidProps, // 8144971b
DrawerSlideEvent, // c4ab8fba
DropShadowValue, // e9df2606
DynamicColorIOS, // d96c228c
@@ -5813,9 +5810,9 @@ export {
EventSubscription, // b8d084aa
ExtendedExceptionData, // 5a6ccf5a
FilterFunction, // bf24c0e3
FlatList, // 901c50da
FlatListInstance, // c2dd86eb
FlatListProps, // 3bd11d32
FlatList, // ff6fd4b9
FlatListInstance, // 930e6e0d
FlatListProps, // b77a3695
FocusEvent, // 850f1517
FontVariant, // 7c7558bb
GestureResponderEvent, // 14d3e77a
@@ -5826,17 +5823,17 @@ export {
IEventEmitter, // fbef6131
IOSKeyboardEvent, // e67bfe3a
IgnorePattern, // ec6f6ece
Image, // 23ec0708
ImageBackground, // 4922fef8
ImageBackgroundInstance, // a693a792
ImageBackgroundProps, // 9a257b18
Image, // 70beaf51
ImageBackground, // 125f114f
ImageBackgroundInstance, // b32a44b1
ImageBackgroundProps, // 58c484ed
ImageErrorEvent, // 978933f4
ImageInstance, // 9a100753
ImageLoadEvent, // 77f0b718
ImageProgressEventIOS, // 445331a4
ImageProps, // 9acb1a99
ImageProps, // 0b057370
ImagePropsAndroid, // ee00e1d5
ImagePropsBase, // ceee1a0e
ImagePropsBase, // 360c2972
ImagePropsIOS, // 9e19c85d
ImageRequireSource, // 681d683b
ImageResizeMode, // d51106e2
@@ -5844,7 +5841,7 @@ export {
ImageSize, // 1c47cf88
ImageSource, // ea31cf4a
ImageSourcePropType, // f522e093
ImageStyle, // c972b651
ImageStyle, // 23278d38
ImageURISource, // 443d047c
InputAccessoryView, // 69da97d8
InputAccessoryViewProps, // 6c4ba417
@@ -5854,9 +5851,9 @@ export {
KeyEvent, // 20fa4267
KeyUpEvent, // 57f832c5
Keyboard, // 49414c97
KeyboardAvoidingView, // 206bbaad
KeyboardAvoidingViewInstance, // 9fc99a9a
KeyboardAvoidingViewProps, // 1661b30c
KeyboardAvoidingView, // 86ce3237
KeyboardAvoidingViewInstance, // 39e5e0cb
KeyboardAvoidingViewProps, // 5ea2df10
KeyboardEvent, // c3f895d4
KeyboardEventEasing, // af4091c8
KeyboardEventName, // 59299ad6
@@ -5881,10 +5878,10 @@ export {
MeasureInWindowOnSuccessCallback, // a285f598
MeasureLayoutOnSuccessCallback, // 3592502a
MeasureOnSuccessCallback, // 82824e59
Modal, // 8e222ce5
Modal, // ddb43746
ModalBaseProps, // c294cc46
ModalInstance, // d466ce77
ModalProps, // dc3dfe04
ModalProps, // a073d560
ModalPropsAndroid, // 515fb173
ModalPropsIOS, // 664ecb7e
ModeChangeEvent, // f64bf69d
@@ -5920,15 +5917,15 @@ export {
PointerEvent, // ff599afe
PressabilityConfig, // fea539a5
PressabilityEventHandlers, // c222648b
Pressable, // 148fa542
Pressable, // 73cbe498
PressableAndroidRippleConfig, // ee32eaca
PressableInstance, // eebfe911
PressableProps, // 0610ea0a
PressableStateCallbackType, // 9af36561
PressableProps, // 573ac60a
PressableStateCallbackType, // 5e0cfa78
ProcessedColorValue, // 33f74304
ProgressBarAndroid, // 48034c58
ProgressBarAndroid, // db8f6a6b
ProgressBarAndroidInstance, // ab545ef1
ProgressBarAndroidProps, // 9c1b93a7
ProgressBarAndroidProps, // 6484d368
PublicRootInstance, // 8040afd7
PublicTextInstance, // 6937c7bf
PushNotificationEventName, // 84e7e150
@@ -5936,9 +5933,9 @@ export {
PushNotificationPermissions, // c2e7ae4f
Rationale, // 5df1b1c1
ReactNativeVersion, // abd76827
RefreshControl, // 76837d3f
RefreshControlInstance, // 4c4b2643
RefreshControlProps, // d41ad947
RefreshControl, // 1fc5c032
RefreshControlInstance, // 7cef228c
RefreshControlProps, // c03c6dd3
RefreshControlPropsAndroid, // 8ac931ca
RefreshControlPropsIOS, // 72a36381
Registry, // 6c39216d
@@ -5950,24 +5947,24 @@ export {
RootViewStyleProvider, // a4547094
Runnable, // 594dd93a
Runnables, // 4367c557
SafeAreaView, // 718d200c
SafeAreaView, // 2a5620cd
SafeAreaViewInstance, // 21dba39c
ScaledSize, // 07e417c7
ScrollEvent, // d7abdd0a
ScrollResponderType, // 603c33d5
ScrollResponderType, // 4fb54e25
ScrollToLocationParamsType, // d7ecdad1
ScrollView, // a644be1d
ScrollViewImperativeMethods, // 480a85e1
ScrollViewInstance, // 1030cf7f
ScrollViewProps, // 901ba6eb
ScrollView, // 5b9149bf
ScrollViewImperativeMethods, // 308dd401
ScrollViewInstance, // b86e49e8
ScrollViewProps, // 40e3563d
ScrollViewPropsAndroid, // 02f3df2e
ScrollViewPropsIOS, // 807cb4f6
ScrollViewScrollToOptions, // 3313411e
SectionBase, // 9f13db00
SectionList, // d3af1e2c
SectionList, // 5ad78704
SectionListData, // 1a4de01a
SectionListInstance, // 07b91520
SectionListProps, // ea05da1f
SectionListInstance, // ce15f61c
SectionListProps, // 3b9f4d91
SectionListRenderItem, // 715b2086
SectionListRenderItemInfo, // 4a48a922
Separators, // 6a45f7e3
@@ -5986,17 +5983,17 @@ export {
StyleProp, // fa0e9b4a
StyleSheet, // f7fe407a
SubmitBehavior, // c4ddf490
Switch, // b3e75e79
Switch, // cf0d6ce5
SwitchChangeEvent, // 899635b1
SwitchInstance, // 3c50eec5
SwitchProps, // 31d4e162
SwitchProps, // 9efb522c
Systrace, // 626d178c
TVViewPropsIOS, // 330ce7b5
TargetedEvent, // 16e98910
TaskProvider, // 266dedf2
Text, // 6f2a9453
Text, // 3ccd8020
TextContentType, // 239b3ecc
TextInput, // e7689ddb
TextInput, // 89af456b
TextInputAndroidProps, // 9ebbc103
TextInputBlurEvent, // b77af40e
TextInputChangeEvent, // f55eef98
@@ -6006,44 +6003,44 @@ export {
TextInputIOSProps, // fb3c9327
TextInputInstance, // 5a0c0e0d
TextInputKeyPressEvent, // 546c5d07
TextInputProps, // 665a095f
TextInputProps, // a93c2e69
TextInputSelectionChangeEvent, // e58f2abc
TextInputSubmitEditingEvent, // 6bcb2aa5
TextInstance, // 05463a96
TextLayoutEvent, // 3f54186f
TextProps, // 278dd30a
TextStyle, // bea26d6b
TextProps, // 2e3336ca
TextStyle, // d7678842
ToastAndroid, // 88a8969a
TouchableHighlight, // 4b9ae440
TouchableHighlight, // edab1b07
TouchableHighlightInstance, // b510c0eb
TouchableHighlightProps, // 8e8c6680
TouchableNativeFeedback, // 49b246df
TouchableNativeFeedbackInstance, // 95dc4a1d
TouchableNativeFeedbackProps, // b32639f0
TouchableOpacity, // 36c0926f
TouchableHighlightProps, // 08cd59e1
TouchableNativeFeedback, // e2791ad5
TouchableNativeFeedbackInstance, // ce1ad7e9
TouchableNativeFeedbackProps, // ffc9c1d4
TouchableOpacity, // fac1cc91
TouchableOpacityInstance, // b186055b
TouchableOpacityProps, // d7db3879
TouchableWithoutFeedback, // 4bf9d65a
TouchableWithoutFeedbackProps, // 931958b6
TouchableOpacityProps, // 9e3eeec9
TouchableWithoutFeedback, // da544b16
TouchableWithoutFeedbackProps, // a14626e7
TransformsStyle, // 65e70f18
TurboModule, // dfe29706
TurboModuleRegistry, // 4ace6db2
UIManager, // afbcdf05
UTFSequence, // ad625158
Vibration, // 31e4bbf8
View, // c31ebc5e
View, // 14779d0c
ViewInstance, // ffde5573
ViewProps, // e2c15ef7
ViewProps, // 46cb2061
ViewPropsAndroid, // 55e81851
ViewPropsIOS, // 58ee19bf
ViewStyle, // 1848a17c
ViewStyle, // e75eec1e
VirtualViewMode, // 6be59722
VirtualizedList, // 68c7345e
VirtualizedListInstance, // 423ee7c0
VirtualizedListProps, // 3194847b
VirtualizedListProps, // 5dded4a1
VirtualizedSectionList, // 9fd9cd61
VirtualizedSectionListInstance, // 12b706d5
VirtualizedSectionListProps, // f42f54c4
VirtualizedSectionListProps, // ef311473
WrapperComponentProvider, // 9ef54e61
codegenNativeCommands, // 628a7c0a
codegenNativeComponent, // 520daa94