Skip to content

Commit 25739b4

Browse files
zoontekclaude
andcommitted
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 <Name>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) <noreply@anthropic.com>
1 parent e35a309 commit 25739b4

19 files changed

Lines changed: 487 additions & 424 deletions

File tree

packages/react-native/Libraries/Animated/components/AnimatedScrollView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @format
99
*/
1010

11-
import type {____ViewStyle_Internal} from '../../StyleSheet/StyleSheetTypes';
11+
import type {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
1212
import type {
1313
AnimatedComponentType,
1414
AnimatedProps,
@@ -100,7 +100,7 @@ const AnimatedScrollViewWithInvertedRefreshControl =
100100

101101
// Handle animated props on `refreshControl`.
102102
const [refreshControlAnimatedProps, refreshControlRef] = useAnimatedProps<
103-
{style: ?____ViewStyle_Internal},
103+
{style: ?ViewStyle},
104104
$FlowFixMe,
105105
>(intermediatePropsForRefreshControl);
106106
// NOTE: Assumes that refreshControl.ref` and `refreshControl.style` can be

packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ type ActivityIndicatorIOSProps = Readonly<{
3838
hidesWhenStopped?: ?boolean,
3939
}>;
4040

41-
/** @build-types emit-as-interface Uniwind compatibility */
42-
export type ActivityIndicatorProps = Readonly<{
43-
...ViewProps,
44-
...ActivityIndicatorIOSProps,
45-
41+
type ActivityIndicatorPropsCore = Readonly<{
4642
/**
4743
* Whether to show the indicator (`true`) or hide it (`false`).
4844
*/
@@ -67,6 +63,13 @@ export type ActivityIndicatorProps = Readonly<{
6763
size?: ?IndicatorSize,
6864
}>;
6965

66+
/** @build-types emit-as-interface Uniwind compatibility */
67+
export type ActivityIndicatorProps = Readonly<{
68+
...ViewProps,
69+
...ActivityIndicatorIOSProps,
70+
...ActivityIndicatorPropsCore,
71+
}>;
72+
7073
/**
7174
* Displays a circular loading indicator.
7275
*

packages/react-native/Libraries/Components/Button.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ import View from './View/View';
2727
import invariant from 'invariant';
2828
import * as React from 'react';
2929

30-
/** @build-types emit-as-interface Uniwind compatibility */
31-
export type ButtonProps = Readonly<{
30+
type ButtonPropsCore = Readonly<{
3231
/**
3332
* Text to display inside the button. On Android the given title will be
3433
* converted to the uppercased form.
@@ -167,6 +166,9 @@ export type ButtonProps = Readonly<{
167166
accessibilityLanguage?: ?Stringish,
168167
}>;
169168

169+
/** @build-types emit-as-interface Uniwind compatibility */
170+
export type ButtonProps = ButtonPropsCore;
171+
170172
const NativeTouchable:
171173
typeof TouchableNativeFeedback | typeof TouchableOpacity =
172174
Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;

packages/react-native/Libraries/Components/Keyboard/KeyboardAvoidingView.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ import Keyboard from './Keyboard';
2626
import * as React from 'react';
2727
import {createRef} from 'react';
2828

29-
/** @build-types emit-as-interface Uniwind compatibility */
30-
export type KeyboardAvoidingViewProps = Readonly<{
31-
...ViewProps,
32-
29+
type KeyboardAvoidingViewPropsCore = Readonly<{
3330
/**
3431
* Specify how to react to the presence of the keyboard.
3532
*/
@@ -56,6 +53,12 @@ export type KeyboardAvoidingViewProps = Readonly<{
5653
keyboardVerticalOffset?: number,
5754
}>;
5855

56+
/** @build-types emit-as-interface Uniwind compatibility */
57+
export type KeyboardAvoidingViewProps = Readonly<{
58+
...ViewProps,
59+
...KeyboardAvoidingViewPropsCore,
60+
}>;
61+
5962
type KeyboardAvoidingViewState = {
6063
bottom: number,
6164
};

packages/react-native/Libraries/Components/Pressable/Pressable.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ export type PressableInstance = HostInstance;
3232

3333
export type {PressableAndroidRippleConfig};
3434

35-
/** @build-types emit-as-interface react-native-web compatibility */
36-
export type PressableStateCallbackType = Readonly<{
35+
type PressableStateCallbackTypeCore = Readonly<{
3736
pressed: boolean,
3837
}>;
3938

39+
/** @build-types emit-as-interface react-native-web compatibility */
40+
export type PressableStateCallbackType = PressableStateCallbackTypeCore;
41+
4042
type PressableBaseProps = Readonly<{
4143
/**
4244
* Whether a press gesture can be interrupted by a parent gesture such as a

packages/react-native/Libraries/Components/TextInput/InputAccessoryView.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,7 @@ import useWindowDimensions from '../../Utilities/useWindowDimensions';
1818
import RCTInputAccessoryViewNativeComponent from './RCTInputAccessoryViewNativeComponent';
1919
import * as React from 'react';
2020

21-
/**
22-
* InputAccessoryView is deprecated and will be removed in a future release.
23-
* @deprecated
24-
* @build-types emit-as-interface Expo compatibility
25-
*/
26-
export type InputAccessoryViewProps = Readonly<{
21+
type InputAccessoryViewPropsCore = Readonly<{
2722
readonly children: React.Node,
2823
/**
2924
* An ID used to associate this `InputAccessoryView` to specified `TextInput`(s).
@@ -33,6 +28,13 @@ export type InputAccessoryViewProps = Readonly<{
3328
backgroundColor?: ?ColorValue,
3429
}>;
3530

31+
/**
32+
* InputAccessoryView is deprecated and will be removed in a future release.
33+
* @deprecated
34+
* @build-types emit-as-interface Expo compatibility
35+
*/
36+
export type InputAccessoryViewProps = InputAccessoryViewPropsCore;
37+
3638
/**
3739
* 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.
3840
*

packages/react-native/Libraries/Components/TextInput/TextInput.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010

1111
import type {HostInstance} from '../../../src/private/types/HostInstance';
12-
import type {____TextStyle_Internal as TextStyleInternal} from '../../StyleSheet/StyleSheetTypes';
12+
import type {TextStyle} from '../../StyleSheet/StyleSheetTypes';
1313
import type {
1414
BlurEvent,
1515
FocusEvent,
@@ -543,16 +543,16 @@ function InternalTextInput(props: TextInputProps): React.Node {
543543
let _style = props.style;
544544
const flattenedStyle = flattenStyle<TextStyleProp>(props.style);
545545
if (flattenedStyle != null) {
546-
let overrides: ?{...TextStyleInternal} = null;
546+
let overrides: ?{...TextStyle} = null;
547547
if (typeof flattenedStyle?.fontWeight === 'number') {
548-
overrides = overrides || ({} as {...TextStyleInternal});
548+
overrides = overrides || ({} as {...TextStyle});
549549
overrides.fontWeight =
550550
// $FlowFixMe[incompatible-type]
551-
flattenedStyle.fontWeight.toString() as TextStyleInternal['fontWeight'];
551+
flattenedStyle.fontWeight.toString() as TextStyle['fontWeight'];
552552
}
553553

554554
if (flattenedStyle.verticalAlign != null) {
555-
overrides = overrides || ({} as {...TextStyleInternal});
555+
overrides = overrides || ({} as {...TextStyle});
556556
overrides.textAlignVertical =
557557
verticalAlignToTextAlignVerticalMap[flattenedStyle.verticalAlign];
558558
overrides.verticalAlign = undefined;

packages/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js

Lines changed: 85 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -36,92 +36,93 @@ export type TouchableWithoutFeedbackPropsAndroid = {
3636
touchSoundDisabled?: ?boolean,
3737
};
3838

39+
type TouchableWithoutFeedbackPropsCore = {
40+
children?: ?React.Node,
41+
/**
42+
* Delay in ms, from onPressIn, before onLongPress is called.
43+
*/
44+
delayLongPress?: ?number,
45+
/**
46+
* Delay in ms, from the start of the touch, before onPressIn is called.
47+
*/
48+
delayPressIn?: ?number,
49+
/**
50+
* Delay in ms, from the release of the touch, before onPressOut is called.
51+
*/
52+
delayPressOut?: ?number,
53+
/**
54+
* If true, disable all interactions for this component.
55+
*/
56+
disabled?: ?boolean,
57+
/**
58+
* Whether this View should be focusable with a non-touch input device,
59+
* eg. receive focus with a hardware keyboard / TV remote.
60+
*/
61+
focusable?: ?boolean,
62+
/**
63+
* This defines how far your touch can start away from the button.
64+
* This is added to pressRetentionOffset when moving off of the button.
65+
* NOTE The touch area never extends past the parent view bounds and
66+
* the Z-index of sibling views always takes precedence if a touch hits
67+
* two overlapping views.
68+
*/
69+
hitSlop?: ?EdgeInsetsOrSizeProp,
70+
/**
71+
* Used to reference react managed views from native code.
72+
*/
73+
id?: string,
74+
importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'),
75+
nativeID?: ?string,
76+
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => unknown,
77+
/**
78+
* When `accessible` is true (which is the default) this may be called when
79+
* the OS-specific concept of "blur" occurs, meaning the element lost focus.
80+
* Some platforms may not have the concept of blur.
81+
*/
82+
onBlur?: ?(event: BlurEvent) => unknown,
83+
/**
84+
* When `accessible` is true (which is the default) this may be called when
85+
* the OS-specific concept of "focus" occurs. Some platforms may not have
86+
* the concept of focus.
87+
*/
88+
onFocus?: ?(event: FocusEvent) => unknown,
89+
/**
90+
* Invoked on mount and layout changes with
91+
* {nativeEvent: {layout: {x, y, width, height}}}
92+
*/
93+
onLayout?: ?(event: LayoutChangeEvent) => unknown,
94+
onLongPress?: ?(event: GestureResponderEvent) => unknown,
95+
/**
96+
* Called when the touch is released,
97+
* but not if cancelled (e.g. by a scroll that steals the responder lock).
98+
*/
99+
onPress?: ?(event: GestureResponderEvent) => unknown,
100+
onPressIn?: ?(event: GestureResponderEvent) => unknown,
101+
onPressOut?: ?(event: GestureResponderEvent) => unknown,
102+
/**
103+
* When the scroll view is disabled, this defines how far your
104+
* touch may move off of the button, before deactivating the button.
105+
* Once deactivated, try moving it back and you'll see that the button
106+
* is once again reactivated! Move it back and forth several times
107+
* while the scroll view is disabled. Ensure you pass in a constant
108+
* to reduce memory allocations.
109+
*/
110+
pressRetentionOffset?: ?EdgeInsetsOrSizeProp,
111+
rejectResponderTermination?: ?boolean,
112+
/**
113+
* Used to locate this view in end-to-end tests.
114+
*/
115+
testID?: ?string,
116+
/**
117+
* //FIXME: not in doc but available in examples
118+
*/
119+
style?: ?ViewStyleProp,
120+
};
121+
39122
/** @build-types emit-as-interface Expo compatibility */
40123
export type TouchableWithoutFeedbackProps = Readonly<
41-
{
42-
children?: ?React.Node,
43-
/**
44-
* Delay in ms, from onPressIn, before onLongPress is called.
45-
*/
46-
delayLongPress?: ?number,
47-
/**
48-
* Delay in ms, from the start of the touch, before onPressIn is called.
49-
*/
50-
delayPressIn?: ?number,
51-
/**
52-
* Delay in ms, from the release of the touch, before onPressOut is called.
53-
*/
54-
delayPressOut?: ?number,
55-
/**
56-
* If true, disable all interactions for this component.
57-
*/
58-
disabled?: ?boolean,
59-
/**
60-
* Whether this View should be focusable with a non-touch input device,
61-
* eg. receive focus with a hardware keyboard / TV remote.
62-
*/
63-
focusable?: ?boolean,
64-
/**
65-
* This defines how far your touch can start away from the button.
66-
* This is added to pressRetentionOffset when moving off of the button.
67-
* NOTE The touch area never extends past the parent view bounds and
68-
* the Z-index of sibling views always takes precedence if a touch hits
69-
* two overlapping views.
70-
*/
71-
hitSlop?: ?EdgeInsetsOrSizeProp,
72-
/**
73-
* Used to reference react managed views from native code.
74-
*/
75-
id?: string,
76-
importantForAccessibility?: ?(
77-
'auto' | 'yes' | 'no' | 'no-hide-descendants'
78-
),
79-
nativeID?: ?string,
80-
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => unknown,
81-
/**
82-
* When `accessible` is true (which is the default) this may be called when
83-
* the OS-specific concept of "blur" occurs, meaning the element lost focus.
84-
* Some platforms may not have the concept of blur.
85-
*/
86-
onBlur?: ?(event: BlurEvent) => unknown,
87-
/**
88-
* When `accessible` is true (which is the default) this may be called when
89-
* the OS-specific concept of "focus" occurs. Some platforms may not have
90-
* the concept of focus.
91-
*/
92-
onFocus?: ?(event: FocusEvent) => unknown,
93-
/**
94-
* Invoked on mount and layout changes with
95-
* {nativeEvent: {layout: {x, y, width, height}}}
96-
*/
97-
onLayout?: ?(event: LayoutChangeEvent) => unknown,
98-
onLongPress?: ?(event: GestureResponderEvent) => unknown,
99-
/**
100-
* Called when the touch is released,
101-
* but not if cancelled (e.g. by a scroll that steals the responder lock).
102-
*/
103-
onPress?: ?(event: GestureResponderEvent) => unknown,
104-
onPressIn?: ?(event: GestureResponderEvent) => unknown,
105-
onPressOut?: ?(event: GestureResponderEvent) => unknown,
106-
/**
107-
* When the scroll view is disabled, this defines how far your
108-
* touch may move off of the button, before deactivating the button.
109-
* Once deactivated, try moving it back and you'll see that the button
110-
* is once again reactivated! Move it back and forth several times
111-
* while the scroll view is disabled. Ensure you pass in a constant
112-
* to reduce memory allocations.
113-
*/
114-
pressRetentionOffset?: ?EdgeInsetsOrSizeProp,
115-
rejectResponderTermination?: ?boolean,
116-
/**
117-
* Used to locate this view in end-to-end tests.
118-
*/
119-
testID?: ?string,
120-
/**
121-
* //FIXME: not in doc but available in examples
122-
*/
123-
style?: ?ViewStyleProp,
124-
} & TouchableWithoutFeedbackPropsAndroid &
124+
TouchableWithoutFeedbackPropsCore &
125+
TouchableWithoutFeedbackPropsAndroid &
125126
TouchableWithoutFeedbackPropsIOS &
126127
AccessibilityProps,
127128
>;

packages/react-native/Libraries/Components/View/ViewAccessibility.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,7 @@ export type AccessibilityPropsIOS = Readonly<{
349349
accessibilityRespondsToUserInteraction?: ?boolean,
350350
}>;
351351

352-
/** @build-types emit-as-interface react-native-web compatibility */
353-
export type AccessibilityProps = Readonly<{
354-
...AccessibilityPropsAndroid,
355-
...AccessibilityPropsIOS,
352+
type AccessibilityPropsCore = Readonly<{
356353
/**
357354
* When `true`, indicates that the view is an accessibility element.
358355
* By default, all the touchable elements are accessible.
@@ -434,3 +431,10 @@ export type AccessibilityProps = Readonly<{
434431
*/
435432
'aria-hidden'?: ?boolean,
436433
}>;
434+
435+
/** @build-types emit-as-interface react-native-web compatibility */
436+
export type AccessibilityProps = Readonly<{
437+
...AccessibilityPropsAndroid,
438+
...AccessibilityPropsIOS,
439+
...AccessibilityPropsCore,
440+
}>;

0 commit comments

Comments
 (0)