Reduce symbol collisions in the API snapshot (#52085)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52085

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D76814453

fbshipit-source-id: fffbf585d63e282443830c08397ae5e4d745785a
This commit is contained in:
Jakub Piasecki
2025-06-23 00:34:05 -07:00
committed by Facebook GitHub Bot
parent fe4047fe3a
commit f338db9c17
12 changed files with 73 additions and 58 deletions
+6 -4
View File
@@ -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>,
@@ -362,7 +364,7 @@ const Button: component(
: importantForAccessibility;
return (
<Touchable
<NativeTouchable
accessible={accessible}
accessibilityActions={accessibilityActions}
onAccessibilityAction={onAccessibilityAction}
@@ -391,7 +393,7 @@ const Button: component(
{formattedTitle}
</Text>
</View>
</Touchable>
</NativeTouchable>
);
};
@@ -24,7 +24,7 @@ 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({
@@ -32,4 +32,4 @@ const exported: component(
default: View,
});
export default exported;
export default SafeAreaView;
@@ -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
@@ -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;
@@ -45,7 +45,7 @@ type OnAnimationDidFailCallback = () => void;
let isLayoutAnimationEnabled: boolean =
ReactNativeFeatureFlags.isLayoutAnimationEnabled();
function setEnabled(value: boolean) {
function setLayoutAnimationEnabled(value: boolean) {
isLayoutAnimationEnabled = isLayoutAnimationEnabled;
}
@@ -115,7 +115,7 @@ function configureNext(
}
}
function create(
function createLayoutAnimation(
duration: number,
type?: LayoutAnimationType,
property?: LayoutAnimationProperty,
@@ -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: {
@@ -180,7 +184,7 @@ const LayoutAnimation = {
/**
* Helper for creating a config for `configureNext`.
*/
create,
create: createLayoutAnimation,
Types: Object.freeze({
spring: 'spring',
linear: 'linear',
@@ -208,7 +212,7 @@ const LayoutAnimation = {
spring: (configureNext.bind(null, Presets.spring): (
onAnimationDidEnd?: OnAnimationDidEndCallback,
) => void),
setEnabled,
setEnabled: setLayoutAnimationEnabled,
};
export default LayoutAnimation;
+1
View File
@@ -15,6 +15,7 @@ import type {
ListRenderItemInfo,
ViewabilityConfigCallbackPair,
ViewToken,
VirtualizedListProps,
} from '@react-native/virtualized-lists';
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
@@ -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',
@@ -297,5 +297,6 @@ class PermissionsAndroid {
}
}
const PermissionsAndroidInstance: PermissionsAndroid = new PermissionsAndroid();
const PermissionsAndroidInstance: PermissionsAndroidImpl =
new PermissionsAndroidImpl();
export default PermissionsAndroidInstance;
@@ -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 = (
@@ -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';
@@ -1535,10 +1535,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
@@ -1928,11 +1928,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;
"
`;
@@ -4175,11 +4175,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;
@@ -4855,13 +4855,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
@@ -4873,7 +4873,7 @@ declare const Presets: {
};
declare const LayoutAnimation: {
configureNext: typeof configureNext,
create: typeof create,
create: typeof createLayoutAnimation,
Types: LayoutAnimationTypes,
Properties: LayoutAnimationProperties,
checkConfig(...args: Array<mixed>): void,
@@ -4881,7 +4881,7 @@ declare const LayoutAnimation: {
easeInEaseOut: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
linear: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
spring: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
setEnabled: typeof setEnabled,
setEnabled: typeof setLayoutAnimationEnabled,
};
declare export default typeof LayoutAnimation;
"
@@ -6141,7 +6141,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\\",
@@ -6162,7 +6162,7 @@ declare class PermissionsAndroid {
permissions: Array<Permission>
): Promise<{ [permission: Permission]: PermissionStatus, ... }>;
}
declare const PermissionsAndroidInstance: PermissionsAndroid;
declare const PermissionsAndroidInstance: PermissionsAndroidImpl;
declare export default typeof PermissionsAndroidInstance;
"
`;
@@ -6428,8 +6428,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,
@@ -8359,7 +8359,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\\";
"
`;
@@ -8955,12 +8955,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,
@@ -8976,8 +8976,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;
@@ -9,14 +9,14 @@
*/
// $FlowFixMe[unclear-type] unclear type of events
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,
@@ -41,7 +41,7 @@ interface Registration<TArgs> {
}
type Registry<
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
> = {
[K in keyof TEventToArgsMap]: Set<Registration<TEventToArgsMap[K]>>,
};
@@ -68,8 +68,8 @@ type Registry<
*/
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>
{
#registry: Registry<TEventToArgsMap>;
@@ -157,7 +157,7 @@ export default class EventEmitter<
}
function allocate<
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
TEvent: $Keys<TEventToArgsMap>,
TEventArgs: TEventToArgsMap[TEvent],
>(
@@ -21,7 +21,7 @@ import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNative
import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent';
import * as React from 'react';
type SwitchChangeEvent = $ReadOnly<{
type NativeSwitchChangeEvent = $ReadOnly<{
value: boolean,
target: Int32,
}>;
@@ -42,7 +42,7 @@ type SwitchNativeProps = $ReadOnly<{
trackColorForTrue?: ?ColorValue,
// Events
onChange?: ?BubblingEventHandler<SwitchChangeEvent>,
onChange?: ?BubblingEventHandler<NativeSwitchChangeEvent>,
}>;
type ComponentType = HostComponent<SwitchNativeProps>;
@@ -17,17 +17,17 @@ import invariant from 'invariant';
import * as React from 'react';
import {useEffect, useState} from 'react';
type DefaultSectionT = {
type DefaultVirtualizedSectionT = {
data: any,
[key: string]: any,
};
export type SectionData<SectionItemT, SectionT = DefaultSectionT> =
export type SectionData<SectionItemT, SectionT = DefaultVirtualizedSectionT> =
| ($ReadOnly<SectionBase<SectionItemT, SectionT>> & SectionT)
| (SectionBase<SectionItemT, SectionT> & SectionT)
| SectionT;
export type SectionBase<SectionItemT, SectionT = DefaultSectionT> = {
export type SectionBase<SectionItemT, SectionT = DefaultVirtualizedSectionT> = {
/**
* The data for rendering items in this section.
*/
@@ -55,11 +55,11 @@ export type SectionBase<SectionItemT, SectionT = DefaultSectionT> = {
...
};
type RequiredProps<ItemT, SectionT = DefaultSectionT> = {
type RequiredProps<ItemT, SectionT = DefaultVirtualizedSectionT> = {
sections: $ReadOnlyArray<SectionData<ItemT, SectionT>>,
};
type OptionalProps<ItemT, SectionT = DefaultSectionT> = {
type OptionalProps<ItemT, SectionT = DefaultVirtualizedSectionT> = {
/**
* Default renderer for every item in every section.
*/
@@ -100,7 +100,10 @@ type OptionalProps<ItemT, SectionT = DefaultSectionT> = {
onEndReached?: ?({distanceFromEnd: number, ...}) => void,
};
export type VirtualizedSectionListProps<ItemT, SectionT = DefaultSectionT> = {
export type VirtualizedSectionListProps<
ItemT,
SectionT = DefaultVirtualizedSectionT,
> = {
...RequiredProps<ItemT, SectionT>,
...OptionalProps<ItemT, SectionT>,
...Omit<VirtualizedListProps, 'data' | 'renderItem'>,
@@ -122,7 +125,10 @@ type State = {childProps: VirtualizedListProps, ...};
*/
class VirtualizedSectionList<
ItemT,
SectionT: SectionBase<ItemT, DefaultSectionT> = DefaultSectionT,
SectionT: SectionBase<
ItemT,
DefaultVirtualizedSectionT,
> = DefaultVirtualizedSectionT,
> extends React.PureComponent<
VirtualizedSectionListProps<ItemT, SectionT>,
State,
@@ -613,7 +619,10 @@ function ItemWithSeparator<ItemT>(
const VirtualizedSectionListComponent = VirtualizedSectionList as component<
ItemT,
SectionT: SectionBase<ItemT, DefaultSectionT> = DefaultSectionT,
SectionT: SectionBase<
ItemT,
DefaultVirtualizedSectionT,
> = DefaultVirtualizedSectionT,
>(
ref: React.RefSetter<
interface {