diff --git a/packages/react-native/Libraries/Blob/File.js b/packages/react-native/Libraries/Blob/File.js index 0783d1c503b6..ccbd83dba703 100644 --- a/packages/react-native/Libraries/Blob/File.js +++ b/packages/react-native/Libraries/Blob/File.js @@ -4,10 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ +// flowlint unsafe-getters-setters:off + 'use strict'; import type {BlobOptions} from './BlobTypes'; diff --git a/packages/react-native/Libraries/Blob/FileReader.js b/packages/react-native/Libraries/Blob/FileReader.js index 98e7f8c9da15..07c5744d9c29 100644 --- a/packages/react-native/Libraries/Blob/FileReader.js +++ b/packages/react-native/Libraries/Blob/FileReader.js @@ -4,10 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ +// flowlint unsafe-getters-setters:off + import type {EventCallback} from '../../src/private/webapis/dom/events/EventTarget'; import type Blob from './Blob'; diff --git a/packages/react-native/Libraries/Blob/URL.js b/packages/react-native/Libraries/Blob/URL.js index f4f879a51214..3da963315be3 100644 --- a/packages/react-native/Libraries/Blob/URL.js +++ b/packages/react-native/Libraries/Blob/URL.js @@ -4,10 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ +// flowlint unsafe-getters-setters:off + import type Blob from './Blob'; import NativeBlobModule from './NativeBlobModule'; @@ -79,6 +81,7 @@ export class URL { // $FlowFixMe[missing-local-annot] constructor(url: string, base?: string | URL) { let baseUrl = null; + // $FlowFixMe[sketchy-null-string] if (!base || validateBaseUrl(url)) { this._url = url; if (this._url.includes('#')) { @@ -112,13 +115,14 @@ export class URL { if (baseUrl.endsWith('/')) { baseUrl = baseUrl.slice(0, baseUrl.length - 1); } - if (!url.startsWith('/')) { - url = `/${url}`; + let path = url; + if (!path.startsWith('/')) { + path = `/${path}`; } - if (baseUrl.endsWith(url)) { - url = ''; + if (baseUrl.endsWith(path)) { + path = ''; } - this._url = `${baseUrl}${url}`; + this._url = `${baseUrl}${path}`; } } diff --git a/packages/react-native/Libraries/Blob/URLSearchParams.js b/packages/react-native/Libraries/Blob/URLSearchParams.js index d325f7bb25a8..1cf3ef6b2f4e 100644 --- a/packages/react-native/Libraries/Blob/URLSearchParams.js +++ b/packages/react-native/Libraries/Blob/URLSearchParams.js @@ -4,10 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ +// flowlint unsafe-getters-setters:off + // Small subset from whatwg-url: https://github.com/jsdom/whatwg-url/tree/master/src // The reference code bloat comes from Unicode issues with URLs, so those won't work here. export class URLSearchParams { diff --git a/packages/react-native/Libraries/Blob/URLSearchParams.js.flow b/packages/react-native/Libraries/Blob/URLSearchParams.js.flow index df5b32557dda..fe7741a88d41 100644 --- a/packages/react-native/Libraries/Blob/URLSearchParams.js.flow +++ b/packages/react-native/Libraries/Blob/URLSearchParams.js.flow @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ diff --git a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js index 3200bb8afc56..f021d43aad26 100644 --- a/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js +++ b/packages/react-native/Libraries/Components/ActivityIndicator/ActivityIndicator.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -115,7 +115,7 @@ const ActivityIndicator: component( style, ...restProps }: { - ref?: any, + ref?: React.RefSetter, ...ActivityIndicatorProps, }) => { let sizeStyle; diff --git a/packages/react-native/Libraries/Components/Button.js b/packages/react-native/Libraries/Components/Button.js index c1bec4b65edf..cf283e552318 100644 --- a/packages/react-native/Libraries/Components/Button.js +++ b/packages/react-native/Libraries/Components/Button.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -232,7 +232,7 @@ const Button: component( } = props; const buttonStyles: Array = [styles.button]; const textStyles: Array = [styles.text]; - if (color) { + if (Boolean(color)) { if (Platform.OS === 'ios') { textStyles.push({color: color}); } else { @@ -256,7 +256,7 @@ const Button: component( ? {..._accessibilityState, disabled} : _accessibilityState; - if (disabled) { + if (disabled === true) { buttonStyles.push(styles.buttonDisabled); textStyles.push(styles.textDisabled); } @@ -279,7 +279,10 @@ const Button: component( accessible={accessible} accessibilityActions={accessibilityActions} onAccessibilityAction={onAccessibilityAction} - accessibilityLabel={ariaLabel || accessibilityLabel} + accessibilityLabel={ + // $FlowFixMe[sketchy-null-string] + ariaLabel || accessibilityLabel + } accessibilityHint={accessibilityHint} accessibilityLanguage={accessibilityLanguage} accessibilityRole="button" diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js index 77c72316cfe8..0ee0b92b667c 100644 --- a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js @@ -4,10 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ +// flowlint unsafe-getters-setters:off + import type { MeasureInWindowOnSuccessCallback, MeasureLayoutOnSuccessCallback, @@ -204,7 +206,7 @@ class DrawerLayoutAndroid ); } - setNativeProps(nativeProps: Object) { + setNativeProps(nativeProps: {...}) { nullthrows(this._nativeRef.current).setNativeProps(nativeProps); } } diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js index 5776fd4f500e..0bf8cca18b4d 100644 --- a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ diff --git a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js index c5b16a13e090..cbe137320123 100644 --- a/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +++ b/packages/react-native/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -127,7 +127,7 @@ export interface DrawerLayoutAndroidMethods { onSuccess: MeasureLayoutOnSuccessCallback, onFail?: () => void, ): void; - setNativeProps(nativeProps: Object): void; + setNativeProps(nativeProps: {...}): void; } export type DrawerLayoutAndroidInstance = DrawerLayoutAndroidMethods; diff --git a/packages/react-native/Libraries/Components/StatusBar/StatusBar.js b/packages/react-native/Libraries/Components/StatusBar/StatusBar.js index 0cd2315373ae..bab23467263c 100644 --- a/packages/react-native/Libraries/Components/StatusBar/StatusBar.js +++ b/packages/react-native/Libraries/Components/StatusBar/StatusBar.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -101,13 +101,25 @@ export type StatusBarProps = Readonly<{ type StackProps = { barStyle: ?{ - value: StatusBarProps['barStyle'], + value: StatusBarStyle, animated: boolean, }, hidden: ?{ value: boolean, animated: boolean, - transition: StatusBarProps['showHideTransition'], + transition: StatusBarAnimation, + }, +}; + +type ResolvedStackProps = { + barStyle: { + value: StatusBarStyle, + animated: boolean, + }, + hidden: { + value: boolean, + animated: boolean, + transition: StatusBarAnimation, }, }; @@ -126,13 +138,16 @@ function getAutoBarStyle(): 'light-content' | 'dark-content' { * barStyle to a concrete value. */ function mergePropsStack( - propsStack: Array, - defaultValues: Object, -): Object { - const merged: StackProps = propsStack.reduce( + propsStack: Array, + defaultValues: ResolvedStackProps, +): ResolvedStackProps { + const merged: ResolvedStackProps = propsStack.reduce( (prev, cur) => { for (const prop in cur) { + // $FlowFixMe[invalid-computed-prop] dynamic merge over the known StackProps keys if (cur[prop] != null) { + // $FlowFixMe[invalid-computed-prop] dynamic merge over the known StackProps keys + // $FlowFixMe[prop-missing] dynamic merge over the known StackProps keys prev[prop] = cur[prop]; } } @@ -141,7 +156,7 @@ function mergePropsStack( {...defaultValues}, ); - if (merged.barStyle?.value === 'auto') { + if (merged.barStyle.value === 'auto') { merged.barStyle = {...merged.barStyle, value: getAutoBarStyle()}; } @@ -224,10 +239,10 @@ function createStackEntry(props: StatusBarProps): StackProps { class StatusBar extends React.Component { static _propsStack: Array = []; - static _defaultProps: any = createStackEntry({ - barStyle: 'default', - hidden: false, - }); + static _defaultProps: ResolvedStackProps = { + barStyle: {value: 'default', animated: false}, + hidden: {value: false, animated: false, transition: 'fade'}, + }; // Timer for updating the native module values at the end of the frame. static _updateImmediate: ?number = null; @@ -235,7 +250,7 @@ class StatusBar extends React.Component { // The current merged values from the props stack. `barStyle.value` is stored // in its resolved form (never `'auto'`), so diff comparisons reflect what // was actually sent to the native module. - static _currentValues: ?StackProps = null; + static _currentValues: ?ResolvedStackProps = null; // Number of mounted `StatusBar` instances. Used to lazily subscribe to color // scheme changes only while at least one instance is on screen. @@ -264,10 +279,10 @@ class StatusBar extends React.Component { * changing the status bar hidden property. */ static setHidden(hidden: boolean, animation?: StatusBarAnimation) { - animation = animation || 'none'; + const resolvedAnimation = animation ?? 'none'; StatusBar._defaultProps.hidden.value = hidden; if (Platform.OS === 'ios') { - NativeStatusBarManagerIOS.setHidden(hidden, animation); + NativeStatusBarManagerIOS.setHidden(hidden, resolvedAnimation); } else if (Platform.OS === 'android') { NativeStatusBarManagerAndroid.setHidden(hidden); } @@ -279,11 +294,11 @@ class StatusBar extends React.Component { * @param animated Animate the style change. */ static setBarStyle(style: StatusBarStyle, animated?: boolean) { - animated = animated || false; + const resolvedAnimated = animated ?? false; StatusBar._defaultProps.barStyle.value = style; const resolvedStyle = style === 'auto' ? getAutoBarStyle() : style; if (Platform.OS === 'ios') { - NativeStatusBarManagerIOS.setStyle(resolvedStyle, animated); + NativeStatusBarManagerIOS.setStyle(resolvedStyle, resolvedAnimated); } else if (Platform.OS === 'android') { NativeStatusBarManagerAndroid.setStyle(resolvedStyle); } diff --git a/packages/react-native/Libraries/Components/Touchable/Touchable.js b/packages/react-native/Libraries/Components/Touchable/Touchable.js index 827477f98c5b..8c5605366426 100644 --- a/packages/react-native/Libraries/Components/Touchable/Touchable.js +++ b/packages/react-native/Libraries/Components/Touchable/Touchable.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -331,7 +331,7 @@ const TouchableMixinImpl = { */ /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by * Flow's LTI update could not be added via codemod */ - touchableHandleResponderTerminationRequest: function (): any { + touchableHandleResponderTerminationRequest: function (): boolean { return !this.props.rejectResponderTermination; }, @@ -340,7 +340,7 @@ const TouchableMixinImpl = { */ /* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by * Flow's LTI update could not be added via codemod */ - touchableHandleStartShouldSetResponder: function (): any { + touchableHandleStartShouldSetResponder: function (): boolean { return !this.props.disabled; }, diff --git a/packages/react-native/Libraries/Core/Timers/immediateShim.js b/packages/react-native/Libraries/Core/Timers/immediateShim.js index 6e9534de1621..df84d573ed3f 100644 --- a/packages/react-native/Libraries/Core/Timers/immediateShim.js +++ b/packages/react-native/Libraries/Core/Timers/immediateShim.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format * @deprecated */ @@ -22,7 +22,10 @@ const clearedImmediates: Set = new Set(); * @param {function} func Callback to be invoked before the end of the * current JavaScript execution loop. */ -export function setImmediate(callback: Function, ...args: any): number { +export function setImmediate>( + callback: (...args: TArgs) => unknown, + ...args: TArgs +): number { if (arguments.length < 1) { throw new TypeError( 'setImmediate must be called with at least one argument (a function to call)', @@ -41,7 +44,6 @@ export function setImmediate(callback: Function, ...args: any): number { clearedImmediates.delete(id); } - // $FlowFixMe[incompatible-type] global.queueMicrotask(() => { if (!clearedImmediates.has(id)) { callback.apply(undefined, args); diff --git a/packages/react-native/Libraries/Core/Timers/queueMicrotask.js b/packages/react-native/Libraries/Core/Timers/queueMicrotask.js index 34741aa1f838..efc8a3da277f 100644 --- a/packages/react-native/Libraries/Core/Timers/queueMicrotask.js +++ b/packages/react-native/Libraries/Core/Timers/queueMicrotask.js @@ -4,13 +4,13 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ 'use strict'; -let resolvedPromise; +let resolvedPromise: ?Promise; /** * Polyfill for the microtask queueing API defined by WHATWG HTML spec. @@ -19,7 +19,7 @@ let resolvedPromise; * The method must queue a microtask to invoke @param {function} callback, and * if the callback throws an exception, report the exception. */ -export default function queueMicrotask(callback: Function) { +export default function queueMicrotask(callback: () => unknown) { if (arguments.length < 1) { throw new TypeError( 'queueMicrotask must be called with at least one argument (a function to call)', @@ -30,7 +30,6 @@ export default function queueMicrotask(callback: Function) { } // Try to reuse a lazily allocated resolved promise from closure. - // $FlowFixMe[constant-condition] (resolvedPromise || (resolvedPromise = Promise.resolve())) .then(callback) .catch(error => diff --git a/packages/react-native/Libraries/ReactNative/AppRegistry.js b/packages/react-native/Libraries/ReactNative/AppRegistry.js index 036749c3514a..20e2168f0d62 100644 --- a/packages/react-native/Libraries/ReactNative/AppRegistry.js +++ b/packages/react-native/Libraries/ReactNative/AppRegistry.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ diff --git a/packages/react-native/Libraries/ReactNative/AppRegistry.js.flow b/packages/react-native/Libraries/ReactNative/AppRegistry.js.flow index aa5c650107ac..792f2c87e562 100644 --- a/packages/react-native/Libraries/ReactNative/AppRegistry.js.flow +++ b/packages/react-native/Libraries/ReactNative/AppRegistry.js.flow @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ diff --git a/packages/react-native/Libraries/ReactNative/AppRegistryImpl.js b/packages/react-native/Libraries/ReactNative/AppRegistryImpl.js index 33e0c84f3ba1..3166cbd5678d 100644 --- a/packages/react-native/Libraries/ReactNative/AppRegistryImpl.js +++ b/packages/react-native/Libraries/ReactNative/AppRegistryImpl.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -113,7 +113,7 @@ export function registerComponent( displayMode, }); }; - if (section) { + if (section === true) { sections[appKey] = runnables[appKey]; } return appKey; @@ -220,7 +220,7 @@ export function runApplication( */ export function setSurfaceProps( appKey: string, - appParameters: Object, + appParameters: AppParameters, displayMode?: number, ): void { if (appKey !== 'LogBox') { @@ -264,7 +264,6 @@ export function registerHeadlessTask( taskKey: string, taskProvider: TaskProvider, ): void { - // $FlowFixMe[object-this-reference] registerCancellableHeadlessTask(taskKey, taskProvider, () => () => { /* Cancel is no-op */ }); @@ -300,7 +299,7 @@ export function registerCancellableHeadlessTask( export function startHeadlessTask( taskId: number, taskKey: string, - data: any, + data: unknown, ): void { const NativeHeadlessJsTaskSupport = require('./NativeHeadlessJsTaskSupport').default; @@ -326,8 +325,7 @@ export function startHeadlessTask( NativeHeadlessJsTaskSupport && reason instanceof HeadlessJsTaskError ) { - // $FlowFixMe[unused-promise] - NativeHeadlessJsTaskSupport.notifyTaskRetry(taskId).then( + void NativeHeadlessJsTaskSupport.notifyTaskRetry(taskId).then( retryPosted => { if (!retryPosted) { NativeHeadlessJsTaskSupport.notifyTaskFinished(taskId); diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheet.js b/packages/react-native/Libraries/StyleSheet/StyleSheet.js index 529b9f3b6568..a6ec58a3fc9d 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheet.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheet.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow b/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow index 101d782aa278..28c096e51e00 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow +++ b/packages/react-native/Libraries/StyleSheet/StyleSheet.js.flow @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetExports.js.flow b/packages/react-native/Libraries/StyleSheet/StyleSheetExports.js.flow index 2aa4ee1d3ffb..9520c8d24788 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetExports.js.flow +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetExports.js.flow @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -86,9 +86,9 @@ declare export const flatten: typeof flattenStyle; * internally to process color and transform values. You should not use this * unless you really know what you are doing and have exhausted other options. */ -declare export const setStyleAttributePreprocessor: ( +declare export const setStyleAttributePreprocessor: ( property: string, - process: (nextProp: any) => any, + process: (nextProp: T) => unknown, ) => void; /** diff --git a/packages/react-native/Libraries/StyleSheet/processFilter.js b/packages/react-native/Libraries/StyleSheet/processFilter.js index 50e3e04ef1b7..0e1a246d2ba5 100644 --- a/packages/react-native/Libraries/StyleSheet/processFilter.js +++ b/packages/react-native/Libraries/StyleSheet/processFilter.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format strict-local */ @@ -51,13 +51,13 @@ export default function processFilter( } if (typeof filter === 'string') { - filter = filter.replace(NEWLINE_REGEX, ' '); + const normalizedFilter = filter.replace(NEWLINE_REGEX, ' '); // matches on functions with args and nested functions like "drop-shadow(10 10 10 rgba(0, 0, 0, 1))" FILTER_FUNCTION_REGEX.lastIndex = 0; let matches; - while ((matches = FILTER_FUNCTION_REGEX.exec(filter))) { + while ((matches = FILTER_FUNCTION_REGEX.exec(normalizedFilter))) { let filterName = matches[1].toLowerCase(); if (filterName === 'drop-shadow') { const dropShadow = parseDropShadow(matches[2]); @@ -159,7 +159,7 @@ function _getFilterAmount(filterName: string, filterArgs: unknown): ?number { // blur takes any positive CSS length that is not a percent. In RN // we currently only have DIPs, so we are not parsing units here. case 'blur': - if ((unit && unit !== 'px') || filterArgAsNumber < 0) { + if ((Boolean(unit) && unit !== 'px') || filterArgAsNumber < 0) { return undefined; } return filterArgAsNumber; @@ -173,7 +173,10 @@ function _getFilterAmount(filterName: string, filterArgs: unknown): ?number { case 'opacity': case 'saturate': case 'sepia': - if ((unit && unit !== '%' && unit !== 'px') || filterArgAsNumber < 0) { + if ( + (Boolean(unit) && unit !== '%' && unit !== 'px') || + filterArgAsNumber < 0 + ) { return undefined; } if (unit === '%') { diff --git a/packages/react-native/Libraries/StyleSheet/processTransformOrigin.js b/packages/react-native/Libraries/StyleSheet/processTransformOrigin.js index 5c132d92ae43..b90d3ced96e0 100644 --- a/packages/react-native/Libraries/StyleSheet/processTransformOrigin.js +++ b/packages/react-native/Libraries/StyleSheet/processTransformOrigin.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -20,10 +20,11 @@ const INDEX_Z = 2; /* eslint-disable no-labels */ export default function processTransformOrigin( - transformOrigin: Array | string, + transformOriginInput: Array | string, ): Array { - if (typeof transformOrigin === 'string') { - const transformOriginString = transformOrigin; + let transformOrigin: Array; + if (typeof transformOriginInput === 'string') { + const transformOriginString = transformOriginInput; TRANSFORM_ORIGIN_REGEX.lastIndex = 0; const transformOriginArray: Array = ['50%', '50%', 0]; @@ -111,6 +112,8 @@ export default function processTransformOrigin( } transformOrigin = transformOriginArray; + } else { + transformOrigin = transformOriginInput; } if (__DEV__) { diff --git a/packages/react-native/Libraries/StyleSheet/setNormalizedColorAlpha.js b/packages/react-native/Libraries/StyleSheet/setNormalizedColorAlpha.js index b412b260a30c..975243ad9eed 100644 --- a/packages/react-native/Libraries/StyleSheet/setNormalizedColorAlpha.js +++ b/packages/react-native/Libraries/StyleSheet/setNormalizedColorAlpha.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -17,15 +17,16 @@ * alpha should be number between 0 and 1 */ function setNormalizedColorAlpha(input: number, alpha: number): number { - if (alpha < 0) { - alpha = 0; - } else if (alpha > 1) { - alpha = 1; + let normalizedAlpha = alpha; + if (normalizedAlpha < 0) { + normalizedAlpha = 0; + } else if (normalizedAlpha > 1) { + normalizedAlpha = 1; } - alpha = Math.round(alpha * 255); + normalizedAlpha = Math.round(normalizedAlpha * 255); // magic bitshift guarantees we return an unsigned int - return ((input & 0xffffff00) | alpha) >>> 0; + return ((input & 0xffffff00) | normalizedAlpha) >>> 0; } export default setNormalizedColorAlpha; diff --git a/packages/react-native/Libraries/Utilities/BackHandler.js.flow b/packages/react-native/Libraries/Utilities/BackHandler.js.flow index 68cc9095f5b5..4c1debea88b0 100644 --- a/packages/react-native/Libraries/Utilities/BackHandler.js.flow +++ b/packages/react-native/Libraries/Utilities/BackHandler.js.flow @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ diff --git a/packages/react-native/Libraries/Utilities/FeatureDetection.js b/packages/react-native/Libraries/Utilities/FeatureDetection.js index 83cdd80ac4e1..3429a76f04ab 100644 --- a/packages/react-native/Libraries/Utilities/FeatureDetection.js +++ b/packages/react-native/Libraries/Utilities/FeatureDetection.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -15,7 +15,9 @@ * Note that a polyfill can technically fake this behavior but few does it. * Therefore, this is usually good enough for our purpose. */ -export function isNativeFunction(f: Function): boolean { +export function isNativeFunction( + f: (...args: ReadonlyArray) => unknown, +): boolean { return typeof f === 'function' && f.toString().indexOf('[native code]') > -1; } @@ -23,7 +25,10 @@ export function isNativeFunction(f: Function): boolean { * @return whether or not the constructor of @param {object} o is an native * function named with @param {string} expectedName. */ -export function hasNativeConstructor(o: Object, expectedName: string): boolean { +export function hasNativeConstructor( + o: interface {}, + expectedName: string, +): boolean { const con = Object.getPrototypeOf(o).constructor; return con.name === expectedName && isNativeFunction(con); } diff --git a/packages/react-native/Libraries/Utilities/differ/insetsDiffer.js b/packages/react-native/Libraries/Utilities/differ/insetsDiffer.js index 0742df32c31e..c504e64543a1 100644 --- a/packages/react-native/Libraries/Utilities/differ/insetsDiffer.js +++ b/packages/react-native/Libraries/Utilities/differ/insetsDiffer.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -26,14 +26,14 @@ const dummyInsets = { }; function insetsDiffer(one: Inset, two: Inset): boolean { - one = one || dummyInsets; - two = two || dummyInsets; + const insetOne = one || dummyInsets; + const insetTwo = two || dummyInsets; return ( - one !== two && - (one.top !== two.top || - one.left !== two.left || - one.right !== two.right || - one.bottom !== two.bottom) + insetOne !== insetTwo && + (insetOne.top !== insetTwo.top || + insetOne.left !== insetTwo.left || + insetOne.right !== insetTwo.right || + insetOne.bottom !== insetTwo.bottom) ); } diff --git a/packages/react-native/Libraries/Utilities/differ/pointsDiffer.js b/packages/react-native/Libraries/Utilities/differ/pointsDiffer.js index 9bf891f914e2..cf5e7551b793 100644 --- a/packages/react-native/Libraries/Utilities/differ/pointsDiffer.js +++ b/packages/react-native/Libraries/Utilities/differ/pointsDiffer.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -19,9 +19,12 @@ type Point = { const dummyPoint: Point = {x: undefined, y: undefined}; function pointsDiffer(one: ?Point, two: ?Point): boolean { - one = one || dummyPoint; - two = two || dummyPoint; - return one !== two && (one.x !== two.x || one.y !== two.y); + const onePoint = one || dummyPoint; + const twoPoint = two || dummyPoint; + return ( + onePoint !== twoPoint && + (onePoint.x !== twoPoint.x || onePoint.y !== twoPoint.y) + ); } export default pointsDiffer; diff --git a/packages/react-native/Libraries/Utilities/stringifyViewConfig.js b/packages/react-native/Libraries/Utilities/stringifyViewConfig.js index 419bce0a8ba6..daf7cbcf2b28 100644 --- a/packages/react-native/Libraries/Utilities/stringifyViewConfig.js +++ b/packages/react-native/Libraries/Utilities/stringifyViewConfig.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ -export default function stringifyViewConfig(viewConfig: any): string { +export default function stringifyViewConfig(viewConfig: unknown): string { + // $FlowFixMe[incompatible-type] JSON.stringify can return void; preserves prior behavior (returns the result directly, not coerced to '') return JSON.stringify( viewConfig, (key, val) => { diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index 24f632825a84..5eb3e4b82f33 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<4ce7639c1ad25f2e115d3fc7815e811c>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -371,9 +371,9 @@ declare const sequence: typeof $$AnimatedImplementation.sequence declare const sequenceImpl: ( animations: Array, ) => CompositeAnimation -declare const setStyleAttributePreprocessor: ( +declare const setStyleAttributePreprocessor: ( property: string, - process: (nextProp: any) => any, + process: (nextProp: T) => unknown, ) => void declare const Settings: typeof Settings_default declare let Settings_default: { @@ -1960,7 +1960,7 @@ declare interface DrawerLayoutAndroidMethods { onFail?: () => void, ): void openDrawer(): void - setNativeProps(nativeProps: Object): void + setNativeProps(nativeProps: {}): void } declare type DrawerLayoutAndroidProps = Readonly< ViewProps & { @@ -4445,7 +4445,7 @@ declare type setStyleAttributePreprocessor = typeof setStyleAttributePreprocessor declare function setSurfaceProps( appKey: string, - appParameters: Object, + appParameters: AppParameters, displayMode?: number, ): void declare type Settings = typeof Settings @@ -4643,13 +4643,13 @@ declare type StackProps = { | undefined | { animated: boolean - value: StatusBarProps["barStyle"] + value: StatusBarStyle } hidden: | undefined | { animated: boolean - transition: StatusBarProps["showHideTransition"] + transition: StatusBarAnimation value: boolean } } @@ -4657,7 +4657,7 @@ declare type stagger = typeof stagger declare function startHeadlessTask( taskId: number, taskKey: string, - data: any, + data: unknown, ): void declare type State = { cellsAroundViewport: { @@ -5716,7 +5716,7 @@ export { AndroidKeyboardEvent, // e03becc8 Animated, // 50cbe576 AppConfig, // 35c0ca70 - AppRegistry, // 1e8c5a00 + AppRegistry, // 54cbc34d AppState, // 12012be5 AppStateEvent, // 80f034c3 AppStateStatus, // 447e5ef2 @@ -5748,8 +5748,8 @@ export { DimensionsPayload, // 653bc26c DisplayMetrics, // 1dc35cef DisplayMetricsAndroid, // 872e62eb - DrawerLayoutAndroid, // 7843b7b5 - DrawerLayoutAndroidInstance, // c0694352 + DrawerLayoutAndroid, // 58bc08bc + DrawerLayoutAndroidInstance, // aa243cbf DrawerLayoutAndroidProps, // 0c1d6155 DrawerSlideEvent, // c4ab8fba DropShadowValue, // e9df2606 @@ -5931,13 +5931,13 @@ export { ShareActionSheetIOSOptions, // eff574f5 ShareContent, // 7c627896 ShareOptions, // 800c3a4e - StatusBar, // f95dbb76 + StatusBar, // 5748d574 StatusBarAnimation, // 7fd047e6 - StatusBarInstance, // 416e9640 + StatusBarInstance, // de13e4a1 StatusBarProps, // c2a44d88 StatusBarStyle, // 78f53eea StyleProp, // fa0e9b4a - StyleSheet, // e734acd4 + StyleSheet, // 94c9aa8e SubmitBehavior, // c4ddf490 Switch, // f495bab3 SwitchChangeEvent, // 899635b1 diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAccessibilityManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAccessibilityManager.js index b54a36179a1b..f30e52bc0b2f 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAccessibilityManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAccessibilityManager.js @@ -4,46 +4,47 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { readonly getCurrentBoldTextState: ( onSuccess: (isBoldTextEnabled: boolean) => void, - onError: (error: Object) => void, + onError: (error: UnsafeObject) => void, ) => void; readonly getCurrentGrayscaleState: ( onSuccess: (isGrayscaleEnabled: boolean) => void, - onError: (error: Object) => void, + onError: (error: UnsafeObject) => void, ) => void; readonly getCurrentInvertColorsState: ( onSuccess: (isInvertColorsEnabled: boolean) => void, - onError: (error: Object) => void, + onError: (error: UnsafeObject) => void, ) => void; readonly getCurrentReduceMotionState: ( onSuccess: (isReduceMotionEnabled: boolean) => void, - onError: (error: Object) => void, + onError: (error: UnsafeObject) => void, ) => void; readonly getCurrentDarkerSystemColorsState?: ( onSuccess: (isDarkerSystemColorsEnabled: boolean) => void, - onError: (error: Object) => void, + onError: (error: UnsafeObject) => void, ) => void; readonly getCurrentPrefersCrossFadeTransitionsState?: ( onSuccess: (prefersCrossFadeTransitions: boolean) => void, - onError: (error: Object) => void, + onError: (error: UnsafeObject) => void, ) => void; readonly getCurrentReduceTransparencyState: ( onSuccess: (isReduceTransparencyEnabled: boolean) => void, - onError: (error: Object) => void, + onError: (error: UnsafeObject) => void, ) => void; readonly getCurrentVoiceOverState: ( onSuccess: (isScreenReaderEnabled: boolean) => void, - onError: (error: Object) => void, + onError: (error: UnsafeObject) => void, ) => void; readonly setAccessibilityContentSizeMultipliers: (JSMultipliers: { readonly extraSmall?: ?number, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeActionSheetManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeActionSheetManager.js index b4017988a264..fa0c95b497a7 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeActionSheetManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeActionSheetManager.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -45,7 +46,7 @@ export interface Spec extends TurboModule { failureCallback: (error: { readonly domain: string, readonly code: string, - readonly userInfo?: ?Object, + readonly userInfo?: ?UnsafeObject, readonly message: string, }) => void, successCallback: (completed: boolean, activityType: ?string) => void, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAlertManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAlertManager.js index 603984af224d..fadf832c2813 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAlertManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAlertManager.js @@ -4,18 +4,19 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export type Args = { title?: string, message?: string, - buttons?: Array, // TODO(T67565166): have a better type + buttons?: Array, // TODO(T67565166): have a better type type?: string, defaultValue?: string, cancelButtonKey?: string, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js index ea72f860bbd3..e8f6548167e0 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import shouldUseTurboAnimatedModule from '../../../../Libraries/Animated/shouldUseTurboAnimatedModule'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -24,8 +25,8 @@ export type EventMapping = { // The config has different keys depending on the type of the Node // TODO(T54896888): Make these types strict -export type AnimatedNodeConfig = Object; -export type AnimatingNodeConfig = Object; +export type AnimatedNodeConfig = UnsafeObject; +export type AnimatingNodeConfig = UnsafeObject; export interface Spec extends TurboModule { readonly startOperationBatch: () => void; @@ -66,7 +67,7 @@ export interface Spec extends TurboModule { ) => void; readonly connectAnimatedNodeToShadowNodeFamily?: ( nodeTag: number, - shadowNode: Object, + shadowNode: UnsafeObject, ) => void; readonly disconnectAnimatedNodeFromView: ( nodeTag: number, @@ -91,7 +92,7 @@ export interface Spec extends TurboModule { // All of the above in a batched mode readonly queueAndExecuteBatchedOperations?: ( - operationsAndArgs: Array, + operationsAndArgs: Array, ) => void; } diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedTurboModule.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedTurboModule.js index f634843ce3b4..f21f673ce8e8 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedTurboModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedTurboModule.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import shouldUseTurboAnimatedModule from '../../../../Libraries/Animated/shouldUseTurboAnimatedModule'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -24,8 +25,8 @@ export type EventMapping = { // The config has different keys depending on the type of the Node // TODO(T54896888): Make these types strict -export type AnimatedNodeConfig = Object; -export type AnimatingNodeConfig = Object; +export type AnimatedNodeConfig = UnsafeObject; +export type AnimatingNodeConfig = UnsafeObject; export interface Spec extends TurboModule { readonly startOperationBatch: () => void; @@ -87,7 +88,7 @@ export interface Spec extends TurboModule { // All of the above in a batched mode readonly queueAndExecuteBatchedOperations?: ( - operationsAndArgs: Array, + operationsAndArgs: Array, ) => void; } diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAppState.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAppState.js index 85f8159ea175..60f04e5b0807 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAppState.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAppState.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -22,7 +23,7 @@ export interface Spec extends TurboModule { readonly getConstants: () => AppStateConstants; readonly getCurrentAppState: ( success: (appState: AppState) => void, - error: (error: Object) => void, + error: (error: UnsafeObject) => void, ) => void; // Events diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeBlobModule.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeBlobModule.js index 929a1cf098d2..82fa62b9a858 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeBlobModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeBlobModule.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -19,8 +20,11 @@ export interface Spec extends TurboModule { readonly addNetworkingHandler: () => void; readonly addWebSocketHandler: (id: number) => void; readonly removeWebSocketHandler: (id: number) => void; - readonly sendOverSocket: (blob: Object, socketID: number) => void; - readonly createFromParts: (parts: Array, withId: string) => void; + readonly sendOverSocket: (blob: UnsafeObject, socketID: number) => void; + readonly createFromParts: ( + parts: Array, + withId: string, + ) => void; readonly release: (blobId: string) => void; } @@ -46,10 +50,10 @@ if (NativeModule != null) { removeWebSocketHandler(id: number): void { NativeModule.removeWebSocketHandler(id); }, - sendOverSocket(blob: Object, socketID: number): void { + sendOverSocket(blob: UnsafeObject, socketID: number): void { NativeModule.sendOverSocket(blob, socketID); }, - createFromParts(parts: Array, withId: string): void { + createFromParts(parts: Array, withId: string): void { NativeModule.createFromParts(parts, withId); }, release(blobId: string): void { diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeFileReaderModule.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeFileReaderModule.js index 835bd532ee75..331f4007539c 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeFileReaderModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeFileReaderModule.js @@ -4,17 +4,21 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - readonly readAsDataURL: (data: Object) => Promise; - readonly readAsText: (data: Object, encoding: string) => Promise; + readonly readAsDataURL: (data: UnsafeObject) => Promise; + readonly readAsText: ( + data: UnsafeObject, + encoding: string, + ) => Promise; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderAndroid.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderAndroid.js index dc30094b4189..cf056ca4d76f 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderAndroid.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -24,10 +25,10 @@ export interface Spec extends TurboModule { readonly getSize: (uri: string) => Promise; readonly getSizeWithHeaders: ( uri: string, - headers: Object, + headers: UnsafeObject, ) => Promise; readonly prefetchImage: (uri: string, requestId: number) => Promise; - readonly queryCache: (uris: Array) => Promise; + readonly queryCache: (uris: Array) => Promise; } export default TurboModuleRegistry.getEnforcing('ImageLoader') as Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js index bdc908509ae2..6e273aaba435 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js @@ -4,12 +4,13 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {RootTag} from '../../../../Libraries/TurboModule/RCTExport'; import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -19,7 +20,7 @@ export interface Spec extends TurboModule { readonly getSize: (uri: string) => Promise>; readonly getSizeWithHeaders: ( uri: string, - headers: Object, + headers: UnsafeObject, ) => Promise<{ width: number, height: number, @@ -31,7 +32,7 @@ export interface Spec extends TurboModule { queryRootName: string, rootTag: RootTag, ) => Promise; - readonly queryCache: (uris: Array) => Promise; + readonly queryCache: (uris: Array) => Promise; } export default TurboModuleRegistry.getEnforcing('ImageLoader') as Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingAndroid.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingAndroid.js index df9fec835c5e..d25b8cec42fa 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingAndroid.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -20,7 +21,7 @@ export interface Spec extends TurboModule { url: string, requestId: number, headers: Array
, - data: Object, + data: UnsafeObject, responseType: string, useIncrementalUpdates: boolean, timeout: number, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js index 5fc56cb35bd5..0af1223daf10 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -17,8 +18,8 @@ export interface Spec extends TurboModule { query: { method: string, url: string, - data: Object, - headers: Object, + data: UnsafeObject, + headers: UnsafeObject, responseType: string, incrementalUpdates: boolean, timeout: number, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativePushNotificationManagerIOS.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativePushNotificationManagerIOS.js index ad4ed1de0529..c754130d8a55 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativePushNotificationManagerIOS.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativePushNotificationManagerIOS.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -21,7 +22,7 @@ type Permissions = { type Notification = { readonly alertTitle?: ?string, readonly alertBody?: ?string, - readonly userInfo?: ?Object, + readonly userInfo?: ?UnsafeObject, /** * Identifier for the notification category. See the [Apple documentation](https://developer.apple.com/documentation/usernotifications/declaring_your_actionable_notification_types) * for more details. @@ -85,7 +86,7 @@ export interface Spec extends TurboModule { readonly presentLocalNotification: (notification: Notification) => void; readonly scheduleLocalNotification: (notification: Notification) => void; readonly cancelAllLocalNotifications: () => void; - readonly cancelLocalNotifications: (userInfo: Object) => void; + readonly cancelLocalNotifications: (userInfo: UnsafeObject) => void; readonly getInitialNotification: () => Promise; readonly getScheduledLocalNotifications: ( callback: (notification: Notification) => void, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeRedBox.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeRedBox.js index b61cd62c78ef..af9b0469a685 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeRedBox.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeRedBox.js @@ -4,16 +4,20 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - readonly setExtraData: (extraData: Object, forIdentifier: string) => void; + readonly setExtraData: ( + extraData: UnsafeObject, + forIdentifier: string, + ) => void; readonly dismiss: () => void; } diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js index 65ee3fe605c1..fd2893dbe965 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ @@ -46,18 +46,18 @@ export interface Spec extends TurboModule { readonly getEnum?: (arg: EnumInt) => EnumInt; readonly getNumber: (arg: number) => number; readonly getString: (arg: string) => string; - readonly getArray: (arg: Array) => Array; - readonly getObject: (arg: Object) => Object; + readonly getArray: (arg: Array) => Array; + readonly getObject: (arg: UnsafeObject) => UnsafeObject; readonly getUnsafeObject: (arg: UnsafeObject) => UnsafeObject; readonly getRootTag: (arg: RootTag) => RootTag; - readonly getValue: (x: number, y: string, z: Object) => Object; + readonly getValue: (x: number, y: string, z: UnsafeObject) => UnsafeObject; readonly getValueWithCallback: (callback: (value: string) => void) => void; readonly getValueWithPromise: (error: boolean) => Promise; readonly voidFuncThrows?: () => void; - readonly getObjectThrows?: (arg: Object) => Object; + readonly getObjectThrows?: (arg: UnsafeObject) => UnsafeObject; readonly promiseThrows?: () => Promise; readonly voidFuncAssert?: () => void; - readonly getObjectAssert?: (arg: Object) => Object; + readonly getObjectAssert?: (arg: UnsafeObject) => UnsafeObject; readonly promiseAssert?: () => Promise; // Android-only diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSettingsManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSettingsManager.js index 5cc6c4cb1443..35159e98e0a2 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSettingsManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSettingsManager.js @@ -4,19 +4,20 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { readonly getConstants: () => { - settings: Object, + settings: UnsafeObject, }; - readonly setValues: (values: Object) => void; + readonly setValues: (values: UnsafeObject) => void; readonly deleteValues: (values: Array) => void; } diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeWebSocketModule.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeWebSocketModule.js index f6f0cd9ddfcd..8d5b9d47b3e1 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeWebSocketModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeWebSocketModule.js @@ -4,11 +4,12 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow + * @flow strict-local * @format */ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; +import type {UnsafeObject} from '../../../../Libraries/Types/CodegenTypes'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; @@ -17,7 +18,7 @@ export interface Spec extends TurboModule { url: string, protocols: ?Array, options: { - headers?: Object, + headers?: UnsafeObject, unstable_devToolsRequestId?: string, }, socketID: number, diff --git a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api index 6e4ab04a9d24..13b9098bd58d 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api @@ -2504,7 +2504,7 @@ protocol NativeRedBoxSpec : public NSObjectRCTBridgeModule, public RCTTurboModul } protocol NativeSampleTurboModuleSpec : public NSObjectRCTBridgeModule, public RCTTurboModule { - public virtual NSArray>* getArray:(NSArray* arg); + public virtual NSArray* getArray:(NSArray* arg); public virtual NSDictionary* getObject:(NSDictionary* arg); public virtual NSDictionary* getObjectAssert:(NSDictionary* arg); public virtual NSDictionary* getObjectThrows:(NSDictionary* arg); diff --git a/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api index 02957e06c0f6..78658d135996 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api @@ -2493,7 +2493,7 @@ protocol NativeRedBoxSpec : public NSObjectRCTBridgeModule, public RCTTurboModul } protocol NativeSampleTurboModuleSpec : public NSObjectRCTBridgeModule, public RCTTurboModule { - public virtual NSArray>* getArray:(NSArray* arg); + public virtual NSArray* getArray:(NSArray* arg); public virtual NSDictionary* getObject:(NSDictionary* arg); public virtual NSDictionary* getObjectAssert:(NSDictionary* arg); public virtual NSDictionary* getObjectThrows:(NSDictionary* arg); diff --git a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api index 94953681427d..87fcd01c36fd 100644 --- a/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api +++ b/scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api @@ -2504,7 +2504,7 @@ protocol NativeRedBoxSpec : public NSObjectRCTBridgeModule, public RCTTurboModul } protocol NativeSampleTurboModuleSpec : public NSObjectRCTBridgeModule, public RCTTurboModule { - public virtual NSArray>* getArray:(NSArray* arg); + public virtual NSArray* getArray:(NSArray* arg); public virtual NSDictionary* getObject:(NSDictionary* arg); public virtual NSDictionary* getObjectAssert:(NSDictionary* arg); public virtual NSDictionary* getObjectThrows:(NSDictionary* arg);