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/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..e02cdc1999c5 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<<9e84d3a75a150cc9d571738d15f28d91>> * * 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: { @@ -5937,7 +5937,7 @@ export { 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);