Skip to content

Commit f338db9

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Reduce symbol collisions in the API snapshot (#52085)
Summary: Pull Request resolved: #52085 Changelog: [Internal] Reviewed By: huntie Differential Revision: D76814453 fbshipit-source-id: fffbf585d63e282443830c08397ae5e4d745785a
1 parent fe4047f commit f338db9

File tree

12 files changed

+73
-58
lines changed

12 files changed

+73
-58
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,12 @@ export type ButtonProps = $ReadOnly<{
281281
```
282282
*/
283283

284-
const Touchable: typeof TouchableNativeFeedback | typeof TouchableOpacity =
284+
const NativeTouchable:
285+
| typeof TouchableNativeFeedback
286+
| typeof TouchableOpacity =
285287
Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;
286288

287-
type ButtonRef = React.ElementRef<typeof Touchable>;
289+
type ButtonRef = React.ElementRef<typeof NativeTouchable>;
288290

289291
const Button: component(
290292
ref?: React.RefSetter<ButtonRef>,
@@ -362,7 +364,7 @@ const Button: component(
362364
: importantForAccessibility;
363365

364366
return (
365-
<Touchable
367+
<NativeTouchable
366368
accessible={accessible}
367369
accessibilityActions={accessibilityActions}
368370
onAccessibilityAction={onAccessibilityAction}
@@ -391,7 +393,7 @@ const Button: component(
391393
{formattedTitle}
392394
</Text>
393395
</View>
394-
</Touchable>
396+
</NativeTouchable>
395397
);
396398
};
397399

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import * as React from 'react';
2424
* sensor housing area on iPhone X).
2525
* @deprecated Use `react-native-safe-area-context` instead. This component will be removed in a future release.
2626
*/
27-
const exported: component(
27+
const SafeAreaView: component(
2828
ref?: React.RefSetter<React.ElementRef<typeof View>>,
2929
...props: ViewProps
3030
) = Platform.select({
3131
ios: require('./RCTSafeAreaViewNativeComponent').default,
3232
default: View,
3333
});
3434

35-
export default exported;
35+
export default SafeAreaView;

packages/react-native/Libraries/EventEmitter/NativeEventEmitter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type {EventSubscription, EmitterSubscription};
3232
export type NativeEventSubscription = EventSubscription;
3333

3434
// $FlowFixMe[unclear-type] unclear type of events
35-
type UnsafeObject = Object;
35+
type UnsafeNativeEventObject = Object;
3636

3737
/**
3838
* `NativeEventEmitter` is intended for use by Native Modules to emit events to
@@ -46,8 +46,8 @@ type UnsafeObject = Object;
4646
*/
4747
export default class NativeEventEmitter<
4848
TEventToArgsMap: $ReadOnly<
49-
Record<string, $ReadOnlyArray<UnsafeObject>>,
50-
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
49+
Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>,
50+
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>>,
5151
> implements IEventEmitter<TEventToArgsMap>
5252
{
5353
_nativeModule: ?NativeModule;

packages/react-native/Libraries/LayoutAnimation/LayoutAnimation.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type OnAnimationDidFailCallback = () => void;
4545
let isLayoutAnimationEnabled: boolean =
4646
ReactNativeFeatureFlags.isLayoutAnimationEnabled();
4747

48-
function setEnabled(value: boolean) {
48+
function setLayoutAnimationEnabled(value: boolean) {
4949
isLayoutAnimationEnabled = isLayoutAnimationEnabled;
5050
}
5151

@@ -115,7 +115,7 @@ function configureNext(
115115
}
116116
}
117117

118-
function create(
118+
function createLayoutAnimation(
119119
duration: number,
120120
type?: LayoutAnimationType,
121121
property?: LayoutAnimationProperty,
@@ -129,12 +129,16 @@ function create(
129129
}
130130

131131
const Presets = {
132-
easeInEaseOut: (create(
132+
easeInEaseOut: (createLayoutAnimation(
133133
300,
134134
'easeInEaseOut',
135135
'opacity',
136136
): LayoutAnimationConfig),
137-
linear: (create(500, 'linear', 'opacity'): LayoutAnimationConfig),
137+
linear: (createLayoutAnimation(
138+
500,
139+
'linear',
140+
'opacity',
141+
): LayoutAnimationConfig),
138142
spring: ({
139143
duration: 700,
140144
create: {
@@ -180,7 +184,7 @@ const LayoutAnimation = {
180184
/**
181185
* Helper for creating a config for `configureNext`.
182186
*/
183-
create,
187+
create: createLayoutAnimation,
184188
Types: Object.freeze({
185189
spring: 'spring',
186190
linear: 'linear',
@@ -208,7 +212,7 @@ const LayoutAnimation = {
208212
spring: (configureNext.bind(null, Presets.spring): (
209213
onAnimationDidEnd?: OnAnimationDidEndCallback,
210214
) => void),
211-
setEnabled,
215+
setEnabled: setLayoutAnimationEnabled,
212216
};
213217

214218
export default LayoutAnimation;

packages/react-native/Libraries/Lists/FlatList.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type {
1515
ListRenderItemInfo,
1616
ViewabilityConfigCallbackPair,
1717
ViewToken,
18+
VirtualizedListProps,
1819
} from '@react-native/virtualized-lists';
1920

2021
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';

packages/react-native/Libraries/PermissionsAndroid/PermissionsAndroid.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const PERMISSIONS = Object.freeze({
130130
*
131131
* See https://reactnative.dev/docs/permissionsandroid
132132
*/
133-
class PermissionsAndroid {
133+
class PermissionsAndroidImpl {
134134
PERMISSIONS: PermissionsType = PERMISSIONS;
135135
RESULTS: $ReadOnly<{
136136
DENIED: 'denied',
@@ -297,5 +297,6 @@ class PermissionsAndroid {
297297
}
298298
}
299299

300-
const PermissionsAndroidInstance: PermissionsAndroid = new PermissionsAndroid();
300+
const PermissionsAndroidInstance: PermissionsAndroidImpl =
301+
new PermissionsAndroidImpl();
301302
export default PermissionsAndroidInstance;

packages/react-native/Libraries/ReactNative/AppRegistry.flow.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import type {RootTag} from '../Types/RootTagTypes';
1313
import type {IPerformanceLogger} from '../Utilities/createPerformanceLogger';
1414
import type {DisplayModeType} from './DisplayMode';
1515

16-
type Task = (taskData: any) => Promise<void>;
17-
export type TaskProvider = () => Task;
16+
type HeadlessTask = (taskData: any) => Promise<void>;
17+
export type TaskProvider = () => HeadlessTask;
1818

1919
export type ComponentProvider = () => React.ComponentType<any>;
2020
export type ComponentProviderInstrumentationHook = (

packages/react-native/Libraries/Utilities/NativeDeviceInfo.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@
99
*/
1010

1111
export * from '../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo';
12-
import NativeDeviceInfo from '../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo';
13-
14-
export default NativeDeviceInfo;
12+
export {default} from '../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo';

packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,10 +1535,10 @@ exports[`public API should not change unintentionally Libraries/Components/Butto
15351535
accessibilityHint?: ?string,
15361536
accessibilityLanguage?: ?Stringish,
15371537
}>;
1538-
declare const Touchable:
1538+
declare const NativeTouchable:
15391539
| typeof TouchableNativeFeedback
15401540
| typeof TouchableOpacity;
1541-
type ButtonRef = React.ElementRef<typeof Touchable>;
1541+
type ButtonRef = React.ElementRef<typeof NativeTouchable>;
15421542
declare const Button: component(
15431543
ref?: React.RefSetter<ButtonRef>,
15441544
...props: ButtonProps
@@ -1928,11 +1928,11 @@ export { default } from \\"../../../src/private/specs_DEPRECATED/components/RCTS
19281928
`;
19291929

19301930
exports[`public API should not change unintentionally Libraries/Components/SafeAreaView/SafeAreaView.js 1`] = `
1931-
"declare const exported: component(
1931+
"declare const SafeAreaView: component(
19321932
ref?: React.RefSetter<React.ElementRef<typeof View>>,
19331933
...props: ViewProps
19341934
);
1935-
declare export default typeof exported;
1935+
declare export default typeof SafeAreaView;
19361936
"
19371937
`;
19381938

@@ -4175,11 +4175,11 @@ exports[`public API should not change unintentionally Libraries/EventEmitter/Nat
41754175
type EmitterSubscription = EventSubscription;
41764176
export type { EventSubscription, EmitterSubscription };
41774177
export type NativeEventSubscription = EventSubscription;
4178-
type UnsafeObject = Object;
4178+
type UnsafeNativeEventObject = Object;
41794179
declare export default class NativeEventEmitter<
41804180
TEventToArgsMap: $ReadOnly<
4181-
Record<string, $ReadOnlyArray<UnsafeObject>>,
4182-
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
4181+
Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>,
4182+
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>>,
41834183
> implements IEventEmitter<TEventToArgsMap>
41844184
{
41854185
constructor(nativeModule?: ?NativeModule): void;
@@ -4855,13 +4855,13 @@ export type LayoutAnimationProperties = $ReadOnly<{
48554855
}>;
48564856
type OnAnimationDidEndCallback = () => void;
48574857
type OnAnimationDidFailCallback = () => void;
4858-
declare function setEnabled(value: boolean): void;
4858+
declare function setLayoutAnimationEnabled(value: boolean): void;
48594859
declare function configureNext(
48604860
config: LayoutAnimationConfig,
48614861
onAnimationDidEnd?: OnAnimationDidEndCallback,
48624862
onAnimationDidFail?: OnAnimationDidFailCallback
48634863
): void;
4864-
declare function create(
4864+
declare function createLayoutAnimation(
48654865
duration: number,
48664866
type?: LayoutAnimationType,
48674867
property?: LayoutAnimationProperty
@@ -4873,15 +4873,15 @@ declare const Presets: {
48734873
};
48744874
declare const LayoutAnimation: {
48754875
configureNext: typeof configureNext,
4876-
create: typeof create,
4876+
create: typeof createLayoutAnimation,
48774877
Types: LayoutAnimationTypes,
48784878
Properties: LayoutAnimationProperties,
48794879
checkConfig(...args: Array<mixed>): void,
48804880
Presets: typeof Presets,
48814881
easeInEaseOut: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
48824882
linear: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
48834883
spring: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
4884-
setEnabled: typeof setEnabled,
4884+
setEnabled: typeof setLayoutAnimationEnabled,
48854885
};
48864886
declare export default typeof LayoutAnimation;
48874887
"
@@ -6141,7 +6141,7 @@ type PermissionsType = $ReadOnly<{
61416141
}>;
61426142
export type PermissionStatus = \\"granted\\" | \\"denied\\" | \\"never_ask_again\\";
61436143
export type Permission = $Values<PermissionsType>;
6144-
declare class PermissionsAndroid {
6144+
declare class PermissionsAndroidImpl {
61456145
PERMISSIONS: PermissionsType;
61466146
RESULTS: $ReadOnly<{
61476147
DENIED: \\"denied\\",
@@ -6162,7 +6162,7 @@ declare class PermissionsAndroid {
61626162
permissions: Array<Permission>
61636163
): Promise<{ [permission: Permission]: PermissionStatus, ... }>;
61646164
}
6165-
declare const PermissionsAndroidInstance: PermissionsAndroid;
6165+
declare const PermissionsAndroidInstance: PermissionsAndroidImpl;
61666166
declare export default typeof PermissionsAndroidInstance;
61676167
"
61686168
`;
@@ -6428,8 +6428,8 @@ declare export default typeof AppContainer;
64286428
`;
64296429

64306430
exports[`public API should not change unintentionally Libraries/ReactNative/AppRegistry.flow.js 1`] = `
6431-
"type Task = (taskData: any) => Promise<void>;
6432-
export type TaskProvider = () => Task;
6431+
"type HeadlessTask = (taskData: any) => Promise<void>;
6432+
export type TaskProvider = () => HeadlessTask;
64336433
export type ComponentProvider = () => React.ComponentType<any>;
64346434
export type ComponentProviderInstrumentationHook = (
64356435
component_: ComponentProvider,
@@ -8359,7 +8359,7 @@ declare export default typeof NativeDevLoadingView;
83598359

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

@@ -8955,12 +8955,12 @@ declare export default ErrorUtils;
89558955
`;
89568956

89578957
exports[`public API should not change unintentionally Libraries/vendor/emitter/EventEmitter.js 1`] = `
8958-
"type UnsafeObject = Object;
8958+
"type UnsafeEventObject = Object;
89598959
export interface EventSubscription {
89608960
remove(): void;
89618961
}
89628962
export interface IEventEmitter<
8963-
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
8963+
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
89648964
> {
89658965
addListener<TEvent: $Keys<TEventToArgsMap>>(
89668966
eventType: TEvent,
@@ -8976,8 +8976,8 @@ export interface IEventEmitter<
89768976
}
89778977
declare export default class EventEmitter<
89788978
TEventToArgsMap: $ReadOnly<
8979-
Record<string, $ReadOnlyArray<UnsafeObject>>,
8980-
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
8979+
Record<string, $ReadOnlyArray<UnsafeEventObject>>,
8980+
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
89818981
> implements IEventEmitter<TEventToArgsMap>
89828982
{
89838983
constructor(): void;

packages/react-native/Libraries/vendor/emitter/EventEmitter.js

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

1111
// $FlowFixMe[unclear-type] unclear type of events
12-
type UnsafeObject = Object;
12+
type UnsafeEventObject = Object;
1313

1414
export interface EventSubscription {
1515
remove(): void;
1616
}
1717

1818
export interface IEventEmitter<
19-
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
19+
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
2020
> {
2121
addListener<TEvent: $Keys<TEventToArgsMap>>(
2222
eventType: TEvent,
@@ -41,7 +41,7 @@ interface Registration<TArgs> {
4141
}
4242

4343
type Registry<
44-
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
44+
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
4545
> = {
4646
[K in keyof TEventToArgsMap]: Set<Registration<TEventToArgsMap[K]>>,
4747
};
@@ -68,8 +68,8 @@ type Registry<
6868
*/
6969
export default class EventEmitter<
7070
TEventToArgsMap: $ReadOnly<
71-
Record<string, $ReadOnlyArray<UnsafeObject>>,
72-
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
71+
Record<string, $ReadOnlyArray<UnsafeEventObject>>,
72+
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
7373
> implements IEventEmitter<TEventToArgsMap>
7474
{
7575
#registry: Registry<TEventToArgsMap>;
@@ -157,7 +157,7 @@ export default class EventEmitter<
157157
}
158158

159159
function allocate<
160-
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
160+
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
161161
TEvent: $Keys<TEventToArgsMap>,
162162
TEventArgs: TEventToArgsMap[TEvent],
163163
>(

0 commit comments

Comments
 (0)