Skip to content

Fix generated types base on __typetests__ #51317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@babel/plugin-transform-regenerator": "^7.24.7",
"@babel/preset-env": "^7.25.3",
"@babel/preset-flow": "^7.24.7",
"@definitelytyped/dtslint": "^0.0.127",
"@definitelytyped/dtslint": "^0.0.178",
"@jest/create-cache-key-function": "^29.7.0",
"@react-native/metro-babel-transformer": "0.80.0-main",
"@react-native/metro-config": "0.80.0-main",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type {default as AnimatedDivision} from './nodes/AnimatedDivision';
export type {default as AnimatedModulo} from './nodes/AnimatedModulo';
export type {default as AnimatedMultiplication} from './nodes/AnimatedMultiplication';
export type {default as AnimatedSubtraction} from './nodes/AnimatedSubtraction';
export type {WithAnimatedValue} from './createAnimatedComponent';
export type {WithAnimatedValue, AnimatedProps} from './createAnimatedComponent';
export type {AnimatedComponentType as AnimatedComponent} from './createAnimatedComponent';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import invariant from 'invariant';

export type AnimatedPropsAllowlist = $ReadOnly<{
style?: ?AnimatedStyleAllowlist,
[string]: true,
[key: string]: true | AnimatedStyleAllowlist,
}>;

