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 @@ -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;
5 changes: 2 additions & 3 deletions packages/react-native/Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ import type {
ListRenderItemInfo,
ViewabilityConfigCallbackPair,
ViewToken,
VirtualizedListProps,
} from '@react-native/virtualized-lists';

import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
import {type ScrollResponderType} from '../Components/ScrollView/ScrollView';
import View from '../Components/View/View';
import VirtualizedLists, {
type VirtualizedListProps,
} from '@react-native/virtualized-lists';
import VirtualizedLists from '@react-native/virtualized-lists';
import memoizeOne from 'memoize-one';
import * as React from 'react';

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 @@ -1539,10 +1539,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 @@ -4179,11 +4179,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 +4859,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 +4877,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 @@ -6145,7 +6145,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 @@ -6166,7 +6166,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 @@ -6432,8 +6432,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 @@ -8363,7 +8363,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 @@ -8959,12 +8959,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 @@ -8980,8 +8980,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
12 changes: 6 additions & 6 deletions packages/react-native/Libraries/vendor/emitter/EventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]>>,
};
Expand All @@ -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>;
Expand Down Expand Up @@ -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],
>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}>;
Expand All @@ -42,7 +42,7 @@ type SwitchNativeProps = $ReadOnly<{
trackColorForTrue?: ?ColorValue,

// Events
onChange?: ?BubblingEventHandler<SwitchChangeEvent>,
onChange?: ?BubblingEventHandler<NativeSwitchChangeEvent>,
}>;

type ComponentType = HostComponent<SwitchNativeProps>;
Expand Down
Loading
Loading