Skip to content

Commit d3f0fe6

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Reduce symbol collisions in the API snapshot (#52213)
Summary: Changelog: [Internal] Reviewed By: huntie Differential Revision: D77207979
1 parent 19ebd4c commit d3f0fe6

File tree

11 files changed

+70
-57
lines changed

11 files changed

+70
-57
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/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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ 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';
2122
import {type ScrollResponderType} from '../Components/ScrollView/ScrollView';
2223
import View from '../Components/View/View';
23-
import VirtualizedLists, {
24-
type VirtualizedListProps,
25-
} from '@react-native/virtualized-lists';
24+
import VirtualizedLists from '@react-native/virtualized-lists';
2625
import memoizeOne from 'memoize-one';
2726
import * as React from 'react';
2827

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: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,10 +1539,10 @@ exports[`public API should not change unintentionally Libraries/Components/Butto
15391539
accessibilityHint?: ?string,
15401540
accessibilityLanguage?: ?Stringish,
15411541
}>;
1542-
declare const Touchable:
1542+
declare const NativeTouchable:
15431543
| typeof TouchableNativeFeedback
15441544
| typeof TouchableOpacity;
1545-
type ButtonRef = React.ElementRef<typeof Touchable>;
1545+
type ButtonRef = React.ElementRef<typeof NativeTouchable>;
15461546
declare const Button: component(
15471547
ref?: React.RefSetter<ButtonRef>,
15481548
...props: ButtonProps
@@ -4179,11 +4179,11 @@ exports[`public API should not change unintentionally Libraries/EventEmitter/Nat
41794179
type EmitterSubscription = EventSubscription;
41804180
export type { EventSubscription, EmitterSubscription };
41814181
export type NativeEventSubscription = EventSubscription;
4182-
type UnsafeObject = Object;
4182+
type UnsafeNativeEventObject = Object;
41834183
declare export default class NativeEventEmitter<
41844184
TEventToArgsMap: $ReadOnly<
4185-
Record<string, $ReadOnlyArray<UnsafeObject>>,
4186-
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
4185+
Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>,
4186+
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>>,
41874187
> implements IEventEmitter<TEventToArgsMap>
41884188
{
41894189
constructor(nativeModule?: ?NativeModule): void;
@@ -4859,13 +4859,13 @@ export type LayoutAnimationProperties = $ReadOnly<{
48594859
}>;
48604860
type OnAnimationDidEndCallback = () => void;
48614861
type OnAnimationDidFailCallback = () => void;
4862-
declare function setEnabled(value: boolean): void;
4862+
declare function setLayoutAnimationEnabled(value: boolean): void;
48634863
declare function configureNext(
48644864
config: LayoutAnimationConfig,
48654865
onAnimationDidEnd?: OnAnimationDidEndCallback,
48664866
onAnimationDidFail?: OnAnimationDidFailCallback
48674867
): void;
4868-
declare function create(
4868+
declare function createLayoutAnimation(
48694869
duration: number,
48704870
type?: LayoutAnimationType,
48714871
property?: LayoutAnimationProperty
@@ -4877,15 +4877,15 @@ declare const Presets: {
48774877
};
48784878
declare const LayoutAnimation: {
48794879
configureNext: typeof configureNext,
4880-
create: typeof create,
4880+
create: typeof createLayoutAnimation,
48814881
Types: LayoutAnimationTypes,
48824882
Properties: LayoutAnimationProperties,
48834883
checkConfig(...args: Array<mixed>): void,
48844884
Presets: typeof Presets,
48854885
easeInEaseOut: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
48864886
linear: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
48874887
spring: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
4888-
setEnabled: typeof setEnabled,
4888+
setEnabled: typeof setLayoutAnimationEnabled,
48894889
};
48904890
declare export default typeof LayoutAnimation;
48914891
"
@@ -6145,7 +6145,7 @@ type PermissionsType = $ReadOnly<{
61456145
}>;
61466146
export type PermissionStatus = \\"granted\\" | \\"denied\\" | \\"never_ask_again\\";
61476147
export type Permission = $Values<PermissionsType>;
6148-
declare class PermissionsAndroid {
6148+
declare class PermissionsAndroidImpl {
61496149
PERMISSIONS: PermissionsType;
61506150
RESULTS: $ReadOnly<{
61516151
DENIED: \\"denied\\",
@@ -6166,7 +6166,7 @@ declare class PermissionsAndroid {
61666166
permissions: Array<Permission>
61676167
): Promise<{ [permission: Permission]: PermissionStatus, ... }>;
61686168
}
6169-
declare const PermissionsAndroidInstance: PermissionsAndroid;
6169+
declare const PermissionsAndroidInstance: PermissionsAndroidImpl;
61706170
declare export default typeof PermissionsAndroidInstance;
61716171
"
61726172
`;
@@ -6432,8 +6432,8 @@ declare export default typeof AppContainer;
64326432
`;
64336433

64346434
exports[`public API should not change unintentionally Libraries/ReactNative/AppRegistry.flow.js 1`] = `
6435-
"type Task = (taskData: any) => Promise<void>;
6436-
export type TaskProvider = () => Task;
6435+
"type HeadlessTask = (taskData: any) => Promise<void>;
6436+
export type TaskProvider = () => HeadlessTask;
64376437
export type ComponentProvider = () => React.ComponentType<any>;
64386438
export type ComponentProviderInstrumentationHook = (
64396439
component_: ComponentProvider,
@@ -8363,7 +8363,7 @@ declare export default typeof NativeDevLoadingView;
83638363

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

@@ -8959,12 +8959,12 @@ declare export default ErrorUtils;
89598959
`;
89608960

89618961
exports[`public API should not change unintentionally Libraries/vendor/emitter/EventEmitter.js 1`] = `
8962-
"type UnsafeObject = Object;
8962+
"type UnsafeEventObject = Object;
89638963
export interface EventSubscription {
89648964
remove(): void;
89658965
}
89668966
export interface IEventEmitter<
8967-
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
8967+
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
89688968
> {
89698969
addListener<TEvent: $Keys<TEventToArgsMap>>(
89708970
eventType: TEvent,
@@ -8980,8 +8980,8 @@ export interface IEventEmitter<
89808980
}
89818981
declare export default class EventEmitter<
89828982
TEventToArgsMap: $ReadOnly<
8983-
Record<string, $ReadOnlyArray<UnsafeObject>>,
8984-
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
8983+
Record<string, $ReadOnlyArray<UnsafeEventObject>>,
8984+
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
89858985
> implements IEventEmitter<TEventToArgsMap>
89868986
{
89878987
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
>(

packages/react-native/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNative
2121
import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent';
2222
import * as React from 'react';
2323

24-
type SwitchChangeEvent = $ReadOnly<{
24+
type NativeSwitchChangeEvent = $ReadOnly<{
2525
value: boolean,
2626
target: Int32,
2727
}>;
@@ -42,7 +42,7 @@ type SwitchNativeProps = $ReadOnly<{
4242
trackColorForTrue?: ?ColorValue,
4343

4444
// Events
45-
onChange?: ?BubblingEventHandler<SwitchChangeEvent>,
45+
onChange?: ?BubblingEventHandler<NativeSwitchChangeEvent>,
4646
}>;
4747

4848
type ComponentType = HostComponent<SwitchNativeProps>;

0 commit comments

Comments
 (0)