Skip to content
Closed
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
10 changes: 6 additions & 4 deletions packages/react-native/Libraries/Components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,12 @@ export type ButtonProps = $ReadOnly<{
```
*/

const Touchable: typeof TouchableNativeFeedback | typeof TouchableOpacity =
const NativeTouchable:
| typeof TouchableNativeFeedback
| typeof TouchableOpacity =
Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;

type ButtonRef = React.ElementRef<typeof Touchable>;
type ButtonRef = React.ElementRef<typeof NativeTouchable>;

const Button: component(
ref?: React.RefSetter<ButtonRef>,
Expand Down Expand Up @@ -362,7 +364,7 @@ const Button: component(
: importantForAccessibility;

return (
<Touchable
<NativeTouchable
accessible={accessible}
accessibilityActions={accessibilityActions}
onAccessibilityAction={onAccessibilityAction}
Expand Down Expand Up @@ -391,7 +393,7 @@ const Button: component(
{formattedTitle}
</Text>
</View>
</Touchable>
</NativeTouchable>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @format
*/

import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {
GestureResponderEvent,
LayoutChangeEvent,
Expand All @@ -26,8 +27,6 @@ import useAndroidRippleForView, {
import * as React from 'react';
import {memo, useMemo, useRef, useState} from 'react';

type ViewStyleProp = React.ElementConfig<typeof View>['style'];

export type {PressableAndroidRippleConfig};

export type PressableStateCallbackType = $ReadOnly<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import * as React from 'react';
* sensor housing area on iPhone X).
* @deprecated Use `react-native-safe-area-context` instead. This component will be removed in a future release.
*/
const exported: component(
const SafeAreaView: component(
ref?: React.RefSetter<React.ElementRef<typeof View>>,
...props: ViewProps
) = Platform.select({
ios: require('./RCTSafeAreaViewNativeComponent').default,
default: View,
});

export default exported;
export default SafeAreaView;
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type {EventSubscription, EmitterSubscription};
export type NativeEventSubscription = EventSubscription;

// $FlowFixMe[unclear-type] unclear type of events
type UnsafeObject = Object;
type UnsafeNativeEventObject = Object;

/**
* `NativeEventEmitter` is intended for use by Native Modules to emit events to
Expand All @@ -46,8 +46,8 @@ type UnsafeObject = Object;
*/
export default class NativeEventEmitter<
TEventToArgsMap: $ReadOnly<
Record<string, $ReadOnlyArray<UnsafeObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>>,
> implements IEventEmitter<TEventToArgsMap>
{
_nativeModule: ?NativeModule;
Expand Down
16 changes: 10 additions & 6 deletions packages/react-native/Libraries/LayoutAnimation/LayoutAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type OnAnimationDidFailCallback = () => void;
let isLayoutAnimationEnabled: boolean =
ReactNativeFeatureFlags.isLayoutAnimationEnabled();

function setEnabled(value: boolean) {
function setLayoutAnimationEnabled(value: boolean) {
isLayoutAnimationEnabled = isLayoutAnimationEnabled;
}

Expand Down Expand Up @@ -115,7 +115,7 @@ function configureNext(
}
}

function create(
function createLayoutAnimation(
duration: number,
type?: LayoutAnimationType,
property?: LayoutAnimationProperty,
Expand All @@ -129,12 +129,16 @@ function create(
}

const Presets = {
easeInEaseOut: (create(
easeInEaseOut: (createLayoutAnimation(
300,
'easeInEaseOut',
'opacity',
): LayoutAnimationConfig),
linear: (create(500, 'linear', 'opacity'): LayoutAnimationConfig),
linear: (createLayoutAnimation(
500,
'linear',
'opacity',
): LayoutAnimationConfig),
spring: ({
duration: 700,
create: {
Expand Down Expand Up @@ -180,7 +184,7 @@ const LayoutAnimation = {
/**
* Helper for creating a config for `configureNext`.
*/
create,
create: createLayoutAnimation,
Types: Object.freeze({
spring: 'spring',
linear: 'linear',
Expand Down Expand Up @@ -208,7 +212,7 @@ const LayoutAnimation = {
spring: (configureNext.bind(null, Presets.spring): (
onAnimationDidEnd?: OnAnimationDidEndCallback,
) => void),
setEnabled,
setEnabled: setLayoutAnimationEnabled,
};

export default LayoutAnimation;
3 changes: 1 addition & 2 deletions packages/react-native/Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
ListRenderItemInfo,
ViewabilityConfigCallbackPair,
ViewToken,
VirtualizedListProps,
} from '@react-native/virtualized-lists';

import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
Expand Down Expand Up @@ -181,8 +182,6 @@ type FlatListBaseProps<ItemT> = {
...OptionalProps<ItemT>,
};

type VirtualizedListProps = React.ElementConfig<typeof VirtualizedList>;

export type FlatListProps<ItemT> = {
...Omit<
VirtualizedListProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const PERMISSIONS = Object.freeze({
*
* See https://reactnative.dev/docs/permissionsandroid
*/
class PermissionsAndroid {
class PermissionsAndroidImpl {
PERMISSIONS: PermissionsType = PERMISSIONS;
RESULTS: $ReadOnly<{
DENIED: 'denied',
Expand Down Expand Up @@ -297,5 +297,6 @@ class PermissionsAndroid {
}
}

const PermissionsAndroidInstance: PermissionsAndroid = new PermissionsAndroid();
const PermissionsAndroidInstance: PermissionsAndroidImpl =
new PermissionsAndroidImpl();
export default PermissionsAndroidInstance;
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import type {RootTag} from '../Types/RootTagTypes';
import type {IPerformanceLogger} from '../Utilities/createPerformanceLogger';
import type {DisplayModeType} from './DisplayMode';

type Task = (taskData: any) => Promise<void>;
export type TaskProvider = () => Task;
type HeadlessTask = (taskData: any) => Promise<void>;
export type TaskProvider = () => HeadlessTask;

export type ComponentProvider = () => React.ComponentType<any>;
export type ComponentProviderInstrumentationHook = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
*/

export * from '../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo';
import NativeDeviceInfo from '../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo';

export default NativeDeviceInfo;
export {default} from '../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo';
Original file line number Diff line number Diff line change
Expand Up @@ -1538,10 +1538,10 @@ exports[`public API should not change unintentionally Libraries/Components/Butto
accessibilityHint?: ?string,
accessibilityLanguage?: ?Stringish,
}>;
declare const Touchable:
declare const NativeTouchable:
| typeof TouchableNativeFeedback
| typeof TouchableOpacity;
type ButtonRef = React.ElementRef<typeof Touchable>;
type ButtonRef = React.ElementRef<typeof NativeTouchable>;
declare const Button: component(
ref?: React.RefSetter<ButtonRef>,
...props: ButtonProps
Expand Down Expand Up @@ -1757,8 +1757,7 @@ declare export default typeof LayoutConformanceNativeComponent;
`;

exports[`public API should not change unintentionally Libraries/Components/Pressable/Pressable.js 1`] = `
"type ViewStyleProp = React.ElementConfig<typeof View>[\\"style\\"];
export type { PressableAndroidRippleConfig };
"export type { PressableAndroidRippleConfig };
export type PressableStateCallbackType = $ReadOnly<{
pressed: boolean,
}>;
Expand Down Expand Up @@ -1932,11 +1931,11 @@ export { default } from \\"../../../src/private/specs_DEPRECATED/components/RCTS
`;

exports[`public API should not change unintentionally Libraries/Components/SafeAreaView/SafeAreaView.js 1`] = `
"declare const exported: component(
"declare const SafeAreaView: component(
ref?: React.RefSetter<React.ElementRef<typeof View>>,
...props: ViewProps
);
declare export default typeof exported;
declare export default typeof SafeAreaView;
"
`;

Expand Down Expand Up @@ -4179,11 +4178,11 @@ exports[`public API should not change unintentionally Libraries/EventEmitter/Nat
type EmitterSubscription = EventSubscription;
export type { EventSubscription, EmitterSubscription };
export type NativeEventSubscription = EventSubscription;
type UnsafeObject = Object;
type UnsafeNativeEventObject = Object;
declare export default class NativeEventEmitter<
TEventToArgsMap: $ReadOnly<
Record<string, $ReadOnlyArray<UnsafeObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>>,
> implements IEventEmitter<TEventToArgsMap>
{
constructor(nativeModule?: ?NativeModule): void;
Expand Down Expand Up @@ -4859,13 +4858,13 @@ export type LayoutAnimationProperties = $ReadOnly<{
}>;
type OnAnimationDidEndCallback = () => void;
type OnAnimationDidFailCallback = () => void;
declare function setEnabled(value: boolean): void;
declare function setLayoutAnimationEnabled(value: boolean): void;
declare function configureNext(
config: LayoutAnimationConfig,
onAnimationDidEnd?: OnAnimationDidEndCallback,
onAnimationDidFail?: OnAnimationDidFailCallback
): void;
declare function create(
declare function createLayoutAnimation(
duration: number,
type?: LayoutAnimationType,
property?: LayoutAnimationProperty
Expand All @@ -4877,15 +4876,15 @@ declare const Presets: {
};
declare const LayoutAnimation: {
configureNext: typeof configureNext,
create: typeof create,
create: typeof createLayoutAnimation,
Types: LayoutAnimationTypes,
Properties: LayoutAnimationProperties,
checkConfig(...args: Array<mixed>): void,
Presets: typeof Presets,
easeInEaseOut: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
linear: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
spring: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
setEnabled: typeof setEnabled,
setEnabled: typeof setLayoutAnimationEnabled,
};
declare export default typeof LayoutAnimation;
"
Expand Down Expand Up @@ -4940,8 +4939,7 @@ declare export default typeof FillRateHelper;
`;

exports[`public API should not change unintentionally Libraries/Lists/FlatList.js 1`] = `
"declare const VirtualizedList: typeof VirtualizedLists.VirtualizedList;
type RequiredProps<ItemT> = {
"type RequiredProps<ItemT> = {
data: ?$ReadOnly<$ArrayLike<ItemT>>,
};
type OptionalProps<ItemT> = {
Expand Down Expand Up @@ -4971,7 +4969,6 @@ type FlatListBaseProps<ItemT> = {
...RequiredProps<ItemT>,
...OptionalProps<ItemT>,
};
type VirtualizedListProps = React.ElementConfig<typeof VirtualizedList>;
export type FlatListProps<ItemT> = {
...Omit<
VirtualizedListProps,
Expand Down Expand Up @@ -6147,7 +6144,7 @@ type PermissionsType = $ReadOnly<{
}>;
export type PermissionStatus = \\"granted\\" | \\"denied\\" | \\"never_ask_again\\";
export type Permission = $Values<PermissionsType>;
declare class PermissionsAndroid {
declare class PermissionsAndroidImpl {
PERMISSIONS: PermissionsType;
RESULTS: $ReadOnly<{
DENIED: \\"denied\\",
Expand All @@ -6168,7 +6165,7 @@ declare class PermissionsAndroid {
permissions: Array<Permission>
): Promise<{ [permission: Permission]: PermissionStatus, ... }>;
}
declare const PermissionsAndroidInstance: PermissionsAndroid;
declare const PermissionsAndroidInstance: PermissionsAndroidImpl;
declare export default typeof PermissionsAndroidInstance;
"
`;
Expand Down Expand Up @@ -6434,8 +6431,8 @@ declare export default typeof AppContainer;
`;

exports[`public API should not change unintentionally Libraries/ReactNative/AppRegistry.flow.js 1`] = `
"type Task = (taskData: any) => Promise<void>;
export type TaskProvider = () => Task;
"type HeadlessTask = (taskData: any) => Promise<void>;
export type TaskProvider = () => HeadlessTask;
export type ComponentProvider = () => React.ComponentType<any>;
export type ComponentProviderInstrumentationHook = (
component_: ComponentProvider,
Expand Down Expand Up @@ -8365,7 +8362,7 @@ declare export default typeof NativeDevLoadingView;

exports[`public API should not change unintentionally Libraries/Utilities/NativeDeviceInfo.js 1`] = `
"export * from \\"../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo\\";
declare export default typeof NativeDeviceInfo;
export { default } from \\"../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo\\";
"
`;

Expand Down Expand Up @@ -8961,12 +8958,12 @@ declare export default ErrorUtils;
`;

exports[`public API should not change unintentionally Libraries/vendor/emitter/EventEmitter.js 1`] = `
"type UnsafeObject = Object;
"type UnsafeEventObject = Object;
export interface EventSubscription {
remove(): void;
}
export interface IEventEmitter<
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
> {
addListener<TEvent: $Keys<TEventToArgsMap>>(
eventType: TEvent,
Expand All @@ -8982,8 +8979,8 @@ export interface IEventEmitter<
}
declare export default class EventEmitter<
TEventToArgsMap: $ReadOnly<
Record<string, $ReadOnlyArray<UnsafeObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
Record<string, $ReadOnlyArray<UnsafeEventObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
> implements IEventEmitter<TEventToArgsMap>
{
constructor(): void;
Expand Down
Loading
Loading