diff --git a/packages/react-native-codegen/src/generators/Utils.js b/packages/react-native-codegen/src/generators/Utils.js index b03003a8cd4..59227b34d29 100644 --- a/packages/react-native-codegen/src/generators/Utils.js +++ b/packages/react-native-codegen/src/generators/Utils.js @@ -23,7 +23,7 @@ function indent(nice: string, spaces: number): string { if (line.length === 0 || index === 0) { return line; } - const emptySpaces = new Array(spaces + 1).join(' '); + const emptySpaces = new Array(spaces + 1).join(' '); return emptySpaces + line; }) .join('\n'); diff --git a/packages/react-native-codegen/src/parsers/flow/components/commands.js b/packages/react-native-codegen/src/parsers/flow/components/commands.js index 88fc2d1ad4f..df8f54d901d 100644 --- a/packages/react-native-codegen/src/parsers/flow/components/commands.js +++ b/packages/react-native-codegen/src/parsers/flow/components/commands.js @@ -131,7 +131,7 @@ function buildCommandSchema( }; break; default: - (type: mixed); + (type: unknown); throw new Error( `Unsupported param type for method "${name}", param "${paramName}". Found ${type}`, ); @@ -160,7 +160,7 @@ function buildCommandSchema( type Allowed = ComponentCommandArrayTypeAnnotation['elementType']; function getCommandArrayElementTypeType( - inputType: mixed, + inputType: unknown, parser: Parser, ): Allowed { // TODO: T172453752 support more complex type annotation for array element diff --git a/packages/react-native-codegen/src/parsers/typescript/components/commands.js b/packages/react-native-codegen/src/parsers/typescript/components/commands.js index bf46e2a53f6..2b039c1e89c 100644 --- a/packages/react-native-codegen/src/parsers/typescript/components/commands.js +++ b/packages/react-native-codegen/src/parsers/typescript/components/commands.js @@ -102,7 +102,7 @@ function buildCommandSchemaInternal( }; break; default: - (type: mixed); + (type: unknown); throw new Error( `Unsupported param type for method "${name}", param "${paramName}". Found ${type}`, ); @@ -129,7 +129,7 @@ function buildCommandSchemaInternal( } function getCommandArrayElementTypeType( - inputType: mixed, + inputType: unknown, parser: Parser, ): ComponentCommandArrayTypeAnnotation['elementType'] { // TODO: T172453752 support more complex type annotation for array element diff --git a/packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js b/packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js index 71847b102cf..d9319abee40 100644 --- a/packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js +++ b/packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js @@ -335,7 +335,7 @@ function getTypeAnnotationForArray( type: 'FloatTypeAnnotation', }; default: - (type: mixed); + (type: unknown); throw new Error(`Unknown prop type for "${name}": ${type}`); } } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-props-all-types/NativeComponent.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-props-all-types/NativeComponent.js.flow index 2735237b394..75b5c137270 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-props-all-types/NativeComponent.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-props-all-types/NativeComponent.js.flow @@ -28,7 +28,7 @@ export type Props = $ReadOnly<{ int: Int32, stringUnion: WithDefault<'foo' | 'bar', 'bar'>, intUnion: WithDefault<1 | 2, 1>, - mixed: mixed, + mixed: unknown, backgroundColor?: WithDefault, height?: WithDefault, diff --git a/packages/react-native/Libraries/Pressability/Pressability.js b/packages/react-native/Libraries/Pressability/Pressability.js index eabfb8320fe..7c43691bde5 100644 --- a/packages/react-native/Libraries/Pressability/Pressability.js +++ b/packages/react-native/Libraries/Pressability/Pressability.js @@ -88,47 +88,47 @@ export type PressabilityConfig = $ReadOnly<{ /** * Called after the element loses focus. */ - onBlur?: ?(event: BlurEvent) => mixed, + onBlur?: ?(event: BlurEvent) => unknown, /** * Called after the element is focused. */ - onFocus?: ?(event: FocusEvent) => mixed, + onFocus?: ?(event: FocusEvent) => unknown, /** * Called when the hover is activated to provide visual feedback. */ - onHoverIn?: ?(event: MouseEvent) => mixed, + onHoverIn?: ?(event: MouseEvent) => unknown, /** * Called when the hover is deactivated to undo visual feedback. */ - onHoverOut?: ?(event: MouseEvent) => mixed, + onHoverOut?: ?(event: MouseEvent) => unknown, /** * Called when a long press gesture has been triggered. */ - onLongPress?: ?(event: GestureResponderEvent) => mixed, + onLongPress?: ?(event: GestureResponderEvent) => unknown, /** * Called when a press gesture has been triggered. */ - onPress?: ?(event: GestureResponderEvent) => mixed, + onPress?: ?(event: GestureResponderEvent) => unknown, /** * Called when the press is activated to provide visual feedback. */ - onPressIn?: ?(event: GestureResponderEvent) => mixed, + onPressIn?: ?(event: GestureResponderEvent) => unknown, /** * Called when the press location moves. (This should rarely be used.) */ - onPressMove?: ?(event: GestureResponderEvent) => mixed, + onPressMove?: ?(event: GestureResponderEvent) => unknown, /** * Called when the press is deactivated to undo visual feedback. */ - onPressOut?: ?(event: GestureResponderEvent) => mixed, + onPressOut?: ?(event: GestureResponderEvent) => unknown, /** * Whether to prevent any other native components from becoming responder diff --git a/packages/react-native/Libraries/Pressability/__tests__/Pressability-test.js b/packages/react-native/Libraries/Pressability/__tests__/Pressability-test.js index a5361ba21e6..be84bbdac94 100644 --- a/packages/react-native/Libraries/Pressability/__tests__/Pressability-test.js +++ b/packages/react-native/Libraries/Pressability/__tests__/Pressability-test.js @@ -26,7 +26,7 @@ const itif = (condition: boolean) => { }; // TODO: Move this util to a shared location. -function getMock, TReturn>( +function getMock, TReturn>( fn: (...args: TArguments) => TReturn, ): JestMockFn { if (!jest.isMockFunction(fn)) { diff --git a/packages/react-native/Libraries/ReactNative/AppRegistry.flow.js b/packages/react-native/Libraries/ReactNative/AppRegistry.flow.js index d766debf21f..419424df2cd 100644 --- a/packages/react-native/Libraries/ReactNative/AppRegistry.flow.js +++ b/packages/react-native/Libraries/ReactNative/AppRegistry.flow.js @@ -29,7 +29,7 @@ export type AppConfig = { ... }; export type AppParameters = { - initialProps: $ReadOnly<{[string]: mixed, ...}>, + initialProps: $ReadOnly<{[string]: unknown, ...}>, rootTag: RootTag, fabric?: boolean, }; diff --git a/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js b/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js index 119e2a9815c..0db6d341549 100644 --- a/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js +++ b/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js @@ -265,7 +265,7 @@ const UIManagerJS: UIManagerJSInterface & {[string]: any} = { ...UIManagerJSDeprecatedPlatformAPIs, ...UIManagerJSPlatformAPIs, ...UIManagerJSUnusedInNewArchAPIs, - getViewManagerConfig: (viewManagerName: string): mixed => { + getViewManagerConfig: (viewManagerName: string): unknown => { if (getUIManagerConstants) { const constants = getUIManagerConstantsCached(); if ( diff --git a/packages/react-native/Libraries/ReactNative/FabricUIManager.js b/packages/react-native/Libraries/ReactNative/FabricUIManager.js index 13b203f0abd..0e594c1ce71 100644 --- a/packages/react-native/Libraries/ReactNative/FabricUIManager.js +++ b/packages/react-native/Libraries/ReactNative/FabricUIManager.js @@ -71,7 +71,7 @@ export interface Spec { +dispatchCommand: ( node: Node, commandName: string, - args: Array, + args: Array, ) => void; +findNodeAtPoint: ( node: Node, diff --git a/packages/react-native/Libraries/ReactNative/PaperUIManager.js b/packages/react-native/Libraries/ReactNative/PaperUIManager.js index efb474be8cc..fadf460022f 100644 --- a/packages/react-native/Libraries/ReactNative/PaperUIManager.js +++ b/packages/react-native/Libraries/ReactNative/PaperUIManager.js @@ -121,7 +121,7 @@ function lazifyViewManagerConfig(viewName: string) { defineLazyObjectProperty(viewConfig, 'Constants', { get: () => { const viewManager = NativeModules[viewConfig.Manager]; - const constants: {[string]: mixed} = {}; + const constants: {[string]: unknown} = {}; viewManager && Object.keys(viewManager).forEach(key => { const value = viewManager[key]; diff --git a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js index 788f9bc6183..1e2c9b54a24 100644 --- a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +++ b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js @@ -27,7 +27,7 @@ import ReactNativeElement from '../../../src/private/webapis/dom/nodes/ReactNati import ReadOnlyText from '../../../src/private/webapis/dom/nodes/ReadOnlyText'; import * as RendererProxy from '../../ReactNative/RendererProxy'; -export opaque type PublicRootInstance = mixed; +export opaque type PublicRootInstance = unknown; export function createPublicRootInstance(rootTag: RootTag): PublicRootInstance { // $FlowExpectedError[incompatible-return] diff --git a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstanceUtils.js b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstanceUtils.js index 432803e9db6..27d402457fa 100644 --- a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstanceUtils.js +++ b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstanceUtils.js @@ -16,7 +16,7 @@ * In that case `nativeFabricUIManager` isn't defined and `ReactFabric` throws. */ -export function isPublicInstance(maybeInstance: mixed): boolean { +export function isPublicInstance(maybeInstance: unknown): boolean { return ( maybeInstance != null && // TODO: implement a better check when the instance is defined in the React Native repository. @@ -26,7 +26,7 @@ export function isPublicInstance(maybeInstance: mixed): boolean { ); } -function isLegacyFabricInstance(maybeInstance: mixed): boolean { +function isLegacyFabricInstance(maybeInstance: unknown): boolean { /* eslint-disable dot-notation */ return ( maybeInstance != null && diff --git a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js index 94fd08477f1..ee53d50e1ca 100644 --- a/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +++ b/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js @@ -34,7 +34,7 @@ const deepDifferOptions = { unsafelyIgnoreFunctions: true, }; -function defaultDiffer(prevProp: mixed, nextProp: mixed): boolean { +function defaultDiffer(prevProp: unknown, nextProp: unknown): boolean { if (typeof nextProp !== 'object' || nextProp === null) { // Scalars have already been checked for equality return true; diff --git a/packages/react-native/Libraries/ReactNative/RendererImplementation.js b/packages/react-native/Libraries/ReactNative/RendererImplementation.js index 770ac325093..f9e439a84cd 100644 --- a/packages/react-native/Libraries/ReactNative/RendererImplementation.js +++ b/packages/react-native/Libraries/ReactNative/RendererImplementation.js @@ -114,7 +114,7 @@ let cachedPaperDispatchCommand; export function dispatchCommand( handle: HostInstance, command: string, - args: Array, + args: Array, ): void { if (global.RN$Bridgeless === true) { // Note: this function has the same implementation in the legacy and new renderer. diff --git a/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js b/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js index 58594cc2320..26846a19c55 100644 --- a/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js +++ b/packages/react-native/Libraries/ReactNative/getNativeComponentAttributes.js @@ -69,7 +69,7 @@ function getNativeComponentAttributes(uiViewClassName: string): any { } } - const validAttributes: {[string]: mixed} = {}; + const validAttributes: {[string]: unknown} = {}; for (const key in nativeProps) { const typeName = nativeProps[key]; diff --git a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js index 5cbc624ecea..6365f1bee48 100644 --- a/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js +++ b/packages/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js @@ -39,7 +39,6 @@ import typeof Platform from '../Utilities/Platform'; // Expose these types to the React renderer export type { HostInstance as PublicInstance, - // These types are only necessary for Paper NativeMethods as LegacyPublicInstance, MeasureOnSuccessCallback, @@ -79,7 +78,7 @@ module.exports = { return require('../Utilities/differ/deepDiffer').default; }, get deepFreezeAndThrowOnMutationInDev(): deepFreezeAndThrowOnMutationInDev< - {...} | Array, + {...} | Array, > { return require('../Utilities/deepFreezeAndThrowOnMutationInDev').default; }, diff --git a/packages/react-native/Libraries/Settings/Settings.ios.js b/packages/react-native/Libraries/Settings/Settings.ios.js index 00f844976ad..e5fa348e90b 100644 --- a/packages/react-native/Libraries/Settings/Settings.ios.js +++ b/packages/react-native/Libraries/Settings/Settings.ios.js @@ -22,7 +22,7 @@ const Settings = { _settings: (NativeSettingsManager && NativeSettingsManager.getConstants().settings: any), - get(key: string): mixed { + get(key: string): unknown { // $FlowFixMe[object-this-reference] return this._settings[key]; }, diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetExports.js b/packages/react-native/Libraries/StyleSheet/StyleSheetExports.js index c44af3c920c..a2df7a02b67 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetExports.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetExports.js @@ -159,7 +159,7 @@ export default { */ setStyleAttributePreprocessor( property: string, - process: (nextProp: mixed) => mixed, + process: (nextProp: unknown) => unknown, ) { let value; diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js index 745362c134a..0ba483758fb 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js @@ -1104,22 +1104,20 @@ export type ____Styles_Internal = { // ____FlattenStyleProp_Helper should be considered internal. type FlattenDepthLimiter = [void, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; type ____FlattenStyleProp_Helper< - +TStyleProp: StyleProp, + +TStyleProp: StyleProp, Depth: $Values = 9, > = Depth extends 0 ? empty : TStyleProp extends null | void | false | '' - ? empty - : // When TStyleProp is an array, recurse with decremented Depth - TStyleProp extends $ReadOnlyArray + ? empty // When TStyleProp is an array, recurse with decremented Depth + : TStyleProp extends $ReadOnlyArray ? ____FlattenStyleProp_Helper< V, Depth extends number ? FlattenDepthLimiter[Depth] : 0, > : TStyleProp; -export type ____FlattenStyleProp_Internal<+TStyleProp: StyleProp> = - ____FlattenStyleProp_Helper extends empty - ? // $FlowFixMe[unclear-type] - any +export type ____FlattenStyleProp_Internal<+TStyleProp: StyleProp> = + ____FlattenStyleProp_Helper extends empty // $FlowFixMe[unclear-type] + ? any : ____FlattenStyleProp_Helper; diff --git a/packages/react-native/Libraries/StyleSheet/processFilter.js b/packages/react-native/Libraries/StyleSheet/processFilter.js index 3c15c1c9ada..66471f219d5 100644 --- a/packages/react-native/Libraries/StyleSheet/processFilter.js +++ b/packages/react-native/Libraries/StyleSheet/processFilter.js @@ -115,7 +115,7 @@ export default function processFilter( return result; } -function _getFilterAmount(filterName: string, filterArgs: mixed): ?number { +function _getFilterAmount(filterName: string, filterArgs: unknown): ?number { let filterArgAsNumber: number; let unit: string; if (typeof filterArgs === 'string') { diff --git a/packages/react-native/Libraries/Text/Text.js b/packages/react-native/Libraries/Text/Text.js index 1c45116674b..a9e4036b2e3 100644 --- a/packages/react-native/Libraries/Text/Text.js +++ b/packages/react-native/Libraries/Text/Text.js @@ -668,10 +668,10 @@ const TextImpl: component( TextImpl.displayName = 'Text'; type TextPressabilityProps = $ReadOnly<{ - onLongPress?: ?(event: GestureResponderEvent) => mixed, - onPress?: ?(event: GestureResponderEvent) => mixed, - onPressIn?: ?(event: GestureResponderEvent) => mixed, - onPressOut?: ?(event: GestureResponderEvent) => mixed, + onLongPress?: ?(event: GestureResponderEvent) => unknown, + onPress?: ?(event: GestureResponderEvent) => unknown, + onPressIn?: ?(event: GestureResponderEvent) => unknown, + onPressOut?: ?(event: GestureResponderEvent) => unknown, onResponderGrant?: ?(event: GestureResponderEvent) => void, onResponderMove?: ?(event: GestureResponderEvent) => void, onResponderRelease?: ?(event: GestureResponderEvent) => void, diff --git a/packages/react-native/Libraries/Text/TextNativeComponent.js b/packages/react-native/Libraries/Text/TextNativeComponent.js index 5cff8638c61..5e0fc03c4cb 100644 --- a/packages/react-native/Libraries/Text/TextNativeComponent.js +++ b/packages/react-native/Libraries/Text/TextNativeComponent.js @@ -21,7 +21,7 @@ export type NativeTextProps = $ReadOnly<{ ...TextProps, isHighlighted?: ?boolean, selectionColor?: ?ProcessedColorValue, - onClick?: ?(event: GestureResponderEvent) => mixed, + onClick?: ?(event: GestureResponderEvent) => unknown, // This is only needed for platforms that optimize text hit testing, e.g., // react-native-windows. It can be used to only hit test virtual text spans // that have pressable events attached to them. diff --git a/packages/react-native/Libraries/Text/TextProps.js b/packages/react-native/Libraries/Text/TextProps.js index f706f0ccb5c..4ca3c34e718 100644 --- a/packages/react-native/Libraries/Text/TextProps.js +++ b/packages/react-native/Libraries/Text/TextProps.js @@ -122,7 +122,7 @@ export type TextPropsAndroid = { }; type TextBaseProps = $ReadOnly<{ - onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed, + onAccessibilityAction?: ?(event: AccessibilityActionEvent) => unknown, /** * Whether fonts should scale to respect Text Size accessibility settings. @@ -204,7 +204,7 @@ type TextBaseProps = $ReadOnly<{ * * See https://reactnative.dev/docs/text#onlayout */ - onLayout?: ?(event: LayoutChangeEvent) => mixed, + onLayout?: ?(event: LayoutChangeEvent) => unknown, /** * This function is called on long press. @@ -212,7 +212,7 @@ type TextBaseProps = $ReadOnly<{ * * See https://reactnative.dev/docs/text#onlongpress */ - onLongPress?: ?(event: GestureResponderEvent) => mixed, + onLongPress?: ?(event: GestureResponderEvent) => unknown, /** * This function is called on press. @@ -220,9 +220,9 @@ type TextBaseProps = $ReadOnly<{ * * See https://reactnative.dev/docs/text#onpress */ - onPress?: ?(event: GestureResponderEvent) => mixed, - onPressIn?: ?(event: GestureResponderEvent) => mixed, - onPressOut?: ?(event: GestureResponderEvent) => mixed, + onPress?: ?(event: GestureResponderEvent) => unknown, + onPressIn?: ?(event: GestureResponderEvent) => unknown, + onPressOut?: ?(event: GestureResponderEvent) => unknown, onResponderGrant?: ?(event: GestureResponderEvent) => void, onResponderMove?: ?(event: GestureResponderEvent) => void, onResponderRelease?: ?(event: GestureResponderEvent) => void, @@ -230,7 +230,7 @@ type TextBaseProps = $ReadOnly<{ onResponderTerminationRequest?: ?() => boolean, onStartShouldSetResponder?: ?() => boolean, onMoveShouldSetResponder?: ?() => boolean, - onTextLayout?: ?(event: TextLayoutEvent) => mixed, + onTextLayout?: ?(event: TextLayoutEvent) => unknown, /** * Defines how far your touch may move off of the button, before diff --git a/packages/react-native/Libraries/Types/CodegenTypes.js b/packages/react-native/Libraries/Types/CodegenTypes.js index f6f88789e73..289659521b4 100644 --- a/packages/react-native/Libraries/Types/CodegenTypes.js +++ b/packages/react-native/Libraries/Types/CodegenTypes.js @@ -31,7 +31,7 @@ export type Float = number; export type Int32 = number; /* $FlowFixMe[unclear-type] Object is forbidden in strict mode */ export type UnsafeObject = Object; -export type UnsafeMixed = mixed; +export type UnsafeMixed = unknown; type DefaultTypes = number | boolean | string | $ReadOnlyArray; // Default handling, ignore the unused value diff --git a/packages/react-native/Libraries/Types/ReactDevToolsTypes.js b/packages/react-native/Libraries/Types/ReactDevToolsTypes.js index effa843e2d6..74baa27ff1d 100644 --- a/packages/react-native/Libraries/Types/ReactDevToolsTypes.js +++ b/packages/react-native/Libraries/Types/ReactDevToolsTypes.js @@ -32,7 +32,7 @@ export type ReactDevToolsAgentEvents = { }; export type ReactDevToolsAgent = { - selectNode(node: mixed): void, + selectNode(node: unknown): void, stopInspectingNative(value: boolean): void, addListener>( event: Event, @@ -48,6 +48,6 @@ export type ReactDevToolsGlobalHook = { on: (eventName: string, (agent: ReactDevToolsAgent) => void) => void, off: (eventName: string, (agent: ReactDevToolsAgent) => void) => void, reactDevtoolsAgent?: ReactDevToolsAgent, - resolveRNStyle?: mixed, + resolveRNStyle?: unknown, nativeStyleEditorValidAttributes?: Array, }; diff --git a/packages/react-native/Libraries/Utilities/DevSettings.js b/packages/react-native/Libraries/Utilities/DevSettings.js index 6070f32a906..8b7494264df 100644 --- a/packages/react-native/Libraries/Utilities/DevSettings.js +++ b/packages/react-native/Libraries/Utilities/DevSettings.js @@ -24,7 +24,7 @@ let DevSettings: { * @param title - The title of the menu item. Is internally used as id and should therefore be unique. * @param handler - The callback invoked when pressing the menu item. */ - addMenuItem(title: string, handler: () => mixed): void, + addMenuItem(title: string, handler: () => unknown): void, /** * Reload the application. * @@ -33,7 +33,7 @@ let DevSettings: { reload(reason?: string): void, onFastRefresh(): void, } = { - addMenuItem(title: string, handler: () => mixed): void {}, + addMenuItem(title: string, handler: () => unknown): void {}, reload(reason?: string): void {}, onFastRefresh(): void {}, }; @@ -51,7 +51,7 @@ if (__DEV__) { const subscriptions = new Map(); DevSettings = { - addMenuItem(title: string, handler: () => mixed): void { + addMenuItem(title: string, handler: () => unknown): void { // Make sure items are not added multiple times. This can // happen when hot reloading the module that registers the // menu items. The title is used as the id which means we diff --git a/packages/react-native/Libraries/Utilities/HMRClient.js b/packages/react-native/Libraries/Utilities/HMRClient.js index 40245e5a9fe..11303fe5391 100644 --- a/packages/react-native/Libraries/Utilities/HMRClient.js +++ b/packages/react-native/Libraries/Utilities/HMRClient.js @@ -26,7 +26,7 @@ let hmrUnavailableReason: string | null = null; let hmrOrigin: string | null = null; let currentCompileErrorMessage: string | null = null; let didConnect: boolean = false; -let pendingLogs: Array<[LogLevel, $ReadOnlyArray]> = []; +let pendingLogs: Array<[LogLevel, $ReadOnlyArray]> = []; type LogLevel = | 'trace' @@ -43,7 +43,7 @@ export type HMRClientNativeInterface = { enable(): void, disable(): void, registerBundle(requestUrl: string): void, - log(level: LogLevel, data: $ReadOnlyArray): void, + log(level: LogLevel, data: $ReadOnlyArray): void, setup( platform: string, bundleEntry: string, @@ -113,7 +113,7 @@ const HMRClient: HMRClientNativeInterface = { registerBundleEntryPoints(hmrClient); }, - log(level: LogLevel, data: $ReadOnlyArray) { + log(level: LogLevel, data: $ReadOnlyArray) { if (!hmrClient) { // Catch a reasonable number of early logs // in case hmrClient gets initialized later. diff --git a/packages/react-native/Libraries/Utilities/RCTLog.js b/packages/react-native/Libraries/Utilities/RCTLog.js index 8b71fd4f661..8692aa97918 100644 --- a/packages/react-native/Libraries/Utilities/RCTLog.js +++ b/packages/react-native/Libraries/Utilities/RCTLog.js @@ -20,11 +20,11 @@ const levelsMap = { fatal: 'error', }; -let warningHandler: ?(...Array) => void = null; +let warningHandler: ?(...Array) => void = null; const RCTLog = { // level one of log, info, warn, error, mustfix - logIfNoNativeHook(level: string, ...args: Array): void { + logIfNoNativeHook(level: string, ...args: Array): void { // We already printed in the native console, so only log here if using a js debugger if (typeof global.nativeLoggingHook === 'undefined') { RCTLog.logToConsole(level, ...args); @@ -37,7 +37,7 @@ const RCTLog = { }, // Log to console regardless of nativeLoggingHook - logToConsole(level: string, ...args: Array): void { + logToConsole(level: string, ...args: Array): void { // $FlowFixMe[invalid-computed-prop] const logFn = levelsMap[level]; invariant( diff --git a/packages/react-native/Libraries/Utilities/ReactNativeTestTools.js b/packages/react-native/Libraries/Utilities/ReactNativeTestTools.js index c49d47cec85..88765dc208d 100644 --- a/packages/react-native/Libraries/Utilities/ReactNativeTestTools.js +++ b/packages/react-native/Libraries/Utilities/ReactNativeTestTools.js @@ -124,7 +124,7 @@ function expectNoConsoleError() { async function expectRendersMatchingSnapshot( name: string, ComponentProvider: () => React.MixedElement, - unmockComponent: () => mixed, + unmockComponent: () => unknown, ) { let instance; diff --git a/packages/react-native/Libraries/Utilities/SceneTracker.js b/packages/react-native/Libraries/Utilities/SceneTracker.js index a0b3ca6e430..2cedf5df6f0 100644 --- a/packages/react-native/Libraries/Utilities/SceneTracker.js +++ b/packages/react-native/Libraries/Utilities/SceneTracker.js @@ -10,7 +10,7 @@ 'use strict'; -export type Scene = {name: string, [string]: mixed, ...}; +export type Scene = {name: string, [string]: unknown, ...}; let _listeners: Array<(scene: Scene) => void> = []; diff --git a/packages/react-native/Libraries/Utilities/codegenNativeCommands.js b/packages/react-native/Libraries/Utilities/codegenNativeCommands.js index 6f9c0a115a1..67ae5f86542 100644 --- a/packages/react-native/Libraries/Utilities/codegenNativeCommands.js +++ b/packages/react-native/Libraries/Utilities/codegenNativeCommands.js @@ -17,7 +17,7 @@ type NativeCommandsOptions = $ReadOnly<{ function codegenNativeCommands( options: NativeCommandsOptions<$Keys>, ): T { - const commandObj: {[$Keys]: (...$ReadOnlyArray) => void} = {}; + const commandObj: {[$Keys]: (...$ReadOnlyArray) => void} = {}; options.supportedCommands.forEach(command => { // $FlowFixMe[missing-local-annot] diff --git a/packages/react-native/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js b/packages/react-native/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js index 83b79a17182..44577bc19d4 100644 --- a/packages/react-native/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +++ b/packages/react-native/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js @@ -27,7 +27,7 @@ * Freezing the object and adding the throw mechanism is expensive and will * only be used in DEV. */ -function deepFreezeAndThrowOnMutationInDev>( +function deepFreezeAndThrowOnMutationInDev>( object: T, ): T { if (__DEV__) { @@ -43,7 +43,7 @@ function deepFreezeAndThrowOnMutationInDev>( } // $FlowFixMe[not-an-object] `object` can be an array, but Object.keys works with arrays too - const keys = Object.keys((object: {...} | Array)); + const keys = Object.keys((object: {...} | Array)); // $FlowFixMe[method-unbinding] added when improving typing for this parameters const hasOwnProperty = Object.prototype.hasOwnProperty; @@ -85,7 +85,7 @@ function throwOnImmutableMutation(key: empty, value) { ); } -function identity(value: mixed) { +function identity(value: unknown) { return value; } diff --git a/packages/react-native/Libraries/Utilities/logError.js b/packages/react-native/Libraries/Utilities/logError.js index bbe3f880936..70d8b7dc3c9 100644 --- a/packages/react-native/Libraries/Utilities/logError.js +++ b/packages/react-native/Libraries/Utilities/logError.js @@ -15,7 +15,7 @@ * `console.error` as a failure callback - it's not properly bound. If passes an * `Error` object, it will print the message and stack. */ -const logError = function (...args: $ReadOnlyArray) { +const logError = function (...args: $ReadOnlyArray) { if (args.length === 1 && args[0] instanceof Error) { const err = args[0]; console.error('Error: "' + err.message + '". Stack:\n' + err.stack); diff --git a/packages/react-native/Libraries/Utilities/stringifySafe.js b/packages/react-native/Libraries/Utilities/stringifySafe.js index b3ac681a305..e23e96eb29f 100644 --- a/packages/react-native/Libraries/Utilities/stringifySafe.js +++ b/packages/react-native/Libraries/Utilities/stringifySafe.js @@ -19,17 +19,17 @@ export function createStringifySafeWithLimits(limits: { maxStringLimit?: number, maxArrayLimit?: number, maxObjectKeysLimit?: number, -}): mixed => string { +}): unknown => string { const { maxDepth = Number.POSITIVE_INFINITY, maxStringLimit = Number.POSITIVE_INFINITY, maxArrayLimit = Number.POSITIVE_INFINITY, maxObjectKeysLimit = Number.POSITIVE_INFINITY, } = limits; - const stack: Array = []; + const stack: Array = []; /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by * Flow's LTI update could not be added via codemod */ - function replacer(key: string, value: mixed): mixed { + function replacer(key: string, value: unknown): unknown { while (stack.length && this !== stack[0]) { stack.shift(); } @@ -45,7 +45,7 @@ export function createStringifySafeWithLimits(limits: { return value; } - let retval: mixed = value; + let retval: unknown = value; if (Array.isArray(value)) { if (stack.length >= maxDepth) { retval = `[ ... array with ${value.length} values ... ]`; @@ -64,7 +64,7 @@ export function createStringifySafeWithLimits(limits: { retval = `{ ... object with ${keys.length} keys ... }`; } else if (keys.length > maxObjectKeysLimit) { // Return a sample of the keys. - retval = ({}: {[string]: mixed}); + retval = ({}: {[string]: unknown}); for (let k of keys.slice(0, maxObjectKeysLimit)) { retval[k] = value[k]; } @@ -76,7 +76,7 @@ export function createStringifySafeWithLimits(limits: { return retval; } - return function stringifySafe(arg: mixed): string { + return function stringifySafe(arg: unknown): string { if (arg === undefined) { return 'undefined'; } else if (arg === null) { @@ -111,7 +111,7 @@ export function createStringifySafeWithLimits(limits: { }; } -const stringifySafe: mixed => string = createStringifySafeWithLimits({ +const stringifySafe: unknown => string = createStringifySafeWithLimits({ maxDepth: 10, maxStringLimit: 100, maxArrayLimit: 50, diff --git a/packages/react-native/Libraries/Utilities/useRefEffect.js b/packages/react-native/Libraries/Utilities/useRefEffect.js index 26446cbf536..8f9ed0b3842 100644 --- a/packages/react-native/Libraries/Utilities/useRefEffect.js +++ b/packages/react-native/Libraries/Utilities/useRefEffect.js @@ -10,7 +10,7 @@ import {useCallback, useRef} from 'react'; -type CallbackRef = T => mixed; +type CallbackRef = T => unknown; /** * Constructs a callback ref that provides similar semantics as `useEffect`. The diff --git a/packages/react-native/Libraries/vendor/core/ErrorUtils.js b/packages/react-native/Libraries/vendor/core/ErrorUtils.js index db7762d580c..7d6a0d8f677 100644 --- a/packages/react-native/Libraries/vendor/core/ErrorUtils.js +++ b/packages/react-native/Libraries/vendor/core/ErrorUtils.js @@ -9,30 +9,30 @@ */ // From @react-native/js-polyfills -type ErrorHandler = (error: mixed, isFatal: boolean) => void; -type Fn, Return> = (...Args) => Return; +type ErrorHandler = (error: unknown, isFatal: boolean) => void; +type Fn, Return> = (...Args) => Return; export type ErrorUtils = { - applyWithGuard, TOut>( + applyWithGuard, TOut>( fun: Fn, - context?: mixed, + context?: unknown, args?: ?TArgs, unused_onError?: null, unused_name?: ?string, ): ?TOut, - applyWithGuardIfNeeded, TOut>( + applyWithGuardIfNeeded, TOut>( fun: Fn, - context?: mixed, + context?: unknown, args?: ?TArgs, ): ?TOut, getGlobalHandler(): ErrorHandler, - guard, TOut>( + guard, TOut>( fun: Fn, name?: ?string, - context?: mixed, + context?: unknown, ): ?(...TArgs) => ?TOut, inGuard(): boolean, - reportError(error: mixed): void, - reportFatalError(error: mixed): void, + reportError(error: unknown): void, + reportFatalError(error: unknown): void, setGlobalHandler(fun: ErrorHandler): void, }; diff --git a/packages/react-native/Libraries/vendor/emitter/EventEmitter.js b/packages/react-native/Libraries/vendor/emitter/EventEmitter.js index 236f963dc08..97f1713ca17 100644 --- a/packages/react-native/Libraries/vendor/emitter/EventEmitter.js +++ b/packages/react-native/Libraries/vendor/emitter/EventEmitter.js @@ -20,8 +20,8 @@ export interface IEventEmitter< > { addListener>( eventType: TEvent, - listener: (...args: TEventToArgsMap[TEvent]) => mixed, - context?: mixed, + listener: (...args: TEventToArgsMap[TEvent]) => unknown, + context?: unknown, ): EventSubscription; emit>( @@ -35,8 +35,8 @@ export interface IEventEmitter< } interface Registration { - +context: mixed; - +listener: (...args: TArgs) => mixed; + +context: unknown; + +listener: (...args: TArgs) => unknown; +remove: () => void; } @@ -85,8 +85,8 @@ export default class EventEmitter< */ addListener>( eventType: TEvent, - listener: (...args: TEventToArgsMap[TEvent]) => mixed, - context: mixed, + listener: (...args: TEventToArgsMap[TEvent]) => unknown, + context: unknown, ): EventSubscription { if (typeof listener !== 'function') { throw new TypeError( diff --git a/packages/react-native/Libraries/vendor/emitter/__tests__/EventEmitter-test.js b/packages/react-native/Libraries/vendor/emitter/__tests__/EventEmitter-test.js index 4cb184d840e..c65c5b74ecd 100644 --- a/packages/react-native/Libraries/vendor/emitter/__tests__/EventEmitter-test.js +++ b/packages/react-native/Libraries/vendor/emitter/__tests__/EventEmitter-test.js @@ -106,27 +106,27 @@ describe('listeners', () => { }).not.toThrow(); expect(() => { - // $FlowExpectedError[incompatible-type] + // $FlowExpectedError[incompatible-type] emitter.addListener('A', null); }).toThrow(); expect(() => { - // $FlowExpectedError[incompatible-type] + // $FlowExpectedError[incompatible-type] emitter.addListener('A', undefined); }).toThrow(); expect(() => { - // $FlowExpectedError[incompatible-type] + // $FlowExpectedError[incompatible-type] emitter.addListener('A', 'abc'); }).toThrow(); expect(() => { - // $FlowExpectedError[incompatible-type] + // $FlowExpectedError[incompatible-type] emitter.addListener('A', 123); }).toThrow(); expect(() => { - // $FlowExpectedError[incompatible-type] + // $FlowExpectedError[incompatible-type] emitter.addListener('A', 123); }).toThrow(); }); @@ -155,7 +155,7 @@ describe('arguments and context', () => { const context = {}; let that; - const listener = jest.fn(function (this: mixed) { + const listener = jest.fn(function (this: unknown) { that = this; }); emitter.addListener('A', listener, context); @@ -341,7 +341,7 @@ describe('event emission', () => { const listenerA = jest.fn(() => { results.push('A'); }); - const listenerB: JestMockFn, void> = jest.fn(() => { + const listenerB: JestMockFn, void> = jest.fn(() => { results.push('B'); subscriptionB.remove(); }); diff --git a/packages/react-native/flow/HermesInternalType.js b/packages/react-native/flow/HermesInternalType.js index 134adf9c2cb..3850908e27f 100644 --- a/packages/react-native/flow/HermesInternalType.js +++ b/packages/react-native/flow/HermesInternalType.js @@ -59,7 +59,7 @@ declare type $HermesInternalType = { +getRuntimeProperties?: () => { 'OSS Release Version': string, Build: string, - [string]: mixed, + [string]: unknown, }, /** @@ -93,10 +93,10 @@ declare type $HermesInternalType = { */ +enablePromiseRejectionTracker?: ( options: ?{ - whitelist?: ?Array, + whitelist?: ?Array, allRejections?: ?boolean, - onUnhandled?: ?(number, mixed) => void, - onHandled?: ?(number, mixed) => void, + onUnhandled?: ?(number, unknown) => void, + onHandled?: ?(number, unknown) => void, }, ) => void, @@ -108,7 +108,7 @@ declare type $HermesInternalType = { /** * Enqueue a JavaScript callback function as a Job into the engine Job queue. */ - +enqueueJob?: >( - jobCallback: (...args: TArguments) => mixed, + +enqueueJob?: >( + jobCallback: (...args: TArguments) => unknown, ) => void, }; diff --git a/packages/react-native/flow/bom.js.flow b/packages/react-native/flow/bom.js.flow index fe78011fa4c..ab3b11b9bd2 100644 --- a/packages/react-native/flow/bom.js.flow +++ b/packages/react-native/flow/bom.js.flow @@ -32,31 +32,31 @@ declare interface ConsoleTask { // $FlowExpectedError[libdef-override] Flow core definitions are incomplete. declare var console: { // Logging - log(...data: $ReadOnlyArray): void, - trace(...data: $ReadOnlyArray): void, - debug(...data: $ReadOnlyArray): void, - info(...data: $ReadOnlyArray): void, - warn(...data: $ReadOnlyArray): void, - error(...data: $ReadOnlyArray): void, + log(...data: $ReadOnlyArray): void, + trace(...data: $ReadOnlyArray): void, + debug(...data: $ReadOnlyArray): void, + info(...data: $ReadOnlyArray): void, + warn(...data: $ReadOnlyArray): void, + error(...data: $ReadOnlyArray): void, // Grouping - group(...data: $ReadOnlyArray): void, - groupCollapsed(...data: $ReadOnlyArray): void, + group(...data: $ReadOnlyArray): void, + groupCollapsed(...data: $ReadOnlyArray): void, groupEnd(): void, // Printing table( tabularData: - | $ReadOnly<{[key: string]: mixed, ...}> - | $ReadOnlyArray<$ReadOnly<{[key: string]: mixed, ...}>> - | $ReadOnlyArray<$ReadOnlyArray>, + | $ReadOnly<{[key: string]: unknown, ...}> + | $ReadOnlyArray<$ReadOnly<{[key: string]: unknown, ...}>> + | $ReadOnlyArray<$ReadOnlyArray>, ): void, - dir(...data: $ReadOnlyArray): void, - dirxml(...data: $ReadOnlyArray): void, + dir(...data: $ReadOnlyArray): void, + dirxml(...data: $ReadOnlyArray): void, clear(): void, // Utilities - assert(condition: mixed, ...data: $ReadOnlyArray): void, + assert(condition: unknown, ...data: $ReadOnlyArray): void, // Profiling profile(name?: string): void, @@ -76,7 +76,7 @@ declare var console: { trackName?: string, trackGroup?: string, color?: DevToolsColor, - detail?: {[string]: mixed}, + detail?: {[string]: unknown}, ): void, // Stack tagging @@ -114,12 +114,12 @@ declare class PerformanceEntry { // https://w3c.github.io/user-timing/#performancemark declare class PerformanceMark extends PerformanceEntry { constructor(name: string, markOptions?: PerformanceMarkOptions): void; - +detail: mixed; + +detail: unknown; } // https://w3c.github.io/user-timing/#performancemeasure declare class PerformanceMeasure extends PerformanceEntry { - +detail: mixed; + +detail: unknown; } // https://w3c.github.io/server-timing/#the-performanceservertiming-interface @@ -177,12 +177,12 @@ declare class PerformanceLongTaskTiming extends PerformanceEntry { // https://www.w3.org/TR/user-timing/#extensions-performance-interface declare type PerformanceMarkOptions = { - detail?: mixed, + detail?: unknown, startTime?: number, }; declare type PerformanceMeasureOptions = { - detail?: mixed, + detail?: unknown, duration?: number, end?: number | string, start?: number | string, @@ -249,7 +249,7 @@ declare class PerformanceObserver { callback: ( entries: PerformanceObserverEntryList, observer: PerformanceObserver, - ) => mixed, + ) => unknown, ): void; disconnect(): void; @@ -345,10 +345,10 @@ declare class WebSocket extends EventTarget { CONNECTING: 0; constructor(url: string, protocols?: string | Array): void; extensions: string; - onclose: (ev: CloseEvent) => mixed; - onerror: (ev: $FlowFixMe) => mixed; - onmessage: (ev: MessageEvent) => mixed; - onopen: (ev: $FlowFixMe) => mixed; + onclose: (ev: CloseEvent) => unknown; + onerror: (ev: $FlowFixMe) => unknown; + onmessage: (ev: MessageEvent) => unknown; + onopen: (ev: $FlowFixMe) => unknown; static OPEN: 1; OPEN: 1; protocol: string; @@ -378,7 +378,7 @@ declare class XMLHttpRequest extends EventTarget { onloadend: ProgressEventHandler; onloadstart: ProgressEventHandler; onprogress: ProgressEventHandler; - onreadystatechange: (ev: $FlowFixMe) => mixed; + onreadystatechange: (ev: $FlowFixMe) => unknown; ontimeout: ProgressEventHandler; open( method: string, @@ -441,7 +441,7 @@ declare class Headers { value: string, name: string, headers: Headers, - ) => mixed, + ) => unknown, thisArg: This, ): void; get(name: string): null | string; @@ -471,7 +471,7 @@ declare class URLSearchParams { value: string, name: string, params: URLSearchParams, - ) => mixed, + ) => unknown, thisArg: This, ): void; get(name: string): null | string; @@ -611,7 +611,7 @@ declare class AbortController { declare class AbortSignal extends EventTarget { abort(reason?: $FlowFixMe): AbortSignal; +aborted: boolean; - onabort: (event: Event) => mixed; + onabort: (event: Event) => unknown; +reason: $FlowFixMe; throwIfAborted(): void; timeout(time: number): AbortSignal; diff --git a/packages/react-native/flow/cssom.js.flow b/packages/react-native/flow/cssom.js.flow index 2ef23892852..af1bd371362 100644 --- a/packages/react-native/flow/cssom.js.flow +++ b/packages/react-native/flow/cssom.js.flow @@ -524,9 +524,9 @@ declare class Animation extends EventTarget { finish(): void; +finished: Promise; id: string; - oncancel: ?(ev: AnimationPlaybackEvent) => mixed; - onfinish: ?(ev: AnimationPlaybackEvent) => mixed; - onremove: ?(ev: AnimationPlaybackEvent) => mixed; + oncancel: ?(ev: AnimationPlaybackEvent) => unknown; + onfinish: ?(ev: AnimationPlaybackEvent) => unknown; + onremove: ?(ev: AnimationPlaybackEvent) => unknown; pause(): void; +pending: boolean; persist(): void; diff --git a/packages/react-native/flow/dom.js.flow b/packages/react-native/flow/dom.js.flow index c3c0fdff6c6..2f3dd185513 100644 --- a/packages/react-native/flow/dom.js.flow +++ b/packages/react-native/flow/dom.js.flow @@ -101,7 +101,7 @@ declare class DataTransferItemList { declare class DataTransferItem { kind: string; // readonly type: string; // readonly - getAsString(_callback: ?(data: string) => mixed): void; + getAsString(_callback: ?(data: string) => unknown): void; getAsFile(): ?File; /* * This is not supported by all browsers, please have a fallback plan for it. @@ -168,79 +168,79 @@ declare type ScrollToOptions = { ... }; -type EventHandler = (event: Event) => mixed; +type EventHandler = (event: Event) => unknown; type EventListener = {handleEvent: EventHandler, ...} | EventHandler; -type MouseEventHandler = (event: MouseEvent) => mixed; +type MouseEventHandler = (event: MouseEvent) => unknown; type MouseEventListener = | {handleEvent: MouseEventHandler, ...} | MouseEventHandler; -type FocusEventHandler = (event: FocusEvent) => mixed; +type FocusEventHandler = (event: FocusEvent) => unknown; type FocusEventListener = | {handleEvent: FocusEventHandler, ...} | FocusEventHandler; -type KeyboardEventHandler = (event: KeyboardEvent) => mixed; +type KeyboardEventHandler = (event: KeyboardEvent) => unknown; type KeyboardEventListener = | {handleEvent: KeyboardEventHandler, ...} | KeyboardEventHandler; -type InputEventHandler = (event: InputEvent) => mixed; +type InputEventHandler = (event: InputEvent) => unknown; type InputEventListener = | {handleEvent: InputEventHandler, ...} | InputEventHandler; -type TouchEventHandler = (event: TouchEvent) => mixed; +type TouchEventHandler = (event: TouchEvent) => unknown; type TouchEventListener = | {handleEvent: TouchEventHandler, ...} | TouchEventHandler; -type WheelEventHandler = (event: WheelEvent) => mixed; +type WheelEventHandler = (event: WheelEvent) => unknown; type WheelEventListener = | {handleEvent: WheelEventHandler, ...} | WheelEventHandler; -type AbortProgressEventHandler = (event: ProgressEvent) => mixed; +type AbortProgressEventHandler = (event: ProgressEvent) => unknown; type AbortProgressEventListener = | {handleEvent: AbortProgressEventHandler, ...} | AbortProgressEventHandler; -type ProgressEventHandler = (event: ProgressEvent) => mixed; +type ProgressEventHandler = (event: ProgressEvent) => unknown; type ProgressEventListener = | {handleEvent: ProgressEventHandler, ...} | ProgressEventHandler; -type DragEventHandler = (event: DragEvent) => mixed; +type DragEventHandler = (event: DragEvent) => unknown; type DragEventListener = | {handleEvent: DragEventHandler, ...} | DragEventHandler; -type PointerEventHandler = (event: PointerEvent) => mixed; +type PointerEventHandler = (event: PointerEvent) => unknown; type PointerEventListener = | {handleEvent: PointerEventHandler, ...} | PointerEventHandler; -type AnimationEventHandler = (event: AnimationEvent) => mixed; +type AnimationEventHandler = (event: AnimationEvent) => unknown; type AnimationEventListener = | {handleEvent: AnimationEventHandler, ...} | AnimationEventHandler; -type ClipboardEventHandler = (event: ClipboardEvent) => mixed; +type ClipboardEventHandler = (event: ClipboardEvent) => unknown; type ClipboardEventListener = | {handleEvent: ClipboardEventHandler, ...} | ClipboardEventHandler; -type TransitionEventHandler = (event: TransitionEvent) => mixed; +type TransitionEventHandler = (event: TransitionEvent) => unknown; type TransitionEventListener = | {handleEvent: TransitionEventHandler, ...} | TransitionEventHandler; -type MessageEventHandler = (event: MessageEvent) => mixed; +type MessageEventHandler = (event: MessageEvent) => unknown; type MessageEventListener = | {handleEvent: MessageEventHandler, ...} | MessageEventHandler; -type BeforeUnloadEventHandler = (event: BeforeUnloadEvent) => mixed; +type BeforeUnloadEventHandler = (event: BeforeUnloadEvent) => unknown; type BeforeUnloadEventListener = | {handleEvent: BeforeUnloadEventHandler, ...} | BeforeUnloadEventHandler; -type StorageEventHandler = (event: StorageEvent) => mixed; +type StorageEventHandler = (event: StorageEvent) => unknown; type StorageEventListener = | {handleEvent: StorageEventHandler, ...} | StorageEventHandler; type SecurityPolicyViolationEventHandler = ( event: SecurityPolicyViolationEvent, -) => mixed; +) => unknown; type SecurityPolicyViolationEventListener = | {handleEvent: SecurityPolicyViolationEventHandler, ...} | SecurityPolicyViolationEventHandler; -type USBConnectionEventHandler = (event: USBConnectionEvent) => mixed; +type USBConnectionEventHandler = (event: USBConnectionEvent) => unknown; type USBConnectionEventListener = | {handleEvent: USBConnectionEventHandler, ...} | USBConnectionEventHandler; @@ -917,7 +917,7 @@ declare class PageTransitionEvent extends Event { // and // https://html.spec.whatwg.org/multipage/comms.html#the-messageevent-interfaces declare class MessageEvent extends Event { - data: mixed; + data: unknown; origin: string; lastEventId: string; source: WindowProxy; @@ -1158,7 +1158,7 @@ declare class BroadcastChannel extends EventTarget { onmessageerror: ?(event: MessageEvent) => void; constructor(name: string): void; - postMessage(msg: mixed): void; + postMessage(msg: unknown): void; close(): void; } @@ -1394,30 +1394,30 @@ type ElementRegistrationOptions = { +prototype?: { // from https://www.w3.org/TR/custom-elements/#types-of-callbacks // See also https://github.com/w3c/webcomponents/ - +createdCallback?: () => mixed, - +attachedCallback?: () => mixed, - +detachedCallback?: () => mixed, + +createdCallback?: () => unknown, + +attachedCallback?: () => unknown, + +detachedCallback?: () => unknown, +attributeChangedCallback?: (( // attribute is set attributeLocalName: string, oldAttributeValue: null, newAttributeValue: string, attributeNamespace: string, - ) => mixed) & + ) => unknown) & // attribute is changed (( attributeLocalName: string, oldAttributeValue: string, newAttributeValue: string, attributeNamespace: string, - ) => mixed) & + ) => unknown) & // attribute is removed (( attributeLocalName: string, oldAttributeValue: string, newAttributeValue: null, attributeNamespace: string, - ) => mixed), + ) => unknown), ... }, +extends?: string, @@ -6245,13 +6245,13 @@ declare class Notification extends EventTarget { constructor(title: string, options?: NotificationOptions): void; static +permission: NotificationPermission; static requestPermission( - callback?: (perm: NotificationPermission) => mixed, + callback?: (perm: NotificationPermission) => unknown, ): Promise; static +maxActions: number; - onclick: ?(evt: Event) => mixed; - onclose: ?(evt: Event) => mixed; - onerror: ?(evt: Event) => mixed; - onshow: ?(evt: Event) => mixed; + onclick: ?(evt: Event) => unknown; + onclose: ?(evt: Event) => unknown; + onerror: ?(evt: Event) => unknown; + onshow: ?(evt: Event) => unknown; +title: string; +dir: NotificationDirection; +lang: string; diff --git a/packages/react-native/jest/mock.js b/packages/react-native/jest/mock.js index 78f56bfc470..05eb87e543f 100644 --- a/packages/react-native/jest/mock.js +++ b/packages/react-native/jest/mock.js @@ -16,7 +16,7 @@ * If `factoryRef` is provided, it is expected to reference a module that * exports the same type signature as the module referenced by `moduleRef`. */ -export default function mock>( +export default function mock>( moduleRef: TModuleRef, factoryRef?: NoInfer, ): void { @@ -33,7 +33,7 @@ export default function mock>( } } -function deref(ref: $Flow$ModuleRef): string { +function deref(ref: $Flow$ModuleRef): string { // $FlowFixMe[incompatible-type] return (ref as string).substring(2); } diff --git a/packages/react-native/jest/setup.js b/packages/react-native/jest/setup.js index 580181701bd..e22fe06d5c7 100644 --- a/packages/react-native/jest/setup.js +++ b/packages/react-native/jest/setup.js @@ -51,7 +51,7 @@ Object.defineProperties(global, { regeneratorRuntime: { configurable: true, enumerable: true, - value: jest.requireActual('regenerator-runtime/runtime'), + value: jest.requireActual('regenerator-runtime/runtime'), writable: true, }, requestAnimationFrame: { diff --git a/packages/react-native/src/private/__tests__/utilities/ShadowNodeReferenceCounter.js b/packages/react-native/src/private/__tests__/utilities/ShadowNodeReferenceCounter.js index 325b18f285c..8e3ef6e11b3 100644 --- a/packages/react-native/src/private/__tests__/utilities/ShadowNodeReferenceCounter.js +++ b/packages/react-native/src/private/__tests__/utilities/ShadowNodeReferenceCounter.js @@ -34,7 +34,7 @@ function createExpirationChecker( export function createShadowNodeReferenceCountingRef(): [ () => number, - React.RefSetter, + React.RefSetter, ] { let getReferenceCount: ?() => number; @@ -45,7 +45,7 @@ export function createShadowNodeReferenceCountingRef(): [ return getReferenceCount(); } - function ref(instance: mixed | null) { + function ref(instance: unknown | null) { if (instance == null) { return; } diff --git a/packages/react-native/src/private/__tests__/utilities/ShadowNodeRevisionGetter.js b/packages/react-native/src/private/__tests__/utilities/ShadowNodeRevisionGetter.js index 8d251da8af1..0e0944b62ac 100644 --- a/packages/react-native/src/private/__tests__/utilities/ShadowNodeRevisionGetter.js +++ b/packages/react-native/src/private/__tests__/utilities/ShadowNodeRevisionGetter.js @@ -23,7 +23,7 @@ function createShadowNodeRevisionGetter( export function createShadowNodeReferenceGetterRef(): [ () => ?number, - React.RefSetter, + React.RefSetter, ] { let getRevision: ?() => ?number; @@ -34,7 +34,7 @@ export function createShadowNodeReferenceGetterRef(): [ return getRevision(); } - function ref(instance: mixed | null) { + function ref(instance: unknown | null) { if (instance == null) { return; } diff --git a/packages/react-native/src/private/__tests__/utilities/ensureInstance.js b/packages/react-native/src/private/__tests__/utilities/ensureInstance.js index b5bec88dda2..aee2cb2b2fb 100644 --- a/packages/react-native/src/private/__tests__/utilities/ensureInstance.js +++ b/packages/react-native/src/private/__tests__/utilities/ensureInstance.js @@ -8,7 +8,7 @@ * @format */ -export default function ensureInstance(value: mixed, Class: Class): T { +export default function ensureInstance(value: unknown, Class: Class): T { if (!(value instanceof Class)) { // $FlowFixMe[incompatible-use] const className = Class.name; diff --git a/packages/react-native/src/private/animated/NativeAnimatedHelper.js b/packages/react-native/src/private/animated/NativeAnimatedHelper.js index 54437f9577b..a115addaa2f 100644 --- a/packages/react-native/src/private/animated/NativeAnimatedHelper.js +++ b/packages/react-native/src/private/animated/NativeAnimatedHelper.js @@ -51,7 +51,7 @@ let nativeEventEmitter; const waitingForQueuedOperations = new Set(); let queueOperations = false; const queue: Array<() => void> = []; -const singleOpQueue: Array = []; +const singleOpQueue: Array = []; const isSingleOpBatching = Platform.OS === 'android' && @@ -103,7 +103,7 @@ function createNativeOperations(): NonNullable { methodNames.push('connectAnimatedNodeToShadowNodeFamily'); } const nativeOperations: { - [$Values]: (...$ReadOnlyArray) => void, + [$Values]: (...$ReadOnlyArray) => void, } = {}; if (isSingleOpBatching) { for (let ii = 0, length = methodNames.length; ii < length; ii++) { @@ -406,7 +406,7 @@ function assertNativeAnimatedModule(): void { let _warnedMissingNativeAnimated = false; function shouldUseNativeDriver( - config: $ReadOnly<{...AnimationConfig, ...}> | EventConfig, + config: $ReadOnly<{...AnimationConfig, ...}> | EventConfig, ): boolean { if (config.useNativeDriver == null) { console.warn( diff --git a/packages/react-native/src/private/animated/__tests__/createAnimatedPropsHook-test.js b/packages/react-native/src/private/animated/__tests__/createAnimatedPropsHook-test.js index 15dd289361e..881b75bd9e0 100644 --- a/packages/react-native/src/private/animated/__tests__/createAnimatedPropsHook-test.js +++ b/packages/react-native/src/private/animated/__tests__/createAnimatedPropsHook-test.js @@ -18,8 +18,8 @@ describe('useAnimatedProps', () => { const useAnimatedProps = createAnimatedPropsHook(null); const refs = []; - function Sentinel(props: {[string]: mixed}): React.Node { - const [, ref] = useAnimatedProps<{[string]: mixed}, mixed>(props); + function Sentinel(props: {[string]: unknown}): React.Node { + const [, ref] = useAnimatedProps<{[string]: unknown}, unknown>(props); useLayoutEffect(() => { refs.push(ref); }, [ref]); @@ -38,8 +38,8 @@ describe('useAnimatedProps', () => { const useAnimatedProps = createAnimatedPropsHook(null); const refs = []; - function Sentinel(props: {[string]: mixed}): React.Node { - const [, ref] = useAnimatedProps<{[string]: mixed}, mixed>(props); + function Sentinel(props: {[string]: unknown}): React.Node { + const [, ref] = useAnimatedProps<{[string]: unknown}, unknown>(props); useLayoutEffect(() => { refs.push(ref); }, [ref]); @@ -60,8 +60,8 @@ describe('useAnimatedProps', () => { const useAnimatedProps = createAnimatedPropsHook(null); const refs = []; - function Sentinel(props: {[string]: mixed}): React.Node { - const [, ref] = useAnimatedProps<{[string]: mixed}, mixed>(props); + function Sentinel(props: {[string]: unknown}): React.Node { + const [, ref] = useAnimatedProps<{[string]: unknown}, unknown>(props); useLayoutEffect(() => { refs.push(ref); }, [ref]); diff --git a/packages/react-native/src/private/animated/createAnimatedPropsHook.js b/packages/react-native/src/private/animated/createAnimatedPropsHook.js index de7ed73dfb6..46a09964d81 100644 --- a/packages/react-native/src/private/animated/createAnimatedPropsHook.js +++ b/packages/react-native/src/private/animated/createAnimatedPropsHook.js @@ -34,7 +34,7 @@ type ReducedProps = { collapsable: boolean, ... }; -type CallbackRef = T => mixed; +type CallbackRef = T => unknown; export type AnimatedPropsHook = ( props: TProps, diff --git a/packages/react-native/src/private/animated/createAnimatedPropsMemoHook.js b/packages/react-native/src/private/animated/createAnimatedPropsMemoHook.js index 4723a43d5ee..21062f744e8 100644 --- a/packages/react-native/src/private/animated/createAnimatedPropsMemoHook.js +++ b/packages/react-native/src/private/animated/createAnimatedPropsMemoHook.js @@ -24,8 +24,8 @@ type CompositeKey = { [string]: | CompositeKeyComponent | AnimatedEvent - | $ReadOnlyArray - | $ReadOnly<{[string]: mixed}>, + | $ReadOnlyArray + | $ReadOnly<{[string]: unknown}>, }; type CompositeKeyComponent = @@ -38,8 +38,8 @@ type $ReadOnlyCompositeKey = $ReadOnly<{ [string]: | $ReadOnlyCompositeKeyComponent | AnimatedEvent - | $ReadOnlyArray - | $ReadOnly<{[string]: mixed}>, + | $ReadOnlyArray + | $ReadOnly<{[string]: unknown}>, }>; type $ReadOnlyCompositeKeyComponent = @@ -49,7 +49,7 @@ type $ReadOnlyCompositeKeyComponent = type AnimatedPropsMemoHook = ( () => AnimatedProps, - props: $ReadOnly<{[string]: mixed}>, + props: $ReadOnly<{[string]: unknown}>, ) => AnimatedProps; /** @@ -62,7 +62,7 @@ export function createAnimatedPropsMemoHook( ): AnimatedPropsMemoHook { return function useAnimatedPropsMemo( create: () => AnimatedProps, - props: $ReadOnly<{[string]: mixed}>, + props: $ReadOnly<{[string]: unknown}>, ): AnimatedProps { const compositeKey = useMemo( () => createCompositeKeyForProps(props, allowlist), @@ -107,7 +107,7 @@ export function createAnimatedPropsMemoHook( * returns null. */ export function createCompositeKeyForProps( - props: $ReadOnly<{[string]: mixed}>, + props: $ReadOnly<{[string]: unknown}>, allowlist: ?AnimatedPropsAllowlist, ): $ReadOnlyCompositeKey | null { let compositeKey: CompositeKey | null = null; @@ -122,7 +122,7 @@ export function createCompositeKeyForProps( if (key === 'style') { // $FlowFixMe[incompatible-call] - `style` is a valid argument. // $FlowFixMe[incompatible-type] - `flattenStyle` returns an object. - const flatStyle: ?{[string]: mixed} = flattenStyle(value); + const flatStyle: ?{[string]: unknown} = flattenStyle(value); if (flatStyle != null) { compositeKeyComponent = createCompositeKeyForObject( flatStyle, @@ -160,7 +160,7 @@ export function createCompositeKeyForProps( * If `array` contains no `AnimatedNode` instances, this returns null. */ function createCompositeKeyForArray( - array: $ReadOnlyArray, + array: $ReadOnlyArray, ): $ReadOnlyArray<$ReadOnlyCompositeKeyComponent | null> | null { let compositeKey: Array<$ReadOnlyCompositeKeyComponent | null> | null = null; @@ -200,7 +200,7 @@ function createCompositeKeyForArray( * If `object` contains no `AnimatedNode` instances, this returns null. */ function createCompositeKeyForObject( - object: $ReadOnly<{[string]: mixed}>, + object: $ReadOnly<{[string]: unknown}>, allowlist?: ?AnimatedStyleAllowlist, ): $ReadOnly<{[string]: $ReadOnlyCompositeKeyComponent}> | null { let compositeKey: {[string]: $ReadOnlyCompositeKeyComponent} | null = null; diff --git a/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js b/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js index 9a861bc3c89..93792282b67 100644 --- a/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js +++ b/packages/react-native/src/private/components/virtualview/__tests__/VirtualView-itest.js @@ -297,7 +297,7 @@ describe('memory management', () => { * Helper to reduce duplication of the mock event payload. */ export function dispatchModeChangeEvent( - instance: mixed, + instance: unknown, mode: VirtualViewMode, ): void { const targetRect = { @@ -373,7 +373,7 @@ function createWeakRefCallback(): $ReadOnly<{ /** * Gets the shadow node via `instance.__internalInstanceHandle.stateNode.node`. */ -function getNodeAsObjectFromPublicInstance(instance: mixed): interface {} { +function getNodeAsObjectFromPublicInstance(instance: unknown): interface {} { const node = getNodeFromPublicInstance( ensureInstance(instance, ReactNativeElement), ); diff --git a/packages/react-native/src/private/devsupport/devmenu/elementinspector/ElementProperties.js b/packages/react-native/src/private/devsupport/devmenu/elementinspector/ElementProperties.js index 44b2fb0481e..ed32a6ee1cf 100644 --- a/packages/react-native/src/private/devsupport/devmenu/elementinspector/ElementProperties.js +++ b/packages/react-native/src/private/devsupport/devmenu/elementinspector/ElementProperties.js @@ -35,7 +35,7 @@ type Props = $ReadOnly<{ style?: ?ViewStyleProp, frame?: ?Object, selection?: ?number, - setSelection?: number => mixed, + setSelection?: number => unknown, }>; class ElementProperties extends React.Component { diff --git a/packages/react-native/src/private/devsupport/devmenu/elementinspector/InspectorPanel.js b/packages/react-native/src/private/devsupport/devmenu/elementinspector/InspectorPanel.js index d88e07f42b7..98b36263742 100644 --- a/packages/react-native/src/private/devsupport/devmenu/elementinspector/InspectorPanel.js +++ b/packages/react-native/src/private/devsupport/devmenu/elementinspector/InspectorPanel.js @@ -33,7 +33,7 @@ type Props = $ReadOnly<{ setTouchTargeting: (val: boolean) => void, hierarchy?: ?ElementsHierarchy, selection?: ?number, - setSelection: number => mixed, + setSelection: number => unknown, inspected?: ?InspectedElement, }>; diff --git a/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js b/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js index 3370022c92a..ded5e5d1aea 100644 --- a/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js +++ b/packages/react-native/src/private/renderer/core/__tests__/EventDispatching-itest.js @@ -27,7 +27,7 @@ describe('Event Dispatching', () => { let onPointerUpPriority; - const onPointerUp = jest.fn((event: mixed) => { + const onPointerUp = jest.fn((event: unknown) => { onPointerUpPriority = UIManager.unstable_getCurrentEventPriority(); }); @@ -57,7 +57,7 @@ describe('Event Dispatching', () => { let onPointerMovePriority; - const onPointerMove = jest.fn((event: mixed) => { + const onPointerMove = jest.fn((event: unknown) => { onPointerMovePriority = UIManager.unstable_getCurrentEventPriority(); }); @@ -89,7 +89,7 @@ describe('Event Dispatching', () => { let onPointerMovePriority; - const onPointerMove = jest.fn((event: mixed) => { + const onPointerMove = jest.fn((event: unknown) => { onPointerMovePriority = UIManager.unstable_getCurrentEventPriority(); }); @@ -123,10 +123,10 @@ describe('Event Dispatching', () => { let onPointerEnterPriority; let onPointerLeavePriority; - const onPointerEnter = jest.fn((event: mixed) => { + const onPointerEnter = jest.fn((event: unknown) => { onPointerEnterPriority = UIManager.unstable_getCurrentEventPriority(); }); - const onPointerLeave = jest.fn((event: mixed) => { + const onPointerLeave = jest.fn((event: unknown) => { onPointerLeavePriority = UIManager.unstable_getCurrentEventPriority(); }); @@ -180,7 +180,7 @@ describe('Event Dispatching', () => { const ref = React.createRef>(); let onPointerMovePriority; - const onPointerMove = jest.fn((event: mixed) => { + const onPointerMove = jest.fn((event: unknown) => { onPointerMovePriority = UIManager.unstable_getCurrentEventPriority(); }); @@ -261,7 +261,7 @@ describe('Event Dispatching', () => { const ref = React.createRef>(); let onPointerMovePriority; - const onPointerMove = jest.fn((event: mixed) => { + const onPointerMove = jest.fn((event: unknown) => { onPointerMovePriority = UIManager.unstable_getCurrentEventPriority(); }); diff --git a/packages/react-native/src/private/renderer/errorhandling/ErrorHandlers.js b/packages/react-native/src/private/renderer/errorhandling/ErrorHandlers.js index 5c12bfe54b7..1879582f8fa 100644 --- a/packages/react-native/src/private/renderer/errorhandling/ErrorHandlers.js +++ b/packages/react-native/src/private/renderer/errorhandling/ErrorHandlers.js @@ -22,7 +22,7 @@ type ErrorInfo = { }; function getExtendedError( - errorValue: mixed, + errorValue: unknown, errorInfo: ErrorInfo, ): ExtendedError { let error; @@ -56,14 +56,17 @@ function getExtendedError( return error; } -export function onUncaughtError(errorValue: mixed, errorInfo: ErrorInfo): void { +export function onUncaughtError( + errorValue: unknown, + errorInfo: ErrorInfo, +): void { const error = getExtendedError(errorValue, errorInfo); // Uncaught errors are fatal. ExceptionsManager.handleException(error, true); } -export function onCaughtError(errorValue: mixed, errorInfo: ErrorInfo): void { +export function onCaughtError(errorValue: unknown, errorInfo: ErrorInfo): void { const error = getExtendedError(errorValue, errorInfo); // Caught errors are not fatal. @@ -71,7 +74,7 @@ export function onCaughtError(errorValue: mixed, errorInfo: ErrorInfo): void { } export function onRecoverableError( - errorValue: mixed, + errorValue: unknown, errorInfo: ErrorInfo, ): void { const error = getExtendedError(errorValue, errorInfo); diff --git a/packages/react-native/src/private/testing/fantom/specs/NativeFantom.js b/packages/react-native/src/private/testing/fantom/specs/NativeFantom.js index cf6fb99aee1..0df1c6467fc 100644 --- a/packages/react-native/src/private/testing/fantom/specs/NativeFantom.js +++ b/packages/react-native/src/private/testing/fantom/specs/NativeFantom.js @@ -83,29 +83,29 @@ interface Spec extends TurboModule { ) => RootTag; stopSurface: (surfaceId: RootTag) => void; enqueueNativeEvent: ( - shadowNode: mixed /* ShadowNode */, + shadowNode: unknown /* ShadowNode */, type: string, - payload?: mixed, + payload?: unknown, category?: NativeEventCategory, isUnique?: boolean, ) => void; enqueueScrollEvent: ( - shadowNode: mixed /* ShadowNode */, + shadowNode: unknown /* ShadowNode */, options: ScrollOptions, ) => void; enqueueModalSizeUpdate: ( - shadowNode: mixed /* ShadowNode */, + shadowNode: unknown /* ShadowNode */, height: number, width: number, ) => void; takeMountingManagerLogs: (surfaceId: RootTag) => Array; getDirectManipulationProps: ( - shadowNode: mixed /* ShadowNode */, + shadowNode: unknown /* ShadowNode */, ) => $ReadOnly<{ - [string]: mixed, + [string]: unknown, }>; - getFabricUpdateProps: (shadowNode: mixed /* ShadowNode */) => $ReadOnly<{ - [string]: mixed, + getFabricUpdateProps: (shadowNode: unknown /* ShadowNode */) => $ReadOnly<{ + [string]: unknown, }>; flushMessageQueue: () => void; flushEventQueue: () => void; @@ -117,10 +117,10 @@ interface Spec extends TurboModule { ) => string; reportTestSuiteResultsJSON: (results: string) => void; createShadowNodeReferenceCounter( - shadowNode: mixed /* ShadowNode */, + shadowNode: unknown /* ShadowNode */, ): () => number; createShadowNodeRevisionGetter( - shadowNode: mixed /* ShadowNode */, + shadowNode: unknown /* ShadowNode */, ): () => ?number; saveJSMemoryHeapSnapshot: (filePath: string) => void; forceHighResTimeStamp: (timeStamp: ?number) => void; diff --git a/packages/react-native/src/private/webapis/dom/events/CustomEvent.js b/packages/react-native/src/private/webapis/dom/events/CustomEvent.js index d25ce9fe1d3..fd5922a36d6 100644 --- a/packages/react-native/src/private/webapis/dom/events/CustomEvent.js +++ b/packages/react-native/src/private/webapis/dom/events/CustomEvent.js @@ -20,11 +20,11 @@ import type {EventInit} from './Event'; import Event from './Event'; export interface CustomEventInit extends EventInit { - +detail?: mixed; + +detail?: unknown; } export default class CustomEvent extends Event { - _detail: mixed; + _detail: unknown; constructor(type: string, options?: ?CustomEventInit) { super(type, options); @@ -32,7 +32,7 @@ export default class CustomEvent extends Event { this._detail = options?.detail; } - get detail(): mixed { + get detail(): unknown { return this._detail; } } diff --git a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js index 752a64d3037..4d1f5c82b66 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js +++ b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReactNativeElement-itest.js @@ -28,7 +28,7 @@ import ReadOnlyNode from 'react-native/src/private/webapis/dom/nodes/ReadOnlyNod import HTMLCollection from 'react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection'; import NodeList from 'react-native/src/private/webapis/dom/oldstylecollections/NodeList'; -function ensureReactNativeElement(value: mixed): ReactNativeElement { +function ensureReactNativeElement(value: unknown): ReactNativeElement { return ensureInstance(value, ReactNativeElement); } diff --git a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReadOnlyText-itest.js b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReadOnlyText-itest.js index 8925e5040c9..71beb78fde3 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReadOnlyText-itest.js +++ b/packages/react-native/src/private/webapis/dom/nodes/__tests__/ReadOnlyText-itest.js @@ -22,15 +22,15 @@ import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/React import ReadOnlyNode from 'react-native/src/private/webapis/dom/nodes/ReadOnlyNode'; import ReadOnlyText from 'react-native/src/private/webapis/dom/nodes/ReadOnlyText'; -function ensureReadOnlyText(value: mixed): ReadOnlyText { +function ensureReadOnlyText(value: unknown): ReadOnlyText { return ensureInstance(value, ReadOnlyText); } -function ensureReadOnlyNode(value: mixed): ReadOnlyNode { +function ensureReadOnlyNode(value: unknown): ReadOnlyNode { return ensureInstance(value, ReadOnlyNode); } -function ensureReactNativeElement(value: mixed): ReactNativeElement { +function ensureReactNativeElement(value: unknown): ReactNativeElement { return ensureInstance(value, ReactNativeElement); } diff --git a/packages/react-native/src/private/webapis/dom/nodes/internals/ReactNativeDocumentElementInstanceHandle.js b/packages/react-native/src/private/webapis/dom/nodes/internals/ReactNativeDocumentElementInstanceHandle.js index 434b77d21f1..ca200119812 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/internals/ReactNativeDocumentElementInstanceHandle.js +++ b/packages/react-native/src/private/webapis/dom/nodes/internals/ReactNativeDocumentElementInstanceHandle.js @@ -49,7 +49,7 @@ export function setPublicInstanceForReactNativeDocumentElementInstanceHandle( } export function isReactNativeDocumentElementInstanceHandle( - instanceHandle: mixed, + instanceHandle: unknown, ): instanceHandle is ReactNativeDocumentElementInstanceHandle { return instanceHandle instanceof ReactNativeDocumentElementInstanceHandleImpl; } diff --git a/packages/react-native/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js b/packages/react-native/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js index 04764fde2ce..b0c291658f2 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +++ b/packages/react-native/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js @@ -36,7 +36,7 @@ export function getPublicInstanceFromReactNativeDocumentInstanceHandle( } export function isReactNativeDocumentInstanceHandle( - instanceHandle: mixed, + instanceHandle: unknown, // $FlowExpectedError[incompatible-type-guard] ): instanceHandle is ReactNativeDocumentInstanceHandle { // $FlowFixMe[incompatible-type-guard] diff --git a/packages/react-native/src/private/webapis/dom/nodes/specs/NativeDOM.js b/packages/react-native/src/private/webapis/dom/nodes/specs/NativeDOM.js index 565662fd5fc..5709b1a7c89 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/specs/NativeDOM.js +++ b/packages/react-native/src/private/webapis/dom/nodes/specs/NativeDOM.js @@ -52,25 +52,25 @@ export interface Spec extends TurboModule { */ +compareDocumentPosition: ( - nativeNodeReference: mixed /* NativeNodeReference */, - otherNativeNodeReference: mixed /* NativeNodeReference */, + nativeNodeReference: unknown /* NativeNodeReference */, + otherNativeNodeReference: unknown /* NativeNodeReference */, ) => number; +getChildNodes: ( - nativeNodeReference: mixed /* NativeNodeReference */, - ) => $ReadOnlyArray /* $ReadOnlyArray */; + nativeNodeReference: unknown /* NativeNodeReference */, + ) => $ReadOnlyArray /* $ReadOnlyArray */; +getElementById?: ( - nativeNodeReference: mixed /* NativeNodeReference */, + nativeNodeReference: unknown /* NativeNodeReference */, id: string, - ) => mixed /* ?InstanceHandle */; + ) => unknown /* ?InstanceHandle */; +getParentNode: ( - nativeNodeReference: mixed /* NativeNodeReference */, - ) => mixed /* ?InstanceHandle */; + nativeNodeReference: unknown /* NativeNodeReference */, + ) => unknown /* ?InstanceHandle */; +isConnected: ( - nativeNodeReference: mixed /* NativeNodeReference */, + nativeNodeReference: unknown /* NativeNodeReference */, ) => boolean; /* @@ -78,46 +78,46 @@ export interface Spec extends TurboModule { */ +getBorderWidth: ( - nativeElementReference: mixed /* NativeElementReference */, + nativeElementReference: unknown /* NativeElementReference */, ) => $ReadOnlyArray /* [topWidth: number, rightWidth: number, bottomWidth: number, leftWidth: number] */; +getBoundingClientRect: ( - nativeElementReference: mixed /* NativeElementReference */, + nativeElementReference: unknown /* NativeElementReference */, includeTransform: boolean, ) => $ReadOnlyArray /* [x: number, y: number, width: number, height: number] */; +getInnerSize: ( - nativeElementReference: mixed /* NativeElementReference */, + nativeElementReference: unknown /* NativeElementReference */, ) => $ReadOnlyArray /* [width: number, height: number] */; +getScrollPosition: ( - nativeElementReference: mixed /* NativeElementReference */, + nativeElementReference: unknown /* NativeElementReference */, ) => $ReadOnlyArray /* [scrollLeft: number, scrollTop: number] */; +getScrollSize: ( - nativeElementReference: mixed /* NativeElementReference */, + nativeElementReference: unknown /* NativeElementReference */, ) => $ReadOnlyArray /* [scrollWidth: number, scrollHeight: number] */; +getTagName: ( - nativeElementReference: mixed /* NativeElementReference */, + nativeElementReference: unknown /* NativeElementReference */, ) => string; +getTextContent: ( - nativeElementReference: mixed /* NativeElementReference */, + nativeElementReference: unknown /* NativeElementReference */, ) => string; +hasPointerCapture: ( - nativeElementReference: mixed /* NativeElementReference */, + nativeElementReference: unknown /* NativeElementReference */, pointerId: number, ) => boolean; +releasePointerCapture: ( - nativeElementReference: mixed /* NativeElementReference */, + nativeElementReference: unknown /* NativeElementReference */, pointerId: number, ) => void; +setPointerCapture: ( - nativeElementReference: mixed /* NativeElementReference */, + nativeElementReference: unknown /* NativeElementReference */, pointerId: number, ) => void; @@ -126,8 +126,8 @@ export interface Spec extends TurboModule { */ +getOffset: ( - nativeElementReference: mixed /* NativeElementReference */, - ) => $ReadOnlyArray /* [offsetParent: ?InstanceHandle, top: number, left: number] */; + nativeElementReference: unknown /* NativeElementReference */, + ) => $ReadOnlyArray /* [offsetParent: ?InstanceHandle, top: number, left: number] */; /* * Special methods to handle the root node. @@ -135,26 +135,26 @@ export interface Spec extends TurboModule { +linkRootNode?: ( rootTag: number /* RootTag */, - instanceHandle: mixed /* InstanceHandle */, - ) => mixed /* ?NativeElementReference */; + instanceHandle: unknown /* InstanceHandle */, + ) => unknown /* ?NativeElementReference */; /** * Legacy layout APIs (for `ReactNativeElement`). */ +measure: ( - nativeElementReference: mixed, + nativeElementReference: unknown, callback: MeasureOnSuccessCallback, ) => void; +measureInWindow: ( - nativeElementReference: mixed, + nativeElementReference: unknown, callback: MeasureInWindowOnSuccessCallback, ) => void; +measureLayout: ( - nativeElementReference: mixed, - relativeNode: mixed, + nativeElementReference: unknown, + relativeNode: unknown, onFail: () => void, onSuccess: MeasureLayoutOnSuccessCallback, ) => void; @@ -164,8 +164,8 @@ export interface Spec extends TurboModule { */ +setNativeProps: ( - nativeElementReference: mixed, - updatePayload: mixed, + nativeElementReference: unknown, + updatePayload: unknown, ) => void; } diff --git a/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js b/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js index b7b062051c5..92c66ee75af 100644 --- a/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +++ b/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js @@ -18,7 +18,7 @@ import {setPlatformObject} from '../../webidl/PlatformObjects'; // IMPORTANT: The type definition for this module is defined in `HTMLCollection.js.flow` // because Flow only supports indexers in classes in declaration files. -const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor, ...} = { +const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor, ...} = { value: {}, enumerable: true, configurable: false, diff --git a/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js b/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js index f5c58c6dfef..a2443eaccc2 100644 --- a/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js +++ b/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js @@ -22,7 +22,7 @@ import {setPlatformObject} from '../../webidl/PlatformObjects'; // IMPORTANT: The Flow type definition for this module is defined in `NodeList.js.flow` // because Flow only supports indexers in classes in declaration files. -const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor, ...} = { +const REUSABLE_PROPERTY_DESCRIPTOR: {...PropertyDescriptor, ...} = { value: {}, writable: false, }; @@ -66,7 +66,7 @@ export default class NodeList implements Iterable, ArrayLike { } forEach( - callbackFn: (value: T, index: number, array: NodeList) => mixed, + callbackFn: (value: T, index: number, array: NodeList) => unknown, thisArg?: ThisType, ): void { // assigning to the interface allows us to access the indexer property in a diff --git a/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js.flow b/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js.flow index 37f6eb057ad..1c664786a4e 100644 --- a/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js.flow +++ b/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js.flow @@ -21,7 +21,7 @@ declare export default class NodeList<+T> implements Iterable, ArrayLike { // $FlowFixMe[incompatible-variance] entries(): Iterator<[number, T]>; forEach( - callbackFn: (value: T, index: number, array: NodeList) => mixed, + callbackFn: (value: T, index: number, array: NodeList) => unknown, thisArg?: ThisType, ): void; keys(): Iterator; diff --git a/packages/react-native/src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js b/packages/react-native/src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js index 465d22ffa64..377ee8c3777 100644 --- a/packages/react-native/src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js +++ b/packages/react-native/src/private/webapis/dom/oldstylecollections/__tests__/NodeList-test.js @@ -134,7 +134,7 @@ describe('NodeList', () => { const collection = createNodeList(['a', 'b', 'c']); let i = 0; - collection.forEach(function (this: mixed, value, index, list) { + collection.forEach(function (this: unknown, value, index, list) { expect(value).toBe(collection[i]); expect(index).toBe(i); expect(list).toBe(collection); @@ -148,7 +148,7 @@ describe('NodeList', () => { let i = 0; const explicitThis = {id: 'foo'}; - collection.forEach(function (this: mixed, value, index, list) { + collection.forEach(function (this: unknown, value, index, list) { expect(value).toBe(collection[i]); expect(index).toBe(i); expect(list).toBe(collection); diff --git a/packages/react-native/src/private/webapis/geometry/DOMRectReadOnly.js b/packages/react-native/src/private/webapis/geometry/DOMRectReadOnly.js index cba98de3b9b..03914eca39a 100644 --- a/packages/react-native/src/private/webapis/geometry/DOMRectReadOnly.js +++ b/packages/react-native/src/private/webapis/geometry/DOMRectReadOnly.js @@ -25,7 +25,7 @@ export interface DOMRectInit { height?: ?number; } -function castToNumber(value: mixed): number { +function castToNumber(value: unknown): number { return value ? Number(value) : 0; } diff --git a/packages/react-native/src/private/webapis/html/events/MessageEvent.js b/packages/react-native/src/private/webapis/html/events/MessageEvent.js index 7184eda1938..57bca029b84 100644 --- a/packages/react-native/src/private/webapis/html/events/MessageEvent.js +++ b/packages/react-native/src/private/webapis/html/events/MessageEvent.js @@ -20,7 +20,7 @@ import type {EventInit} from '../../dom/events/Event'; import Event from '../../dom/events/Event'; export interface MessageEventInit extends EventInit { - +data?: mixed; + +data?: unknown; +origin?: string; +lastEventId?: string; // Unsupported @@ -30,7 +30,7 @@ export interface MessageEventInit extends EventInit { } export default class MessageEvent extends Event { - _data: mixed; + _data: unknown; _origin: string; _lastEventId: string; @@ -42,7 +42,7 @@ export default class MessageEvent extends Event { this._lastEventId = String(options?.lastEventId ?? ''); } - get data(): mixed { + get data(): unknown { return this._data; } diff --git a/packages/react-native/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js b/packages/react-native/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js index 4241e5ef06d..1b5f835fe8f 100644 --- a/packages/react-native/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +++ b/packages/react-native/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js @@ -12,7 +12,7 @@ import type {TurboModule} from '../../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/TurboModuleRegistry'; -export opaque type IdleCallbackID = mixed; +export opaque type IdleCallbackID = unknown; export type RequestIdleCallbackOptions = { timeout?: number, @@ -20,12 +20,12 @@ export type RequestIdleCallbackOptions = { export type IdleDeadline = { didTimeout: boolean, - timeRemaining: () => mixed, + timeRemaining: () => unknown, }; export interface Spec extends TurboModule { +requestIdleCallback: ( - callback: (idleDeadline: IdleDeadline) => mixed, + callback: (idleDeadline: IdleDeadline) => unknown, options?: RequestIdleCallbackOptions, ) => IdleCallbackID; +cancelIdleCallback: (handle: IdleCallbackID) => void; diff --git a/packages/react-native/src/private/webapis/intersectionobserver/IntersectionObserver.js b/packages/react-native/src/private/webapis/intersectionobserver/IntersectionObserver.js index e333c4decf4..00a8f6cc7d6 100644 --- a/packages/react-native/src/private/webapis/intersectionobserver/IntersectionObserver.js +++ b/packages/react-native/src/private/webapis/intersectionobserver/IntersectionObserver.js @@ -20,7 +20,7 @@ import * as IntersectionObserverManager from './internals/IntersectionObserverMa export type IntersectionObserverCallback = ( entries: Array, observer: IntersectionObserver, -) => mixed; +) => unknown; export interface IntersectionObserverInit { root?: ?ReactNativeElement; @@ -315,7 +315,7 @@ setPlatformObject(IntersectionObserver); * normalizeThresholds([], true); // → [] */ function normalizeThreshold( - threshold: mixed, + threshold: unknown, defaultEmpty: boolean = false, ): $ReadOnlyArray { if (Array.isArray(threshold)) { @@ -353,7 +353,7 @@ function normalizeThreshold( * normalizeRootThresholds([null, null]); // → null */ function normalizeRootThreshold( - rootThreshold: mixed, + rootThreshold: unknown, ): null | $ReadOnlyArray { if (Array.isArray(rootThreshold)) { const normalizedArr = rootThreshold @@ -368,7 +368,7 @@ function normalizeRootThreshold( } function normalizeThresholdValue( - threshold: mixed, + threshold: unknown, property: string, ): null | number { if (threshold == null) { @@ -399,7 +399,7 @@ function normalizeThresholdValue( * Per W3C spec, rootMargin must be specified in pixels or percent. * This implementation validates the basic format. */ -function normalizeRootMargin(rootMargin: mixed): string { +function normalizeRootMargin(rootMargin: unknown): string { if (rootMargin == null || rootMargin === '') { return '0px 0px 0px 0px'; } diff --git a/packages/react-native/src/private/webapis/intersectionobserver/__tests__/IntersectionObserver-itest.js b/packages/react-native/src/private/webapis/intersectionobserver/__tests__/IntersectionObserver-itest.js index 9e75b3e5be5..68323fd7793 100644 --- a/packages/react-native/src/private/webapis/intersectionobserver/__tests__/IntersectionObserver-itest.js +++ b/packages/react-native/src/private/webapis/intersectionobserver/__tests__/IntersectionObserver-itest.js @@ -28,7 +28,7 @@ declare const IntersectionObserver: Class; setUpIntersectionObserver(); -function ensureReactNativeElement(value: mixed): ReactNativeElement { +function ensureReactNativeElement(value: unknown): ReactNativeElement { return ensureInstance(value, ReactNativeElement); } diff --git a/packages/react-native/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js b/packages/react-native/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js index 3235e7bdb0e..edd4d3c06e6 100644 --- a/packages/react-native/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +++ b/packages/react-native/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js @@ -53,7 +53,7 @@ const instanceHandleToTargetMap: WeakMap = new WeakMap(); function getTargetFromInstanceHandle( - instanceHandle: mixed, + instanceHandle: unknown, ): ?ReactNativeElement { // $FlowExpectedError[incompatible-type] instanceHandle is typed as mixed but we know it's an object and we need it to be to use it as a key in a WeakMap. const key: interface {} = instanceHandle; @@ -61,7 +61,7 @@ function getTargetFromInstanceHandle( } function setTargetForInstanceHandle( - instanceHandle: mixed, + instanceHandle: unknown, target: ReactNativeElement, ): void { // $FlowExpectedError[incompatible-type] instanceHandle is typed as mixed but we know it's an object and we need it to be to use it as a key in a WeakMap. diff --git a/packages/react-native/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js b/packages/react-native/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js index fed5c0977f0..ebadf4ac09b 100644 --- a/packages/react-native/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +++ b/packages/react-native/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js @@ -14,7 +14,7 @@ import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/Turbo export type NativeIntersectionObserverEntry = { intersectionObserverId: number, - targetInstanceHandle: mixed, + targetInstanceHandle: unknown, targetRect: $ReadOnlyArray, // It's actually a tuple with x, y, width and height rootRect: $ReadOnlyArray, // It's actually a tuple with x, y, width and height // TODO(T209328432) - Remove optionality of intersectionRect when native changes are released @@ -25,14 +25,14 @@ export type NativeIntersectionObserverEntry = { export type NativeIntersectionObserverObserveOptions = { intersectionObserverId: number, - rootShadowNode?: ?mixed, - targetShadowNode: mixed, + rootShadowNode?: ?unknown, + targetShadowNode: unknown, thresholds: $ReadOnlyArray, rootThresholds?: ?$ReadOnlyArray, rootMargin?: ?string, }; -export opaque type NativeIntersectionObserverToken = mixed; +export opaque type NativeIntersectionObserverToken = unknown; export interface Spec extends TurboModule { +observeV2?: ( diff --git a/packages/react-native/src/private/webapis/microtasks/specs/NativeMicrotasks.js b/packages/react-native/src/private/webapis/microtasks/specs/NativeMicrotasks.js index 4f07158ad6b..c6be40a63ff 100644 --- a/packages/react-native/src/private/webapis/microtasks/specs/NativeMicrotasks.js +++ b/packages/react-native/src/private/webapis/microtasks/specs/NativeMicrotasks.js @@ -13,7 +13,7 @@ import type {TurboModule} from '../../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +queueMicrotask: (callback: () => mixed) => void; + +queueMicrotask: (callback: () => unknown) => void; } export default (TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native/src/private/webapis/mutationobserver/MutationObserver.js b/packages/react-native/src/private/webapis/mutationobserver/MutationObserver.js index 835dd6ad2b1..daca50a9970 100644 --- a/packages/react-native/src/private/webapis/mutationobserver/MutationObserver.js +++ b/packages/react-native/src/private/webapis/mutationobserver/MutationObserver.js @@ -20,7 +20,7 @@ import * as MutationObserverManager from './internals/MutationObserverManager'; export type MutationObserverCallback = ( mutationRecords: $ReadOnlyArray, observer: MutationObserver, -) => mixed; +) => unknown; export interface MutationObserverInit { +subtree?: boolean; diff --git a/packages/react-native/src/private/webapis/mutationobserver/MutationRecord.js b/packages/react-native/src/private/webapis/mutationobserver/MutationRecord.js index 60ba9a38231..42f7812c21a 100644 --- a/packages/react-native/src/private/webapis/mutationobserver/MutationRecord.js +++ b/packages/react-native/src/private/webapis/mutationobserver/MutationRecord.js @@ -55,7 +55,7 @@ export default class MutationRecord { return null; } - get oldValue(): mixed | null { + get oldValue(): unknown | null { return null; } diff --git a/packages/react-native/src/private/webapis/mutationobserver/__tests__/MutationObserver-itest.js b/packages/react-native/src/private/webapis/mutationobserver/__tests__/MutationObserver-itest.js index 7609f41b22b..2d798c5d200 100644 --- a/packages/react-native/src/private/webapis/mutationobserver/__tests__/MutationObserver-itest.js +++ b/packages/react-native/src/private/webapis/mutationobserver/__tests__/MutationObserver-itest.js @@ -29,14 +29,14 @@ declare const MutationRecord: Class; setUpMutationObserver(); -function ensureReactNativeElement(value: mixed): ReactNativeElement { +function ensureReactNativeElement(value: unknown): ReactNativeElement { return ensureInstance(value, ReactNativeElement); } function ensureMutationRecordArray( - value: mixed, + value: unknown, ): $ReadOnlyArray { - return ensureInstance(value, Array).map((element: mixed) => + return ensureInstance(value, Array).map((element: unknown) => ensureInstance(element, MutationRecord), ); } @@ -239,7 +239,7 @@ describe('MutationObserver', () => { const node = ensureReactNativeElement(nodeRef.current); const observerCallbackCallArgs = []; - const observerCallback = (...args: $ReadOnlyArray) => { + const observerCallback = (...args: $ReadOnlyArray) => { observerCallbackCallArgs.push(args); }; const observer = new MutationObserver(observerCallback); diff --git a/packages/react-native/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js b/packages/react-native/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js index c4fbcb2517e..aa0823f11b0 100644 --- a/packages/react-native/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +++ b/packages/react-native/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js @@ -15,10 +15,10 @@ import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/Turbo export type MutationObserverId = number; // These types are not supported by the codegen. -type ShadowNode = mixed; -type InstanceHandle = mixed; -type ReactNativeElement = mixed; -type ReadOnlyNode = mixed; +type ShadowNode = unknown; +type InstanceHandle = unknown; +type ReactNativeElement = unknown; +type ReadOnlyNode = unknown; export type NativeMutationRecord = { mutationObserverId: MutationObserverId, diff --git a/packages/react-native/src/private/webapis/performance/Performance.js b/packages/react-native/src/private/webapis/performance/Performance.js index e4f640a732d..fa03971ac0b 100644 --- a/packages/react-native/src/private/webapis/performance/Performance.js +++ b/packages/react-native/src/private/webapis/performance/Performance.js @@ -240,7 +240,7 @@ export default class Performance { let resolvedMeasureName: string; let resolvedStartTime: number; let resolvedDuration: number; - let resolvedDetail: mixed; + let resolvedDetail: unknown; if (measureName === undefined) { throw new TypeError( diff --git a/packages/react-native/src/private/webapis/performance/UserTiming.js b/packages/react-native/src/private/webapis/performance/UserTiming.js index 5675fcafd6e..f7c8c7e359e 100644 --- a/packages/react-native/src/private/webapis/performance/UserTiming.js +++ b/packages/react-native/src/private/webapis/performance/UserTiming.js @@ -22,7 +22,7 @@ import {getCurrentTimeStamp} from './internals/Utilities'; import {PerformanceEntry} from './PerformanceEntry'; export type DetailType = - | mixed + | unknown // This will effectively ignored by Flow (mixed | anything = mixed) // but we'll use it as documentation for how to use the extensibility API. | {devtools?: ExtensionMarkerPayload | ExtensionTrackEntryPayload, ...}; diff --git a/packages/react-native/src/private/webapis/performance/__tests__/EventTimingAPI-itest.js b/packages/react-native/src/private/webapis/performance/__tests__/EventTimingAPI-itest.js index 8a5d7bbade8..18921768dfd 100644 --- a/packages/react-native/src/private/webapis/performance/__tests__/EventTimingAPI-itest.js +++ b/packages/react-native/src/private/webapis/performance/__tests__/EventTimingAPI-itest.js @@ -23,7 +23,7 @@ function sleep(ms: number) { while (performance.now() < end) {} } -function ensurePerformanceEventTiming(value: mixed): PerformanceEventTiming { +function ensurePerformanceEventTiming(value: unknown): PerformanceEventTiming { if (!(value instanceof PerformanceEventTiming)) { throw new Error( `Expected instance of PerformanceEventTiming but got ${String(value)}`, diff --git a/packages/react-native/src/private/webapis/performance/__tests__/LongTasksAPI-itest.js b/packages/react-native/src/private/webapis/performance/__tests__/LongTasksAPI-itest.js index e3b8443676e..c53751d15df 100644 --- a/packages/react-native/src/private/webapis/performance/__tests__/LongTasksAPI-itest.js +++ b/packages/react-native/src/private/webapis/performance/__tests__/LongTasksAPI-itest.js @@ -15,7 +15,7 @@ import type {PerformanceObserverCallbackOptions} from '../PerformanceObserver'; import * as Fantom from '@react-native/fantom'; function ensurePerformanceLongTaskTiming( - value: mixed, + value: unknown, ): PerformanceLongTaskTiming { if (!(value instanceof PerformanceLongTaskTiming)) { throw new Error( diff --git a/packages/react-native/src/private/webapis/performance/__tests__/UserTiming-itest.js b/packages/react-native/src/private/webapis/performance/__tests__/UserTiming-itest.js index 99cb13114d4..9de95003fed 100644 --- a/packages/react-native/src/private/webapis/performance/__tests__/UserTiming-itest.js +++ b/packages/react-native/src/private/webapis/performance/__tests__/UserTiming-itest.js @@ -14,7 +14,7 @@ import ensureInstance from '../../../__tests__/utilities/ensureInstance'; import DOMException from '../../errors/DOMException'; import * as Fantom from '@react-native/fantom'; -function getThrownError(fn: () => mixed): mixed { +function getThrownError(fn: () => unknown): unknown { try { fn(); } catch (e) { @@ -23,7 +23,7 @@ function getThrownError(fn: () => mixed): mixed { throw new Error('Expected function to throw'); } -function toJSON(entries: PerformanceEntryList): Array { +function toJSON(entries: PerformanceEntryList): Array { return entries.map(entry => entry.toJSON()); } diff --git a/packages/react-native/src/private/webapis/performance/specs/NativePerformance.js b/packages/react-native/src/private/webapis/performance/specs/NativePerformance.js index af194df4351..9bb167da1b1 100644 --- a/packages/react-native/src/private/webapis/performance/specs/NativePerformance.js +++ b/packages/react-native/src/private/webapis/performance/specs/NativePerformance.js @@ -42,7 +42,7 @@ export type RawPerformanceEntry = { decodedBodySize?: number, }; -export opaque type OpaqueNativeObserverHandle = mixed; +export opaque type OpaqueNativeObserverHandle = unknown; export type NativeBatchedObserverCallback = () => void; export type NativePerformanceMarkResult = number; @@ -59,12 +59,12 @@ export interface Spec extends TurboModule { +now: () => number; +timeOrigin?: () => number; - +reportMark: (name: string, startTime: number, entry: mixed) => void; + +reportMark: (name: string, startTime: number, entry: unknown) => void; +reportMeasure: ( name: string, startTime: number, duration: number, - entry: mixed, + entry: unknown, ) => void; +getMarkTime: (name: string) => ?number; +clearMarks: (entryName?: string) => void; diff --git a/packages/react-native/src/private/webapis/structuredClone/__tests__/structuredClone-itest.js b/packages/react-native/src/private/webapis/structuredClone/__tests__/structuredClone-itest.js index eeeaa8fe466..8409cb8afb9 100644 --- a/packages/react-native/src/private/webapis/structuredClone/__tests__/structuredClone-itest.js +++ b/packages/react-native/src/private/webapis/structuredClone/__tests__/structuredClone-itest.js @@ -30,7 +30,7 @@ import structuredClone from 'react-native/src/private/webapis/structuredClone/st setUpIntersectionObserver(); setUpMutationObserver(); -function expectDataCloneError(fn: () => mixed) { +function expectDataCloneError(fn: () => unknown) { try { fn(); } catch (error) { @@ -284,7 +284,7 @@ describe('structuredClone', () => { }); it('handles circular references', () => { - const obj: {arr: Array} = {arr: []}; + const obj: {arr: Array} = {arr: []}; obj.arr.push(obj); const map = new Map(); map.set('key', map); @@ -389,7 +389,7 @@ describe('structuredClone', () => { }); expect(ref.current).not.toBe(null); - const entries: Array = []; + const entries: Array = []; Fantom.runTask(() => { const observer = new IntersectionObserver((e, self) => { entries.push(...e); @@ -418,7 +418,7 @@ describe('structuredClone', () => { }); expect(ref.current).not.toBe(null); - const records: Array = []; + const records: Array = []; Fantom.runTask(() => { const observer = new MutationObserver(e => { records.push(...e); diff --git a/packages/react-native/src/private/webapis/structuredClone/structuredClone.js b/packages/react-native/src/private/webapis/structuredClone/structuredClone.js index 5cd200f72ca..7a776be1c97 100644 --- a/packages/react-native/src/private/webapis/structuredClone/structuredClone.js +++ b/packages/react-native/src/private/webapis/structuredClone/structuredClone.js @@ -33,7 +33,7 @@ const ObjectPrototype = Object.prototype; // and avoid allocating a new one in every call to `structuredClone`. // This is safe because we don't invoke user code in `structuredClone`, so at // any given point we only have one memory object alive anyway. -const memory: Map = new Map(); +const memory: Map = new Map(); function structuredCloneInternal(value: T): T { // Handles `null` and `undefined`. @@ -105,7 +105,7 @@ function structuredCloneInternal(value: T): T { } if (value instanceof Map) { - const result = new Map(); + const result = new Map(); memory.set(value, result); for (const [innerKey, innerValue] of value) { @@ -120,7 +120,7 @@ function structuredCloneInternal(value: T): T { } if (value instanceof Set) { - const result = new Set(); + const result = new Set(); memory.set(value, result); for (const innerValue of value) { diff --git a/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js b/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js index 312efedbf20..3a445616698 100644 --- a/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js +++ b/packages/rn-tester/RCTTest/RCTSnapshotNativeComponent.js @@ -24,7 +24,7 @@ type SnapshotReadyEvent = NativeSyntheticEvent< type NativeProps = $ReadOnly<{ ...ViewProps, - onSnapshotReady?: ?(event: SnapshotReadyEvent) => mixed, + onSnapshotReady?: ?(event: SnapshotReadyEvent) => unknown, testIdentifier?: ?string, }>; diff --git a/packages/rn-tester/js/components/RNTOption.js b/packages/rn-tester/js/components/RNTOption.js index ce0da863b35..12de74bf477 100644 --- a/packages/rn-tester/js/components/RNTOption.js +++ b/packages/rn-tester/js/components/RNTOption.js @@ -21,7 +21,7 @@ import {Pressable, StyleSheet, Text, View} from 'react-native'; type Props = $ReadOnly<{ testID?: ?string, label: string, - onPress?: ?(event: GestureResponderEvent) => mixed, + onPress?: ?(event: GestureResponderEvent) => unknown, selected?: ?boolean, multiSelect?: ?boolean, disabled?: ?boolean, diff --git a/packages/rn-tester/js/components/RNTPressableRow.js b/packages/rn-tester/js/components/RNTPressableRow.js index 9ae0649389c..a6598baea65 100644 --- a/packages/rn-tester/js/components/RNTPressableRow.js +++ b/packages/rn-tester/js/components/RNTPressableRow.js @@ -18,12 +18,12 @@ type ViewStyleProp = React.ElementConfig['style']; type Props = { accessibilityLabel?: ?string, testID?: ?string, - onPressIn?: ?() => mixed, - onPressOut?: ?() => mixed, + onPressIn?: ?() => unknown, + onPressOut?: ?() => unknown, children?: ?React.Node, title: string, description?: ?string, - onPress: () => mixed, + onPress: () => unknown, style?: ViewStyleProp | ((pressed: boolean) => ViewStyleProp), }; diff --git a/packages/rn-tester/js/components/RNTesterButton.js b/packages/rn-tester/js/components/RNTesterButton.js index c459bd94c56..a3facd92b5c 100644 --- a/packages/rn-tester/js/components/RNTesterButton.js +++ b/packages/rn-tester/js/components/RNTesterButton.js @@ -19,7 +19,7 @@ type Props = $ReadOnly<{ testID?: string, textTestID?: string, children?: React.Node, - onPress?: ?(event: GestureResponderEvent) => mixed, + onPress?: ?(event: GestureResponderEvent) => unknown, }>; function RNTesterButton(props: Props): React.Node { diff --git a/packages/rn-tester/js/components/RNTesterListFilters.js b/packages/rn-tester/js/components/RNTesterListFilters.js index 03d4e5f5131..1dbd890ad1b 100644 --- a/packages/rn-tester/js/components/RNTesterListFilters.js +++ b/packages/rn-tester/js/components/RNTesterListFilters.js @@ -16,7 +16,7 @@ const {StyleSheet, Text, TouchableOpacity, View} = require('react-native'); const filters = ['Basic', 'UI', 'ListView', 'iOS', 'Android']; type Props = { - onFilterButtonPress: (filter: string) => mixed, //optional only for testing + onFilterButtonPress: (filter: string) => unknown, //optional only for testing ... }; diff --git a/packages/rn-tester/js/components/RNTesterModuleContainer.js b/packages/rn-tester/js/components/RNTesterModuleContainer.js index 5dfdb6880c0..c6b39e73649 100644 --- a/packages/rn-tester/js/components/RNTesterModuleContainer.js +++ b/packages/rn-tester/js/components/RNTesterModuleContainer.js @@ -25,7 +25,7 @@ const RNTesterExampleFilter = require('./RNTesterExampleFilter'); type Props = { module: RNTesterModule, example?: ?RNTesterModuleExample, - onExampleCardPress?: ?(exampleName: string) => mixed, + onExampleCardPress?: ?(exampleName: string) => unknown, }; function getExampleTitle(title: $FlowFixMe, platform: $FlowFixMe) { diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js index f9e183bc4eb..e4e869964d2 100644 --- a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js +++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js @@ -1508,7 +1508,7 @@ class EnabledExample extends React.Component< isEnabled: false, }; _subscription: EventSubscription; - componentDidMount(): null | Promise { + componentDidMount(): null | Promise { this._subscription = AccessibilityInfo.addEventListener( this.props.eventListener, this._handleToggled, diff --git a/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestTypes.js b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestTypes.js index ee20acbb92d..a3b3a5685f6 100644 --- a/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestTypes.js +++ b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestTypes.js @@ -34,7 +34,7 @@ export type PlatformTestResult = $ReadOnly<{ name: string, status: PlatformTestResultStatus, assertions: $ReadOnlyArray, - error: mixed | null, // null is technically unnecessary but is kept to ensure the error is described as nullable + error: unknown | null, // null is technically unnecessary but is kept to ensure the error is described as nullable }>; export type PlatformTestContext = $ReadOnly<{ diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js index 508a71dc82f..472502e120b 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-basic.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-basic.js @@ -107,7 +107,7 @@ class FlatListExample extends React.PureComponent { this.setState({filterText}); }; - _onChangeScrollToIndex = (text: mixed) => { + _onChangeScrollToIndex = (text: unknown) => { this._listRef?.scrollToIndex({viewPosition: 0.5, index: Number(text)}); }; @@ -298,7 +298,7 @@ class FlatListExample extends React.PureComponent { ); } - _captureRef = (ref: FlatList | null) => { + _captureRef = (ref: FlatList | null) => { this._listRef = ref; }; // $FlowFixMe[missing-local-annot] @@ -422,7 +422,7 @@ class FlatListExample extends React.PureComponent { })); }; - _listRef: FlatList | null; + _listRef: FlatList | null; } const styles = StyleSheet.create({ diff --git a/packages/rn-tester/js/examples/FlatList/FlatList-multiColumn.js b/packages/rn-tester/js/examples/FlatList/FlatList-multiColumn.js index a6b6c8921de..5900e5d8cde 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatList-multiColumn.js +++ b/packages/rn-tester/js/examples/FlatList/FlatList-multiColumn.js @@ -42,7 +42,7 @@ function MultiColumnExample(): React.Node { const _onChangeFilterText = (_filterText: string) => { setFilterText(_filterText); }; - const _onChangeNumColumns = (_numColumns: mixed) => { + const _onChangeNumColumns = (_numColumns: unknown) => { setNumColumns(Number(_numColumns)); }; diff --git a/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverClippingParent.js b/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverClippingParent.js index 085024cb114..ce4f3e12bcd 100644 --- a/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverClippingParent.js +++ b/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverClippingParent.js @@ -29,7 +29,7 @@ export function render(): React.Node { /** * Showcase threshold of two overlapping elements */ -function roundRect(rect: mixed): ?{ +function roundRect(rect: unknown): ?{ x: number, y: number, width: number, diff --git a/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverClippingRoot.js b/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverClippingRoot.js index e08a2bf4f91..3bf9c3af192 100644 --- a/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverClippingRoot.js +++ b/packages/rn-tester/js/examples/IntersectionObserver/IntersectionObserverClippingRoot.js @@ -26,7 +26,7 @@ export function render(): React.Node { return ; } -function roundRect(rect: mixed): ?{ +function roundRect(rect: unknown): ?{ x: number, y: number, width: number, diff --git a/packages/rn-tester/js/examples/Snapshot/SnapshotViewIOS.ios.js b/packages/rn-tester/js/examples/Snapshot/SnapshotViewIOS.ios.js index 59547b36f03..32f419d10ce 100644 --- a/packages/rn-tester/js/examples/Snapshot/SnapshotViewIOS.ios.js +++ b/packages/rn-tester/js/examples/Snapshot/SnapshotViewIOS.ios.js @@ -30,7 +30,7 @@ type SnapshotReadyEvent = NativeSyntheticEvent< type Props = $ReadOnly<{ ...ViewProps, - onSnapshotReady?: ?(event: SnapshotReadyEvent) => mixed, + onSnapshotReady?: ?(event: SnapshotReadyEvent) => unknown, testIdentifier?: ?string, }>; diff --git a/packages/rn-tester/js/examples/SwipeableCardExample/SwipeableCardExample.js b/packages/rn-tester/js/examples/SwipeableCardExample/SwipeableCardExample.js index 99a6830e7f9..7df3686e543 100644 --- a/packages/rn-tester/js/examples/SwipeableCardExample/SwipeableCardExample.js +++ b/packages/rn-tester/js/examples/SwipeableCardExample/SwipeableCardExample.js @@ -149,7 +149,7 @@ function Card(props: {color: string}) { const separatorComponent = () => ; - const listRef = useRef>(); + const listRef = useRef>(); useEffect(() => { listRef.current?.scrollToOffset({offset: 0, animated: false}); diff --git a/packages/rn-tester/js/examples/Text/TextExample.ios.js b/packages/rn-tester/js/examples/Text/TextExample.ios.js index 5fdff36d3bc..1af9c830f13 100644 --- a/packages/rn-tester/js/examples/Text/TextExample.ios.js +++ b/packages/rn-tester/js/examples/Text/TextExample.ios.js @@ -269,7 +269,7 @@ class AdjustingFontSize extends React.Component< } } -class TextBaseLineLayoutExample extends React.Component<{}, mixed> { +class TextBaseLineLayoutExample extends React.Component<{}, unknown> { render(): React.Node { const texts = []; for (let i = 9; i >= 0; i--) { diff --git a/packages/rn-tester/js/examples/TurboModule/NativeCxxModuleExampleExample.js b/packages/rn-tester/js/examples/TurboModule/NativeCxxModuleExampleExample.js index cfd512be703..dcee38ad656 100644 --- a/packages/rn-tester/js/examples/TurboModule/NativeCxxModuleExampleExample.js +++ b/packages/rn-tester/js/examples/TurboModule/NativeCxxModuleExampleExample.js @@ -29,7 +29,7 @@ type State = { testResults: { [string]: { type: string, - value: mixed, + value: unknown, ... }, ... @@ -239,7 +239,7 @@ class NativeCxxModuleExampleExample extends React.Component<{}, State> { | {const1: boolean, const2: number, const3: string} | number | {[key: string]: ?number} - | Promise + | Promise | number | string, ) { diff --git a/packages/rn-tester/js/examples/TurboModule/SampleLegacyModuleExample.js b/packages/rn-tester/js/examples/TurboModule/SampleLegacyModuleExample.js index 876c03da3a1..d0090a3ebe2 100644 --- a/packages/rn-tester/js/examples/TurboModule/SampleLegacyModuleExample.js +++ b/packages/rn-tester/js/examples/TurboModule/SampleLegacyModuleExample.js @@ -26,7 +26,7 @@ type State = { testResults: { [string]: { type: string, - value: mixed, + value: unknown, ... }, ... @@ -49,14 +49,14 @@ function getSampleLegacyModule() { return module; } -function stringify(obj: mixed): string { - function replacer(_: string, value: mixed) { +function stringify(obj: unknown): string { + function replacer(_: string, value: unknown) { if (value instanceof Object && !(value instanceof Array)) { /* $FlowFixMe[constant-condition] Error discovered during Constant * Condition roll out. See https://fburl.com/workplace/1v97vimq. */ return Object.keys(value ?? {}) .sort() - .reduce((sorted: {[key: string]: mixed}, key: string) => { + .reduce((sorted: {[key: string]: unknown}, key: string) => { // $FlowFixMe[invalid-computed-prop] /* $FlowFixMe[constant-condition] Error discovered during Constant * Condition roll out. See https://fburl.com/workplace/1v97vimq. */ @@ -183,7 +183,7 @@ class SampleLegacyModuleExample extends React.Component<{}, State> { getConst3: () => getSampleLegacyModule()?.const3, }; - _setResult(name: string, result: mixed) { + _setResult(name: string, result: unknown) { this.setState(({testResults}) => ({ /* $FlowFixMe[cannot-spread-indexer] (>=0.122.0 site=react_native_fb) * This comment suppresses an error found when Flow v0.122.0 was diff --git a/packages/rn-tester/js/examples/TurboModule/SampleTurboModuleExample.js b/packages/rn-tester/js/examples/TurboModule/SampleTurboModuleExample.js index 3a57d12ce6c..c1c5803c06c 100644 --- a/packages/rn-tester/js/examples/TurboModule/SampleTurboModuleExample.js +++ b/packages/rn-tester/js/examples/TurboModule/SampleTurboModuleExample.js @@ -21,7 +21,7 @@ type State = { testResults: { [string]: { type: string, - value: mixed, + value: unknown, ... }, ... @@ -169,7 +169,7 @@ class SampleTurboModuleExample extends React.Component<{}, State> { | $FlowFixMe | void | RootTag - | Promise + | Promise | number | string | boolean diff --git a/packages/virtualized-lists/Lists/StateSafePureComponent.js b/packages/virtualized-lists/Lists/StateSafePureComponent.js index bf75a6de848..3e04fd9c735 100644 --- a/packages/virtualized-lists/Lists/StateSafePureComponent.js +++ b/packages/virtualized-lists/Lists/StateSafePureComponent.js @@ -34,7 +34,7 @@ export default class StateSafePureComponent< // $FlowFixMe[incompatible-type] setState>( partialState: ?(Pick | ((State, Props) => ?Pick)), - callback?: () => mixed, + callback?: () => unknown, ): void { if (typeof partialState === 'function') { super.setState((state, props) => { diff --git a/packages/virtualized-lists/Utilities/infoLog.js b/packages/virtualized-lists/Utilities/infoLog.js index 963e1356c75..08cc944e83c 100644 --- a/packages/virtualized-lists/Utilities/infoLog.js +++ b/packages/virtualized-lists/Utilities/infoLog.js @@ -13,7 +13,7 @@ /** * Intentional info-level logging for clear separation from ad-hoc console debug logging. */ -function infoLog(...args: Array): void { +function infoLog(...args: Array): void { return console.log(...args); } diff --git a/private/helloworld/cli.flow.js b/private/helloworld/cli.flow.js index b02be3b1386..33d1cd15c95 100644 --- a/private/helloworld/cli.flow.js +++ b/private/helloworld/cli.flow.js @@ -305,7 +305,7 @@ installAndRun await new Listr([ { title: 'Booting simulator', - task: (_: mixed, task) => { + task: (_: unknown, task) => { if (device.state === 'Booted') { task.skip('Simulator currently Booted'); } else { diff --git a/private/helloworld/lib/filesystem.js b/private/helloworld/lib/filesystem.js index 2d6e7d6573f..baf7c19394d 100644 --- a/private/helloworld/lib/filesystem.js +++ b/private/helloworld/lib/filesystem.js @@ -15,7 +15,7 @@ import path from 'path'; const logWatchman = debug('helloworld:cli:watchman'); -export async function pauseWatchman(command: () => Promise) { +export async function pauseWatchman(command: () => Promise) { let p: ReturnType | null = null; try { const raw: string = execSync('watchman watch-project .', { diff --git a/private/react-native-fantom/runner/runner.js b/private/react-native-fantom/runner/runner.js index 1291f684331..eb0e2b9975b 100644 --- a/private/react-native-fantom/runner/runner.js +++ b/private/react-native-fantom/runner/runner.js @@ -207,7 +207,7 @@ module.exports = async function runTest( environment: {...}, runtime: {...}, testPath: string, -): mixed { +): unknown { let coverageMap: CoverageMap | void; const snapshotResolver = await buildSnapshotResolver(config); const snapshotPath = snapshotResolver.resolveSnapshotPath(testPath); diff --git a/private/react-native-fantom/runtime/expect.js b/private/react-native-fantom/runtime/expect.js index 5a465afa96d..8407436cade 100644 --- a/private/react-native-fantom/runtime/expect.js +++ b/private/react-native-fantom/runtime/expect.js @@ -14,7 +14,7 @@ import deepEqual from 'deep-equal'; import {diff} from 'jest-diff'; import {format, plugins} from 'pretty-format'; -const stringify = (data: mixed): string => +const stringify = (data: unknown): string => format(data, {min: true, plugins: [plugins.ReactElement]}); class ErrorWithCustomBlame extends Error { @@ -24,7 +24,7 @@ class ErrorWithCustomBlame extends Error { #cachedProcessedStack: ?string; #customStack: ?string; - constructor(message?: string, options?: {cause?: mixed, ...}) { + constructor(message?: string, options?: {cause?: unknown, ...}) { super(message, options); // The Error constructor forces an own `stack` property that shadows our @@ -76,10 +76,10 @@ class ErrorWithCustomBlame extends Error { } class Expect { - #received: mixed; + #received: unknown; #isNot: boolean = false; - constructor(received: mixed) { + constructor(received: unknown) { this.#received = received; } @@ -89,7 +89,7 @@ class Expect { return this; } - toEqual(expected: mixed): void { + toEqual(expected: unknown): void { const pass = deepEqual(this.#received, expected, {strict: true}); if (!this.#isExpectedResult(pass)) { throw new ErrorWithCustomBlame( @@ -104,12 +104,12 @@ class Expect { } } - toStrictEqual(expected: mixed): void { - let expectedType: mixed = + toStrictEqual(expected: unknown): void { + let expectedType: unknown = typeof expected === 'object' && expected !== null ? Object.getPrototypeOf(expected) : null; - let receivedType: mixed = + let receivedType: unknown = typeof this.#received === 'object' && this.#received !== null ? Object.getPrototypeOf(this.#received) : null; @@ -129,7 +129,7 @@ class Expect { } } - toBe(expected: mixed): void { + toBe(expected: unknown): void { const pass = this.#received === expected; if (!this.#isExpectedResult(pass)) { throw new ErrorWithCustomBlame( @@ -138,7 +138,7 @@ class Expect { } } - toBeInstanceOf(expected: Class): void { + toBeInstanceOf(expected: Class): void { const pass = this.#received instanceof expected; if (!this.#isExpectedResult(pass)) { throw new ErrorWithCustomBlame( @@ -264,8 +264,8 @@ class Expect { } } - toBeCalledWith: (...args: Array) => void; - toHaveBeenCalledWith(...args: Array): void { + toBeCalledWith: (...args: Array) => void; + toHaveBeenCalledWith(...args: Array): void { const mock = this.#requireMock(); const pass = mock.calls.some(callArgs => deepEqual(callArgs, args, {strict: true}), @@ -279,8 +279,8 @@ class Expect { } } - lastCalledWith: (...args: Array) => void; - toHaveBeenLastCalledWith(...args: mixed[]): void { + lastCalledWith: (...args: Array) => void; + toHaveBeenLastCalledWith(...args: unknown[]): void { const mock = this.#requireMock(); if (mock.calls.length === 0) { if (this.#isNot) { @@ -300,8 +300,8 @@ class Expect { } } - nthCalledWith: (index: number, ...args: mixed[]) => void; - toHaveBeenNthCalledWith(index: number, ...args: mixed[]): void { + nthCalledWith: (index: number, ...args: unknown[]) => void; + toHaveBeenNthCalledWith(index: number, ...args: unknown[]): void { if (index < 1) { throw new ErrorWithCustomBlame( `Expected index to be positive number, got ${index}.`, @@ -405,7 +405,7 @@ class Expect { } } - toContain(item: mixed): void { + toContain(item: unknown): void { if (typeof this.#received === 'string') { if (typeof item !== 'string') { throw new ErrorWithCustomBlame( @@ -436,7 +436,7 @@ class Expect { } } - toContainEqual(item: mixed): void { + toContainEqual(item: unknown): void { if (typeof this.#received === 'string') { if (typeof item !== 'string') { throw new ErrorWithCustomBlame( @@ -536,7 +536,7 @@ class Expect { return this.#isNot ? ' not' : ''; } - #requireMock(): JestMockFn, mixed>['mock'] { + #requireMock(): JestMockFn, unknown>['mock'] { try { return ensureMockFunction(this.#received).mock; } catch (error) { @@ -566,6 +566,6 @@ Expect.prototype.lastCalledWith = Expect.prototype.toHaveBeenLastCalledWith; // $FlowExpectedError[method-unbinding] Expect.prototype.nthCalledWith = Expect.prototype.toHaveBeenNthCalledWith; -const expect: mixed => Expect = (received: mixed) => new Expect(received); +const expect: unknown => Expect = (received: unknown) => new Expect(received); export default expect; diff --git a/private/react-native-fantom/runtime/mocks.js b/private/react-native-fantom/runtime/mocks.js index 7394f352ee4..dad9b9f5ab1 100644 --- a/private/react-native-fantom/runtime/mocks.js +++ b/private/react-native-fantom/runtime/mocks.js @@ -12,10 +12,10 @@ export const MOCK_FN_TAG: symbol = Symbol('mock function'); // The type is defined this way because if we get a mixed value, we return // a generic mock function, and if we get a typed function, we get a typed mock. -export const ensureMockFunction: (, TReturn>( +export const ensureMockFunction: (, TReturn>( fn: (...TArgs) => TReturn, ) => JestMockFn) & - ((fn: mixed) => JestMockFn, mixed>) = fn => { + ((fn: unknown) => JestMockFn, unknown>) = fn => { // $FlowExpectedError[invalid-computed-prop] // $FlowExpectedError[incompatible-use] if (typeof fn !== 'function' || !fn[MOCK_FN_TAG]) { @@ -29,7 +29,7 @@ export const ensureMockFunction: (, TReturn>( return fn; }; -export function createMockFunction, TReturn>( +export function createMockFunction, TReturn>( initialImplementation?: (...TArgs) => TReturn, ): JestMockFn { let implementation: ?(...TArgs) => TReturn = initialImplementation; @@ -43,7 +43,7 @@ export function createMockFunction, TReturn>( results: [], }; - const mockFunction = function (this: mixed, ...args: TArgs): TReturn { + const mockFunction = function (this: unknown, ...args: TArgs): TReturn { let result: JestMockFn['mock']['results'][number] = { isThrow: false, // $FlowExpectedError[incompatible-type] diff --git a/private/react-native-fantom/runtime/setup.js b/private/react-native-fantom/runtime/setup.js index f7512981be2..c4d174910a2 100644 --- a/private/react-native-fantom/runtime/setup.js +++ b/private/react-native-fantom/runtime/setup.js @@ -36,7 +36,7 @@ export type FailureDetail = { cause?: FailureDetail, }; -export opaque type CoverageMap = mixed; +export opaque type CoverageMap = unknown; export type TestSuiteResult = | { @@ -56,7 +56,7 @@ type Spec = { ...FocusState, title: string, parentContext: Context, - implementation: () => mixed, + implementation: () => unknown, }; type Suite = Spec | Context; @@ -89,7 +89,7 @@ const globalModifiers: Array<'focused' | 'skipped'> = []; const globalDescribe = (global.describe = ( title: string, - implementation: () => mixed, + implementation: () => unknown, ) => { const parentContext = currentContext; const {focused, skipped} = getFocusState(); @@ -139,7 +139,7 @@ function getFocusState(): {focused: boolean, skipped: boolean} { const globalIt = (global.it = global.test = - (title: string, implementation: () => mixed) => { + (title: string, implementation: () => unknown) => { const {focused, skipped} = getFocusState(); currentContext.children.push({ title, @@ -153,7 +153,7 @@ const globalIt = // $FlowExpectedError[prop-missing] global.fdescribe = global.describe.only = ( title: string, - implementation: () => mixed, + implementation: () => unknown, ) => { globalModifiers.push('focused'); globalDescribe(title, implementation); @@ -165,7 +165,7 @@ global.it.only = global.fit = // $FlowExpectedError[prop-missing] global.test.only = - (title: string, implementation: () => mixed) => { + (title: string, implementation: () => unknown) => { globalModifiers.push('focused'); globalIt(title, implementation); globalModifiers.pop(); @@ -174,7 +174,7 @@ global.it.only = // $FlowExpectedError[prop-missing] global.xdescribe = global.describe.skip = ( title: string, - implementation: () => mixed, + implementation: () => unknown, ) => { globalModifiers.push('skipped'); globalDescribe(title, implementation); @@ -187,7 +187,7 @@ global.it.skip = // $FlowExpectedError[prop-missing] global.test.skip = global.xtest = - (title: string, implementation: () => mixed) => { + (title: string, implementation: () => unknown) => { globalModifiers.push('skipped'); globalIt(title, implementation); globalModifiers.pop(); @@ -325,7 +325,7 @@ function runSpec(spec: Spec): TestCaseResult { } let status: 'passed' | 'failed' | 'pending'; - let error: mixed; + let error: unknown; const start = Date.now(); snapshotContext.setTargetTest(result.fullName); @@ -336,7 +336,7 @@ function runSpec(spec: Spec): TestCaseResult { invokeHooks(spec.parentContext, 'afterEachHooks'); status = 'passed'; - } catch (e: mixed) { + } catch (e: unknown) { error = e; status = 'failed'; } diff --git a/private/react-native-fantom/src/getFantomRenderedOutput.js b/private/react-native-fantom/src/getFantomRenderedOutput.js index a0599ef1365..6bae7d91a81 100644 --- a/private/react-native-fantom/src/getFantomRenderedOutput.js +++ b/private/react-native-fantom/src/getFantomRenderedOutput.js @@ -162,7 +162,7 @@ function convertRawJsonToJSX( function createJSXElementForTestComparison( type: string, - props: mixed, + props: unknown, key?: ?string, ): React.Node { const Tag = type; diff --git a/private/react-native-fantom/src/index.js b/private/react-native-fantom/src/index.js index fb72b567393..dc96181baf3 100644 --- a/private/react-native-fantom/src/index.js +++ b/private/react-native-fantom/src/index.js @@ -222,7 +222,7 @@ export function unstable_produceFramesForDuration(milliseconds: number) { export function unstable_getDirectManipulationProps( nodeOrRef: NodeOrRef, ): $ReadOnly<{ - [string]: mixed, + [string]: unknown, }> { const node = getNode(nodeOrRef); const shadowNode = getNativeNodeReference(node); @@ -230,7 +230,7 @@ export function unstable_getDirectManipulationProps( } export function unstable_getFabricUpdateProps(nodeOrRef: NodeOrRef): $ReadOnly<{ - [string]: mixed, + [string]: unknown, }> { const node = getNode(nodeOrRef); const shadowNode = getNativeNodeReference(node); @@ -400,7 +400,7 @@ export function createRoot(rootConfig?: RootConfig): Root { export function enqueueNativeEvent( nodeOrRef: NodeOrRef, type: string, - payload?: $ReadOnly<{[key: string]: mixed}>, + payload?: $ReadOnly<{[key: string]: unknown}>, options?: $ReadOnly<{category?: NativeEventCategory, isUnique?: boolean}>, ) { const node = getNode(nodeOrRef); @@ -432,7 +432,7 @@ export function enqueueNativeEvent( export function dispatchNativeEvent( nodeOrRef: NodeOrRef, type: string, - payload?: $ReadOnly<{[key: string]: mixed}>, + payload?: $ReadOnly<{[key: string]: unknown}>, options?: $ReadOnly<{category?: NativeEventCategory, isUnique?: boolean}>, ) { const node = getNode(nodeOrRef); @@ -632,7 +632,7 @@ export function takeJSMemoryHeapSnapshot(): void { try { NativeFantom.saveJSMemoryHeapSnapshot(filePath); - } catch (nativeError: mixed) { + } catch (nativeError: unknown) { let errorMessage = 'Error saving JS heap snapshot.'; if ( nativeError instanceof Error && diff --git a/scripts/js-api/build-types/buildApiSnapshot.js b/scripts/js-api/build-types/buildApiSnapshot.js index 7bcab6f2101..2e204be046f 100644 --- a/scripts/js-api/build-types/buildApiSnapshot.js +++ b/scripts/js-api/build-types/buildApiSnapshot.js @@ -30,14 +30,14 @@ const osTempDir = require('temp-dir'); const {globSync} = require('tinyglobby'); const {styleText} = require('util'); -const inputFilesPostTransforms: $ReadOnlyArray> = [ +const inputFilesPostTransforms: $ReadOnlyArray> = [ require('./transforms/typescript/renameDefaultExportedIdentifiers'), require('./transforms/typescript/stripUnstableApis'), ]; const postTransforms = ( options: BuildApiSnapshotOptions, -): $ReadOnlyArray> => [ +): $ReadOnlyArray> => [ require('./transforms/typescript/simplifyTypes'), require('./transforms/typescript/sortProperties'), require('./transforms/typescript/sortUnions'), diff --git a/scripts/js-api/build-types/transforms/typescript/organizeDeclarations.js b/scripts/js-api/build-types/transforms/typescript/organizeDeclarations.js index e9ecfa5a257..17b65908b9b 100644 --- a/scripts/js-api/build-types/transforms/typescript/organizeDeclarations.js +++ b/scripts/js-api/build-types/transforms/typescript/organizeDeclarations.js @@ -19,7 +19,7 @@ import * as t from '@babel/types'; * - Sorts declarations alphabetically. * - Moves all exports into a single block at the end of the file. */ -const visitor: PluginObj = { +const visitor: PluginObj = { visitor: { Program(path) { const exportedIdentifiers: Set = new Set(); diff --git a/scripts/js-api/build-types/transforms/typescript/removeUndefinedFromOptionalMembers.js b/scripts/js-api/build-types/transforms/typescript/removeUndefinedFromOptionalMembers.js index cd7fbb2b6d2..195ec9262d8 100644 --- a/scripts/js-api/build-types/transforms/typescript/removeUndefinedFromOptionalMembers.js +++ b/scripts/js-api/build-types/transforms/typescript/removeUndefinedFromOptionalMembers.js @@ -12,7 +12,7 @@ import type {PluginObj} from '@babel/core'; import * as t from '@babel/types'; -const visitor: PluginObj = { +const visitor: PluginObj = { visitor: { TSPropertySignature(path) { if (path.node.optional !== true) { diff --git a/scripts/js-api/build-types/transforms/typescript/renameDefaultExportedIdentifiers.js b/scripts/js-api/build-types/transforms/typescript/renameDefaultExportedIdentifiers.js index 30ab96dbc0c..cf5723acb0c 100644 --- a/scripts/js-api/build-types/transforms/typescript/renameDefaultExportedIdentifiers.js +++ b/scripts/js-api/build-types/transforms/typescript/renameDefaultExportedIdentifiers.js @@ -22,7 +22,7 @@ import * as t from '@babel/types'; * the symbol. Finally, it replaces occurences of the local symbol by suffixing * it with `_default`. */ -const visitor: PluginObj = { +const visitor: PluginObj = { visitor: { Program(nodePath) { let localSymbol: ?string = null; diff --git a/scripts/js-api/build-types/transforms/typescript/replaceDefaultExportName.js b/scripts/js-api/build-types/transforms/typescript/replaceDefaultExportName.js index 19f00a70b03..8b3dedcea88 100644 --- a/scripts/js-api/build-types/transforms/typescript/replaceDefaultExportName.js +++ b/scripts/js-api/build-types/transforms/typescript/replaceDefaultExportName.js @@ -10,7 +10,7 @@ import type {PluginObj} from '@babel/core'; -function createDefaultExportNameReplacer(filePath: string): PluginObj { +function createDefaultExportNameReplacer(filePath: string): PluginObj { return { visitor: { Identifier(node) { diff --git a/scripts/js-api/build-types/transforms/typescript/simplifyTypes/index.js b/scripts/js-api/build-types/transforms/typescript/simplifyTypes/index.js index 0bedaff69e0..14035ab46c4 100644 --- a/scripts/js-api/build-types/transforms/typescript/simplifyTypes/index.js +++ b/scripts/js-api/build-types/transforms/typescript/simplifyTypes/index.js @@ -65,4 +65,4 @@ const mergeObjects: PluginObj = { }; // Visitor state is only used internally, so we can safely cast to PluginObj. -module.exports = mergeObjects as $FlowFixMe as PluginObj; +module.exports = mergeObjects as $FlowFixMe as PluginObj; diff --git a/scripts/js-api/build-types/transforms/typescript/simplifyTypes/inlineTypesVisitor.js b/scripts/js-api/build-types/transforms/typescript/simplifyTypes/inlineTypesVisitor.js index cabdf4c5a4c..6c06ef80ebe 100644 --- a/scripts/js-api/build-types/transforms/typescript/simplifyTypes/inlineTypesVisitor.js +++ b/scripts/js-api/build-types/transforms/typescript/simplifyTypes/inlineTypesVisitor.js @@ -253,4 +253,4 @@ const inlineTypes: PluginObj = { }; // Visitor state is only used internally, so we can safely cast to PluginObj. -module.exports = inlineTypes as $FlowFixMe as PluginObj; +module.exports = inlineTypes as $FlowFixMe as PluginObj; diff --git a/scripts/js-api/build-types/transforms/typescript/sortProperties.js b/scripts/js-api/build-types/transforms/typescript/sortProperties.js index d2e06765bb9..b206b9caf8d 100644 --- a/scripts/js-api/build-types/transforms/typescript/sortProperties.js +++ b/scripts/js-api/build-types/transforms/typescript/sortProperties.js @@ -78,7 +78,7 @@ function sortMembers(members: T[]): T[] { .concat(enumMembers); } -const visitor: PluginObj = { +const visitor: PluginObj = { visitor: { TSInterfaceBody(path) { path.node.body = sortMembers(path.node.body); diff --git a/scripts/js-api/build-types/transforms/typescript/sortUnions.js b/scripts/js-api/build-types/transforms/typescript/sortUnions.js index a0bdc72acef..bf2f7bb2f14 100644 --- a/scripts/js-api/build-types/transforms/typescript/sortUnions.js +++ b/scripts/js-api/build-types/transforms/typescript/sortUnions.js @@ -13,7 +13,7 @@ import type {PluginObj} from '@babel/core'; import generate from '@babel/generator'; import * as t from '@babel/types'; -const visitor: PluginObj = { +const visitor: PluginObj = { visitor: { TSUnionType(path) { path.node.types.sort((a, b) => { diff --git a/scripts/js-api/build-types/transforms/typescript/stripUnstableApis.js b/scripts/js-api/build-types/transforms/typescript/stripUnstableApis.js index 9289bb60c72..bcb8c032dbf 100644 --- a/scripts/js-api/build-types/transforms/typescript/stripUnstableApis.js +++ b/scripts/js-api/build-types/transforms/typescript/stripUnstableApis.js @@ -18,7 +18,7 @@ function isUnstableSymbol(name: ?string): boolean { ); } -const stripUnstableProperties: PluginObj = { +const stripUnstableProperties: PluginObj = { visitor: { TSPropertySignature(path) { if (isUnstableSymbol(path.node.key.name)) { diff --git a/scripts/js-api/build-types/transforms/typescript/versionExportedApis.js b/scripts/js-api/build-types/transforms/typescript/versionExportedApis.js index 74632a3581a..5b257e4beb3 100644 --- a/scripts/js-api/build-types/transforms/typescript/versionExportedApis.js +++ b/scripts/js-api/build-types/transforms/typescript/versionExportedApis.js @@ -31,7 +31,7 @@ const debug = require('debug')('build-types:transforms:versionExportedApis'); */ function createVersionExportedApis( outputDebugAnnotations: boolean = false, -): PluginObj { +): PluginObj { return { visitor: { Program(path) { diff --git a/scripts/js-api/build-types/translateSourceFile.js b/scripts/js-api/build-types/translateSourceFile.js index 16cd92a81b7..1bdb5fc0d4f 100644 --- a/scripts/js-api/build-types/translateSourceFile.js +++ b/scripts/js-api/build-types/translateSourceFile.js @@ -28,7 +28,7 @@ const preTransforms: Array = [ require('./transforms/flow/reattachDocComments'), require('./transforms/flow/ensureNoUnprefixedProps'), ]; -const postTransforms = (filePath: string): Array> => [ +const postTransforms = (filePath: string): Array> => [ require('./transforms/typescript/replaceDefaultExportName')(filePath), ]; const prettierOptions = {parser: 'babel'}; diff --git a/scripts/js-api/build-types/utils/applyBabelTransformsSeq.js b/scripts/js-api/build-types/utils/applyBabelTransformsSeq.js index 3c26e0f92d4..3fdff610cdc 100644 --- a/scripts/js-api/build-types/utils/applyBabelTransformsSeq.js +++ b/scripts/js-api/build-types/utils/applyBabelTransformsSeq.js @@ -17,7 +17,7 @@ import * as babel from '@babel/core'; */ async function applyBabelTransformsSeq( source: string, - transforms: $ReadOnlyArray>, + transforms: $ReadOnlyArray>, ): Promise { const parsed = await babel.parseAsync(source, { plugins: ['@babel/plugin-syntax-typescript'], diff --git a/scripts/releases/__tests__/snapshot-utils.js b/scripts/releases/__tests__/snapshot-utils.js index 5a0103a88c2..269efee1796 100644 --- a/scripts/releases/__tests__/snapshot-utils.js +++ b/scripts/releases/__tests__/snapshot-utils.js @@ -25,7 +25,7 @@ function sanitizeSnapshots( tokenOrPattern: string | RegExp | (() => string | RegExp), replacement: string, ): JestPrettyFormatPlugin { - const test = (val: mixed) => { + const test = (val: unknown) => { if (typeof val !== 'string') { return false; } @@ -39,11 +39,11 @@ function sanitizeSnapshots( return tokenOrPatternToTest.test(val); }; const serialize = ( - val: mixed, - config: mixed, - indentation: mixed, - depth: mixed, - refs: mixed, + val: unknown, + config: unknown, + indentation: unknown, + depth: unknown, + refs: unknown, // $FlowFixMe[unclear-type] TODO: add up-to-date and accurate types for Jest snapshot serializers. printer: any, ) => { diff --git a/scripts/releases/utils/octokit-utils.js b/scripts/releases/utils/octokit-utils.js index ce5f7e07be4..9e7f1ff4897 100644 --- a/scripts/releases/utils/octokit-utils.js +++ b/scripts/releases/utils/octokit-utils.js @@ -53,6 +53,6 @@ export interface IOctokit { repo: string, asset_id: string, ... - }) => Promise, + }) => Promise, }>; }