type TargetView = {
Expand Down
7 changes: 6 additions & 1 deletion packages/react-native/Libraries/AppState/AppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ import NativeAppState from './NativeAppState';
* - @platform android - on another Activity (even if it was launched by your app)
* @platform ios - inactive - This is a state that occurs when transitioning between foreground & background, and during periods of inactivity such as entering the multitasking view, opening the Notification Center or in the event of an incoming call.
*/
export type AppStateStatus = 'inactive' | 'background' | 'active';
export type AppStateStatus =
| 'inactive'
| 'background'
| 'active'
| 'extension'
| 'unknown';

/**
* change - This even is received when the app state has changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ const ActivityIndicator: component(
style={StyleSheet.compose(styles.container, style)}>
{Platform.OS === 'android' ? (
// $FlowFixMe[prop-missing] Flow doesn't know when this is the android component
// $FlowFixMe[incompatible-type]
<PlatformActivityIndicator {...nativeProps} {...androidProps} />
) : (
/* $FlowFixMe[incompatible-type] (>=0.106.0 site=react_native_android_fb) This comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ import Platform from '../../Utilities/Platform';

export type {ProgressBarAndroidProps};

// A utility type to preserve the semantics of the union uses in the definition
// of ProgressBarAndroidProps. TS's Omit does not distribute over unions, so
// we define our own version which does. This does not affect Flow.
// $FlowExpectedError[unclear-type]
type Omit<T, K> = T extends any ? Pick<T, Exclude<$Keys<T>, K>> : T;

/**
* ProgressBarAndroid has been extracted from react-native core and will be removed in a future release.
* It can now be installed and imported from `@react-native-community/progress-bar-android` instead of 'react-native'.
Expand All @@ -27,7 +33,7 @@ let ProgressBarAndroid: component(
ref?: React.RefSetter<
React.ElementRef<ProgressBarAndroidNativeComponentType>,
>,
...props: ProgressBarAndroidProps
...props: Omit<ProgressBarAndroidProps, empty>
);

if (Platform.OS === 'android') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,25 @@ import type {ViewProps} from '../View/ViewPropTypes';
* `indeterminate` can only be false if `styleAttr` is Horizontal, and requires a
* `progress` value.
*/
type ProgressBarAndroidStyleAttrProp =
| {
styleAttr: 'Horizontal',
indeterminate: false,
progress: number,
}
| {
styleAttr:
| 'Horizontal'
| 'Normal'
| 'Small'
| 'Large'
| 'Inverse'
| 'SmallInverse'
| 'LargeInverse',
indeterminate: true,
};
type DeterminateProgressBarAndroidStyleAttrProp = {
styleAttr: 'Horizontal',
indeterminate: false,
progress: number,
};

export type ProgressBarAndroidProps = $ReadOnly<{
...ViewProps,
...ProgressBarAndroidStyleAttrProp,
type IndeterminateProgressBarAndroidStyleAttrProp = {
styleAttr:
| 'Horizontal'
| 'Normal'
| 'Small'
| 'Large'
| 'Inverse'
| 'SmallInverse'
| 'LargeInverse',
indeterminate: true,
};

type ProgressBarAndroidBaseProps = $ReadOnly<{
/**
* Whether to show the ProgressBar (true, the default) or hide it (false).
*/
Expand All @@ -52,3 +49,15 @@ export type ProgressBarAndroidProps = $ReadOnly<{
*/
testID?: ?string,
}>;

export type ProgressBarAndroidProps =
| $ReadOnly<{
...ViewProps,
...ProgressBarAndroidBaseProps,
...DeterminateProgressBarAndroidStyleAttrProp,
}>
| $ReadOnly<{
...ViewProps,
...ProgressBarAndroidBaseProps,
...IndeterminateProgressBarAndroidStyleAttrProp,
}>;
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default class NativeEventEmitter<
{
_nativeModule: ?NativeModule;

constructor(nativeModule: ?NativeModule) {
constructor(nativeModule?: ?NativeModule) {
if (Platform.OS === 'ios') {
invariant(
nativeModule != null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,6 @@ declare export const setStyleAttributePreprocessor: (
* An identity function for creating style sheets.
*/
// $FlowFixMe[unsupported-variance-annotation]
declare export const create: <+S: ____Styles_Internal>(obj: S) => $ReadOnly<S>;
declare export const create: <+S: ____Styles_Internal>(
obj: S & ____Styles_Internal,
) => $ReadOnly<S>;
5 changes: 3 additions & 2 deletions packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
____ViewStyle_InternalOverrides,
} from './private/_StyleSheetTypesOverrides';
import type {____TransformStyle_Internal} from './private/_TransformStyle';
import type {ColorValue} from './StyleSheet';

export type {____TransformStyle_Internal};

Expand Down Expand Up @@ -1001,7 +1002,7 @@ export type ____ImageStyle_InternalCore = $ReadOnly<{
resizeMode?: ImageResizeMode,
objectFit?: 'cover' | 'contain' | 'fill' | 'scale-down' | 'none',
tintColor?: ____ColorValue_Internal,
overlayColor?: string,
overlayColor?: ColorValue,
overflow?: 'visible' | 'hidden',
}>;

Expand All @@ -1015,7 +1016,7 @@ export type ____DangerouslyImpreciseStyle_InternalCore = $ReadOnly<{
resizeMode?: ImageResizeMode,
objectFit?: 'cover' | 'contain' | 'fill' | 'scale-down' | 'none',
tintColor?: ____ColorValue_Internal,
overlayColor?: string,
overlayColor?: ColorValue,
}>;

export type ____DangerouslyImpreciseStyle_Internal = $ReadOnly<{
Expand Down
33 changes: 2 additions & 31 deletions packages/react-native/Libraries/Text/TextProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import type {
AccessibilityActionEvent,
AccessibilityActionInfo,
AccessibilityProps,
AccessibilityRole,
AccessibilityState,
Role,
Expand Down Expand Up @@ -124,20 +125,7 @@ export type TextPropsAndroid = {
};

type TextBaseProps = $ReadOnly<{
/**
* Indicates whether the view is an accessibility element.
*
* See https://reactnative.dev/docs/text#accessible
*/
accessible?: ?boolean,
accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
accessibilityHint?: ?Stringish,
accessibilityLanguage?: ?Stringish,
accessibilityLabel?: ?Stringish,
accessibilityRole?: ?AccessibilityRole,
accessibilityState?: ?AccessibilityState,
'aria-label'?: ?string,

/**
* Whether fonts should scale to respect Text Size accessibility settings.
Expand All @@ -152,24 +140,6 @@ type TextBaseProps = $ReadOnly<{
*
*/
android_hyphenationFrequency?: ?('normal' | 'none' | 'full'),

/**
* alias for accessibilityState
*
* see https://reactnative.dev/docs/accessibility#accessibilitystate
*/
'aria-busy'?: ?boolean,
'aria-checked'?: ?boolean | 'mixed',
'aria-disabled'?: ?boolean,
'aria-expanded'?: ?boolean,
'aria-selected'?: ?boolean,

/**
* Represents the nativeID of the associated label text. When the assistive technology focuses on the component with this props, the text is read aloud.
* This prop is listed for cross-platform reasons and has no real effect on Android or iOS.
*/
'aria-labelledby'?: ?string,

children?: ?React.Node,

/**
Expand Down Expand Up @@ -306,4 +276,5 @@ export type TextProps = $ReadOnly<{
...TextPropsIOS,
...TextPropsAndroid,
...TextBaseProps,
...AccessibilityProps,
}>;
Loading
Loading