From 768219fd4c6bcafa516907f8327cf1cbd1595490 Mon Sep 17 00:00:00 2001 From: Marco Wang Date: Fri, 22 May 2026 20:04:17 -0700 Subject: [PATCH] Fix a few readonly 10/n (#56948) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56948 ``` js1 flow-runner codemod flow/transformAllVariance --variance readonly --format-files=false ``` drop-conflicts Reviewed By: SamChou19815 Differential Revision: D106144499 --- .../src/generators/ReservedPrimitiveTypes.js | 163 +++++------ .../components/ComponentsGeneratorUtils.js | 10 +- .../src/parsers/errors.js | 2 +- .../NativeComponent.js.flow | 68 +++-- .../NativeComponent.js.flow | 13 +- .../NativeComponent.js.flow | 22 +- .../NativeComponent.js.flow | 5 +- .../NativeComponent.js.flow | 2 +- .../NativeComponent.js.flow | 7 +- .../NativeComponent.js.flow | 2 +- .../NativeModuleBeforeAfterTypes.js.flow | 12 +- .../NativeModuleBeforeAfterTypes.js.flow | 60 ++--- .../NativeModuleBeforeAfterTypes.js.flow | 59 ++-- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 4 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 4 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 4 +- .../NativeModule.js.flow | 4 +- .../NativeModule.js.flow | 2 +- .../NativeModule.js.flow | 2 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../native-module-nested/NativeModule.js.flow | 6 +- .../NativeTypeDiffingTypes.js.flow | 108 ++++---- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../NativeModule.js.flow | 6 +- .../native-module/NativeModule.js.flow | 6 +- .../js/PopupMenuAndroid.android.js | 2 +- .../js/PopupMenuAndroid.js | 2 +- ...PopupMenuAndroidNativeComponent.android.js | 2 +- .../Libraries/Animated/nodes/AnimatedColor.js | 16 +- .../Libraries/Animated/nodes/AnimatedProps.js | 2 +- .../Animated/nodes/AnimatedValueXY.js | 4 +- .../Libraries/Blob/URLSearchParams.js.flow | 2 +- .../Components/ScrollView/ScrollView.js | 20 +- .../ScrollView/ScrollViewCommands.js | 8 +- .../ScrollView/ScrollViewStickyHeader.js | 2 +- .../TextInput/InputAccessoryView.js | 2 +- .../TextInput/TextInputNativeCommands.js | 6 +- .../Components/Touchable/Touchable.js | 20 +- .../Components/View/ViewNativeComponent.js | 8 +- .../Libraries/Core/ReactFiberErrorDialog.js | 6 +- .../Libraries/Image/AssetSourceResolver.js | 10 +- .../Libraries/Image/ImageSource.js | 18 +- .../Libraries/Image/ImageSourceUtils.js | 8 +- .../Image/ImageViewNativeComponent.js | 2 +- .../Libraries/NativeComponent/ViewConfig.js | 6 +- .../NativeComponent/ViewConfigIgnore.js | 2 +- .../Libraries/ReactNative/AppContainer-dev.js | 4 +- .../Libraries/ReactNative/DisplayMode.js | 2 +- .../Libraries/ReactNative/FabricUIManager.js | 55 ++-- .../Libraries/StyleSheet/StyleSheetTypes.js | 2 +- .../StyleSheet/private/_TransformStyle.js | 30 ++- .../Text/TextEffectNativeComponent.js | 2 +- .../Libraries/TurboModule/RCTExport.js | 2 +- .../Libraries/Types/CoreEventTypes.js | 56 ++-- .../Libraries/Types/UIManagerJSInterface.js | 4 +- .../Libraries/Utilities/Appearance.js | 4 +- .../Utilities/BackHandler.android.js | 4 +- .../Libraries/Utilities/BackHandler.js.flow | 4 +- .../Libraries/Utilities/differ/deepDiffer.js | 7 +- .../Libraries/vendor/emitter/EventEmitter.js | 6 +- packages/react-native/flow/bom.js.flow | 84 +++--- packages/react-native/flow/cssom.js.flow | 42 +-- packages/react-native/flow/dom.js.flow | 254 +++++++++--------- .../private/animated/NativeAnimatedHelper.js | 2 +- .../components/virtualcollection/Virtual.js | 6 +- .../devmenu/elementinspector/Inspector.js | 4 +- .../devsupport/devmenu/specs/NativeDevMenu.js | 8 +- ...ativeReactDevToolsRuntimeSettingsModule.js | 6 +- .../NativeReactDevToolsSettingsManager.js | 4 +- .../renderer/errorhandling/ErrorHandlers.js | 4 +- .../AndroidDrawerLayoutNativeComponent.js | 4 +- ...ndroidSwipeRefreshLayoutNativeComponent.js | 2 +- .../AndroidSwitchNativeComponent.js | 2 +- .../DebuggingOverlayNativeComponent.js | 6 +- .../PullToRefreshViewNativeComponent.js | 2 +- .../components/SwitchNativeComponent.js | 5 +- .../modules/NativeAccessibilityInfo.js | 18 +- .../modules/NativeAccessibilityManager.js | 48 ++-- .../modules/NativeActionSheetManager.js | 56 ++-- .../modules/NativeAlertManager.js | 2 +- .../modules/NativeAnimatedModule.js | 70 +++-- .../modules/NativeAnimatedTurboModule.js | 68 +++-- .../modules/NativeAppState.js | 8 +- .../modules/NativeAppearance.js | 8 +- .../modules/NativeBlobModule.js | 14 +- .../modules/NativeClipboard.js | 6 +- .../modules/NativeDevLoadingView.js | 4 +- .../modules/NativeDevSettings.js | 22 +- .../modules/NativeDeviceEventManager.js | 2 +- .../modules/NativeDeviceInfo.js | 8 +- .../modules/NativeDialogManagerAndroid.js | 14 +- .../modules/NativeExceptionsManager.js | 8 +- .../modules/NativeFileReaderModule.js | 4 +- .../modules/NativeFrameRateLogger.js | 8 +- .../modules/NativeHeadlessJsTaskSupport.js | 4 +- .../modules/NativeI18nManager.js | 2 +- .../modules/NativeImageEditor.js | 26 +- .../modules/NativeImageLoaderAndroid.js | 15 +- .../modules/NativeImageLoaderIOS.js | 12 +- .../modules/NativeImageStoreAndroid.js | 4 +- .../modules/NativeImageStoreIOS.js | 13 +- .../modules/NativeIntentAndroid.js | 10 +- .../modules/NativeJSCHeapCapture.js | 2 +- .../modules/NativeKeyboardObserver.js | 4 +- .../modules/NativeLinkingManager.js | 12 +- .../specs_DEPRECATED/modules/NativeLogBox.js | 4 +- .../modules/NativeModalManager.js | 4 +- .../modules/NativeNetworkingAndroid.js | 10 +- .../modules/NativeNetworkingIOS.js | 12 +- .../modules/NativePermissionsAndroid.js | 10 +- .../modules/NativePlatformConstantsAndroid.js | 4 +- .../modules/NativePlatformConstantsIOS.js | 2 +- .../NativePushNotificationManagerIOS.js | 66 ++--- .../specs_DEPRECATED/modules/NativeRedBox.js | 4 +- .../modules/NativeSampleTurboModule.js | 48 ++-- .../modules/NativeSegmentFetcher.js | 4 +- .../modules/NativeSettingsManager.js | 6 +- .../modules/NativeShareModule.js | 4 +- .../modules/NativeSoundManager.js | 2 +- .../modules/NativeSourceCode.js | 2 +- .../modules/NativeStatusBarManagerAndroid.js | 18 +- .../modules/NativeStatusBarManagerIOS.js | 22 +- .../specs_DEPRECATED/modules/NativeTiming.js | 6 +- .../modules/NativeToastAndroid.js | 8 +- .../modules/NativeUIManager.js | 57 ++-- .../modules/NativeVibration.js | 8 +- .../modules/NativeWebSocketModule.js | 14 +- .../testing/fantom/specs/NativeCPUTime.js | 4 +- .../specs/NativeFantomTestSpecificMethods.js | 10 +- .../specs/NativeViewTransition.js | 10 +- .../private/webapis/dom/events/CustomEvent.js | 2 +- .../src/private/webapis/dom/events/Event.js | 24 +- .../private/webapis/dom/events/EventTarget.js | 6 +- .../webapis/dom/nodes/specs/NativeDOM.js | 88 +++--- .../HTMLCollection.js.flow | 2 +- .../dom/oldstylecollections/NodeList.js.flow | 2 +- .../private/webapis/errors/DOMException.js | 100 +++---- .../webapis/geometry/DOMRectList.js.flow | 2 +- .../webapis/html/events/MessageEvent.js | 6 +- .../__tests__/requestIdleCallback-itest.js | 4 +- .../specs/NativeIdleCallbacks.js | 4 +- .../specs/NativeIntersectionObserver.js | 10 +- .../microtasks/specs/NativeMicrotasks.js | 2 +- .../mutationobserver/MutationObserver.js | 14 +- .../specs/NativeMutationObserver.js | 10 +- .../webapis/performance/EventTiming.js | 6 +- .../webapis/performance/PerformanceEntry.js | 6 +- .../performance/PerformanceObserver.js | 8 +- .../webapis/performance/ResourceTiming.js | 26 +- .../private/webapis/performance/UserTiming.js | 6 +- .../performance/internals/Utilities.js | 2 +- .../performance/specs/NativePerformance.js | 46 ++-- .../private/webapis/utils/ArrayLikeUtils.js | 2 +- .../webapis/websockets/events/CloseEvent.js | 6 +- .../webapis/xhr/events/ProgressEvent.js | 6 +- .../js/MyNativeViewNativeComponent.js | 10 +- .../NativeCxxModuleExample.js | 84 +++--- .../NativeScreenshotManager.js | 2 +- .../PlatformTest/RNTesterPlatformTestTypes.js | 2 +- packages/rn-tester/scripts/utils.js | 2 +- private/helloworld/lib/cli.js | 2 +- private/react-native-fantom/src/Benchmark.js | 2 +- .../simplifyTypes/gatherTypeAliasesVisitor.js | 4 +- .../simplifyTypes/resolveBuiltinType.js | 2 +- .../simplifyTypes/resolveTypeOperator.js | 2 +- scripts/releases/utils/octokit-utils.js | 2 +- 193 files changed, 1493 insertions(+), 1332 deletions(-) diff --git a/packages/react-native-codegen/src/generators/ReservedPrimitiveTypes.js b/packages/react-native-codegen/src/generators/ReservedPrimitiveTypes.js index 97e521d78f52..1de738277d01 100644 --- a/packages/react-native-codegen/src/generators/ReservedPrimitiveTypes.js +++ b/packages/react-native-codegen/src/generators/ReservedPrimitiveTypes.js @@ -28,99 +28,104 @@ export type ReservedPrimitiveName = | 'DimensionPrimitive'; type CppTypeInfo = { - +typeName: string, - +localIncludes: ReadonlyArray, - +conversionIncludes: ReadonlyArray, + readonly typeName: string, + readonly localIncludes: ReadonlyArray, + readonly conversionIncludes: ReadonlyArray, }; type JavaImportInfo = { - +interfaceImports: ReadonlyArray, - +delegateImports: ReadonlyArray, + readonly interfaceImports: ReadonlyArray, + readonly delegateImports: ReadonlyArray, }; type ReservedTypeMapping = { - +cpp: CppTypeInfo, - +java: JavaImportInfo, + readonly cpp: CppTypeInfo, + readonly java: JavaImportInfo, }; -const RESERVED_TYPES: {+[ReservedPrimitiveName]: ReservedTypeMapping} = { - ColorPrimitive: { - cpp: { - typeName: 'SharedColor', - localIncludes: ['#include '], - conversionIncludes: [], +const RESERVED_TYPES: {readonly [ReservedPrimitiveName]: ReservedTypeMapping} = + { + ColorPrimitive: { + cpp: { + typeName: 'SharedColor', + localIncludes: ['#include '], + conversionIncludes: [], + }, + java: { + interfaceImports: [], + delegateImports: [ + 'import com.facebook.react.bridge.ColorPropConverter;', + ], + }, }, - java: { - interfaceImports: [], - delegateImports: ['import com.facebook.react.bridge.ColorPropConverter;'], + ImageSourcePrimitive: { + cpp: { + typeName: 'ImageSource', + localIncludes: ['#include '], + conversionIncludes: [ + '#include ', + ], + }, + java: { + interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'], + delegateImports: ['import com.facebook.react.bridge.ReadableMap;'], + }, }, - }, - ImageSourcePrimitive: { - cpp: { - typeName: 'ImageSource', - localIncludes: ['#include '], - conversionIncludes: [ - '#include ', - ], + ImageRequestPrimitive: { + cpp: { + typeName: 'ImageRequest', + localIncludes: [ + '#include ', + ], + conversionIncludes: [], + }, + java: { + // ImageRequestPrimitive is not used in Java component props + interfaceImports: [], + delegateImports: [], + }, }, - java: { - interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'], - delegateImports: ['import com.facebook.react.bridge.ReadableMap;'], + PointPrimitive: { + cpp: { + typeName: 'Point', + localIncludes: ['#include '], + conversionIncludes: [], + }, + java: { + interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'], + delegateImports: ['import com.facebook.react.bridge.ReadableMap;'], + }, }, - }, - ImageRequestPrimitive: { - cpp: { - typeName: 'ImageRequest', - localIncludes: ['#include '], - conversionIncludes: [], + EdgeInsetsPrimitive: { + cpp: { + typeName: 'EdgeInsets', + localIncludes: ['#include '], + conversionIncludes: [], + }, + java: { + interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'], + delegateImports: ['import com.facebook.react.bridge.ReadableMap;'], + }, }, - java: { - // ImageRequestPrimitive is not used in Java component props - interfaceImports: [], - delegateImports: [], + DimensionPrimitive: { + cpp: { + typeName: 'YGValue', + localIncludes: [ + '#include ', + '#include ', + ], + conversionIncludes: [ + '#include ', + ], + }, + java: { + interfaceImports: ['import com.facebook.yoga.YogaValue;'], + delegateImports: [ + 'import com.facebook.react.bridge.DimensionPropConverter;', + ], + }, }, - }, - PointPrimitive: { - cpp: { - typeName: 'Point', - localIncludes: ['#include '], - conversionIncludes: [], - }, - java: { - interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'], - delegateImports: ['import com.facebook.react.bridge.ReadableMap;'], - }, - }, - EdgeInsetsPrimitive: { - cpp: { - typeName: 'EdgeInsets', - localIncludes: ['#include '], - conversionIncludes: [], - }, - java: { - interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'], - delegateImports: ['import com.facebook.react.bridge.ReadableMap;'], - }, - }, - DimensionPrimitive: { - cpp: { - typeName: 'YGValue', - localIncludes: [ - '#include ', - '#include ', - ], - conversionIncludes: [ - '#include ', - ], - }, - java: { - interfaceImports: ['import com.facebook.yoga.YogaValue;'], - delegateImports: [ - 'import com.facebook.react.bridge.DimensionPropConverter;', - ], - }, - }, -}; + }; function getCppTypeForReservedPrimitive(name: ReservedPrimitiveName): string { return RESERVED_TYPES[name].cpp.typeName; diff --git a/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js b/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js index 4e680fe3e841..bd706b186a1d 100644 --- a/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js +++ b/packages/react-native-codegen/src/generators/components/ComponentsGeneratorUtils.js @@ -49,13 +49,13 @@ function getNativeTypeFromAnnotation( | ObjectTypeAnnotation | ReservedPropTypeAnnotation | { - +default: string, - +options: ReadonlyArray, - +type: 'StringEnumTypeAnnotation', + readonly default: string, + readonly options: ReadonlyArray, + readonly type: 'StringEnumTypeAnnotation', } | { - +elementType: ObjectTypeAnnotation, - +type: 'ArrayTypeAnnotation', + readonly elementType: ObjectTypeAnnotation, + readonly type: 'ArrayTypeAnnotation', }, }, nameParts: ReadonlyArray, diff --git a/packages/react-native-codegen/src/parsers/errors.js b/packages/react-native-codegen/src/parsers/errors.js index fececdedfc44..7e0b2277930f 100644 --- a/packages/react-native-codegen/src/parsers/errors.js +++ b/packages/react-native-codegen/src/parsers/errors.js @@ -128,7 +128,7 @@ class UnsupportedModulePropertyParserError extends ParserError { } class UnsupportedTypeAnnotationParserError extends ParserError { - +typeAnnotationType: string; + readonly typeAnnotationType: string; constructor( nativeModuleName: string, typeAnnotation: $FlowFixMe, diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-all-types/NativeComponent.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-all-types/NativeComponent.js.flow index b5c9ab0208bd..5a9837f0cd41 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-all-types/NativeComponent.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-all-types/NativeComponent.js.flow @@ -91,53 +91,83 @@ type CustomObj = {foo: string, bar: number}; type CustomObj2 = {a: Int32, b: string}; interface NativeCommands { - +methodInt: (viewRef: React.ElementRef, a: Int32) => void; - +methodIntString: ( + readonly methodInt: (viewRef: React.ElementRef, a: Int32) => void; + readonly methodIntString: ( viewRef: React.ElementRef, a: Int32, b: string, ) => void; - +methodString: (viewRef: React.ElementRef, a: string) => void; - +methodBool: (viewRef: React.ElementRef, a: boolean) => void; - +methodFloat: (viewRef: React.ElementRef, a: Float) => void; - +methodDouble: (viewRef: React.ElementRef, a: Double) => void; + readonly methodString: ( + viewRef: React.ElementRef, + a: string, + ) => void; + readonly methodBool: ( + viewRef: React.ElementRef, + a: boolean, + ) => void; + readonly methodFloat: ( + viewRef: React.ElementRef, + a: Float, + ) => void; + readonly methodDouble: ( + viewRef: React.ElementRef, + a: Double, + ) => void; - +methodIntAlias: (viewRef: React.ElementRef, a: Int) => void; - +methodStringAlias: (viewRef: React.ElementRef, a: Str) => void; - +methodBoolAlias: (viewRef: React.ElementRef, a: Bool) => void; - +methodFloatAlias: (viewRef: React.ElementRef, a: Fl) => void; - +methodDoubleAlias: (viewRef: React.ElementRef, a: Dbl) => void; + readonly methodIntAlias: ( + viewRef: React.ElementRef, + a: Int, + ) => void; + readonly methodStringAlias: ( + viewRef: React.ElementRef, + a: Str, + ) => void; + readonly methodBoolAlias: ( + viewRef: React.ElementRef, + a: Bool, + ) => void; + readonly methodFloatAlias: ( + viewRef: React.ElementRef, + a: Fl, + ) => void; + readonly methodDoubleAlias: ( + viewRef: React.ElementRef, + a: Dbl, + ) => void; - +methodIntArray: ( + readonly methodIntArray: ( viewRef: React.ElementRef, a: Array, ) => void; - +methodStringArray: ( + readonly methodStringArray: ( viewRef: React.ElementRef, a: Array, ) => void; - +methodBoolArray: ( + readonly methodBoolArray: ( viewRef: React.ElementRef, a: Array, ) => void; - +methodFloatArray: ( + readonly methodFloatArray: ( viewRef: React.ElementRef, a: Array, ) => void; - +methodDoubleArray: ( + readonly methodDoubleArray: ( viewRef: React.ElementRef, a: Array, ) => void; - +methodCustomObjArray: ( + readonly methodCustomObjArray: ( viewRef: React.ElementRef, a: Array, ) => void; - +methodCustomObj2Array: ( + readonly methodCustomObj2Array: ( viewRef: React.ElementRef, a: Array, ) => void; - +methodRootTag: (viewRef: React.ElementRef, a: RootTag) => void; + readonly methodRootTag: ( + viewRef: React.ElementRef, + a: RootTag, + ) => void; } export const Commands: NativeCommands = codegenNativeCommands({ diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-all-basic-types-arrays/NativeComponent.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-all-basic-types-arrays/NativeComponent.js.flow index 6aab7e7baa5b..a1943b0e7c3e 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-all-basic-types-arrays/NativeComponent.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-all-basic-types-arrays/NativeComponent.js.flow @@ -26,20 +26,23 @@ type NativeProps = Readonly<{ type NativeType = HostComponent; interface NativeCommands { - +methodInt: (viewRef: React.ElementRef, a: Array) => void; - +methodString: ( + readonly methodInt: ( + viewRef: React.ElementRef, + a: Array, + ) => void; + readonly methodString: ( viewRef: React.ElementRef, a: Array, ) => void; - +methodBool: ( + readonly methodBool: ( viewRef: React.ElementRef, a: Array, ) => void; - +methodFloat: ( + readonly methodFloat: ( viewRef: React.ElementRef, a: Array, ) => void; - +methodDouble: ( + readonly methodDouble: ( viewRef: React.ElementRef, a: Array, ) => void; diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-all-basic-types/NativeComponent.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-all-basic-types/NativeComponent.js.flow index cc0c2cd9857e..a44068aa05be 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-all-basic-types/NativeComponent.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-all-basic-types/NativeComponent.js.flow @@ -26,11 +26,23 @@ type NativeProps = Readonly<{ type NativeType = HostComponent; interface NativeCommands { - +methodInt: (viewRef: React.ElementRef, a: Int32) => void; - +methodString: (viewRef: React.ElementRef, a: string) => void; - +methodBool: (viewRef: React.ElementRef, a: boolean) => void; - +methodFloat: (viewRef: React.ElementRef, a: Float) => void; - +methodDouble: (viewRef: React.ElementRef, a: Double) => void; + readonly methodInt: (viewRef: React.ElementRef, a: Int32) => void; + readonly methodString: ( + viewRef: React.ElementRef, + a: string, + ) => void; + readonly methodBool: ( + viewRef: React.ElementRef, + a: boolean, + ) => void; + readonly methodFloat: ( + viewRef: React.ElementRef, + a: Float, + ) => void; + readonly methodDouble: ( + viewRef: React.ElementRef, + a: Double, + ) => void; } export const Commands: NativeCommands = codegenNativeCommands({ diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-changed/NativeComponent.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-changed/NativeComponent.js.flow index f3eac473837f..3437f6381150 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-changed/NativeComponent.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-changed/NativeComponent.js.flow @@ -21,7 +21,10 @@ type NativeProps = Readonly<{ type NativeType = HostComponent; interface NativeCommands { - +methodInt: (viewRef: React.ElementRef, a: string) => void; + readonly methodInt: ( + viewRef: React.ElementRef, + a: string, + ) => void; } export const Commands: NativeCommands = codegenNativeCommands({ diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-extra-arg/NativeComponent.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-extra-arg/NativeComponent.js.flow index 7006bb983320..189ec5835830 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-extra-arg/NativeComponent.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-extra-arg/NativeComponent.js.flow @@ -22,7 +22,7 @@ type NativeProps = Readonly<{ type NativeType = HostComponent; interface NativeCommands { - +methodInt: ( + readonly methodInt: ( viewRef: React.ElementRef, a: Int32, b: string, diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-extra-command/NativeComponent.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-extra-command/NativeComponent.js.flow index a96a01407cb2..39d3ba4aa930 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-extra-command/NativeComponent.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command-extra-command/NativeComponent.js.flow @@ -22,8 +22,11 @@ type NativeProps = Readonly<{ type NativeType = HostComponent; interface NativeCommands { - +methodInt: (viewRef: React.ElementRef, a: Int32) => void; - +methodString: (viewRef: React.ElementRef, a: string) => void; + readonly methodInt: (viewRef: React.ElementRef, a: Int32) => void; + readonly methodString: ( + viewRef: React.ElementRef, + a: string, + ) => void; } export const Commands: NativeCommands = codegenNativeCommands({ diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command/NativeComponent.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command/NativeComponent.js.flow index a50fa6d6d8c4..8767e91f5f8b 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command/NativeComponent.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-component-with-command/NativeComponent.js.flow @@ -22,7 +22,7 @@ type NativeProps = Readonly<{ type NativeType = HostComponent; interface NativeCommands { - +methodInt: (viewRef: React.ElementRef, a: Int32) => void; + readonly methodInt: (viewRef: React.ElementRef, a: Int32) => void; } export const Commands: NativeCommands = codegenNativeCommands({ diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types-removed/NativeModuleBeforeAfterTypes.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types-removed/NativeModuleBeforeAfterTypes.js.flow index 181a16394c65..88e672332d3b 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types-removed/NativeModuleBeforeAfterTypes.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types-removed/NativeModuleBeforeAfterTypes.js.flow @@ -21,13 +21,11 @@ type BeforeMatchingGeneric = {||}; type AfterMatchingGeneric = {||}; export interface Spec extends TurboModule { - +simpleObject: (a: SimpleObject) => void; - +beforeMismatchGeneric: (a: BeforeMismatchGeneric) => void; + readonly simpleObject: (a: SimpleObject) => void; + readonly beforeMismatchGeneric: (a: BeforeMismatchGeneric) => void; - +beforeMatchingGeneric: (a: BeforeMatchingGeneric) => void; - +afterMatchingGeneric: (a: AfterMatchingGeneric) => void; + readonly beforeMatchingGeneric: (a: BeforeMatchingGeneric) => void; + readonly afterMatchingGeneric: (a: AfterMatchingGeneric) => void; } -TurboModuleRegistry.getEnforcing( - 'NativeModuleTest', -) as Spec; +TurboModuleRegistry.getEnforcing('NativeModuleTest') as Spec; diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types-type-changed/NativeModuleBeforeAfterTypes.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types-type-changed/NativeModuleBeforeAfterTypes.js.flow index 8f7de8386a62..4f38be927c38 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types-type-changed/NativeModuleBeforeAfterTypes.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types-type-changed/NativeModuleBeforeAfterTypes.js.flow @@ -44,34 +44,32 @@ type SimpleArray = Array; type SimpleArrayChange = Array; export interface Spec extends TurboModule { - +exampleFunction: (a: SimpleObject) => void; - +simpleObject: (a: SimpleObject) => void; - +beforeMismatchGeneric: (a: BeforeMismatchGeneric) => void; - +afterMismatchGeneric: (a: AfterMismatchGeneric) => void; - - +beforeMatchingGeneric: (a: BeforeMatchingGeneric) => void; - +afterMatchingGeneric: (a: AfterMatchingGeneric) => void; - - +booleanType: (a: BooleanType) => void; - +stringType: (a: StringType) => void; - - +simpleFunction: (a: string) => string; - +simpleFunction2: (a: string) => number; - +simpleFunction3: (foo: string) => string; - +simpleFunction4: (a: number) => string; - - +simpleUnion: (a: SimpleUnion) => void; - +simpleUnionLonger: (a: SimpleUnionLonger) => void; - +simpleUnionOrderChanged: (a: SimpleUnionOrderChanged) => void; - +simpleUnion2: (a: SimpleUnion2) => void; - +simpleUnion2OrderChanged: (a: SimpleUnion2OrderChanged) => void; - +simpleUnion3: (a: SimpleUnion3) => void; - +simpleUnion4: (a: SimpleUnion4) => void; - - +simpleArray: (a: SimpleArray) => void; - +simpleArrayChange: (a: SimpleArrayChange) => void; - } - - TurboModuleRegistry.getEnforcing( - 'NativeModuleTest', - ) as Spec; + readonly exampleFunction: (a: SimpleObject) => void; + readonly simpleObject: (a: SimpleObject) => void; + readonly beforeMismatchGeneric: (a: BeforeMismatchGeneric) => void; + readonly afterMismatchGeneric: (a: AfterMismatchGeneric) => void; + + readonly beforeMatchingGeneric: (a: BeforeMatchingGeneric) => void; + readonly afterMatchingGeneric: (a: AfterMatchingGeneric) => void; + + readonly booleanType: (a: BooleanType) => void; + readonly stringType: (a: StringType) => void; + + readonly simpleFunction: (a: string) => string; + readonly simpleFunction2: (a: string) => number; + readonly simpleFunction3: (foo: string) => string; + readonly simpleFunction4: (a: number) => string; + + readonly simpleUnion: (a: SimpleUnion) => void; + readonly simpleUnionLonger: (a: SimpleUnionLonger) => void; + readonly simpleUnionOrderChanged: (a: SimpleUnionOrderChanged) => void; + readonly simpleUnion2: (a: SimpleUnion2) => void; + readonly simpleUnion2OrderChanged: (a: SimpleUnion2OrderChanged) => void; + readonly simpleUnion3: (a: SimpleUnion3) => void; + readonly simpleUnion4: (a: SimpleUnion4) => void; + + readonly simpleArray: (a: SimpleArray) => void; + readonly simpleArrayChange: (a: SimpleArrayChange) => void; +} + +TurboModuleRegistry.getEnforcing('NativeModuleTest') as Spec; diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types/NativeModuleBeforeAfterTypes.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types/NativeModuleBeforeAfterTypes.js.flow index dcf6ec2a0040..69a5b6d6365c 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types/NativeModuleBeforeAfterTypes.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-before-after-types/NativeModuleBeforeAfterTypes.js.flow @@ -36,37 +36,34 @@ type SimpleUnion4 = BooleanType | StringType | SimpleObject; type SimpleArray = Array; type SimpleArrayChange = Array; - export interface Spec extends TurboModule { - +exampleFunction: (a: SimpleObject) => void; - +simpleObject: (a: SimpleObject) => void; - +beforeMismatchGeneric: (a: BeforeMismatchGeneric) => void; - +afterMismatchGeneric: (a: AfterMismatchGeneric) => void; - - +beforeMatchingGeneric: (a: BeforeMatchingGeneric) => void; - +afterMatchingGeneric: (a: AfterMatchingGeneric) => void; - - +arrayBufferType: (a: ArrayBufferType) => void; - +booleanType: (a: BooleanType) => void; - +stringType: (a: StringType) => void; - - +simpleFunction: (a: string) => string; - +simpleFunction2: (a: string) => number; - +simpleFunction3: (foo: string) => string; - +simpleFunction4: (a: number) => string; - - +simpleUnion: (a: SimpleUnion) => void; - +simpleUnionLonger: (a: SimpleUnionLonger) => void; - +simpleUnionOrderChanged: (a: SimpleUnionOrderChanged) => void; - +simpleUnion2: (a: SimpleUnion2) => void; - +simpleUnion2OrderChanged: (a: SimpleUnion2OrderChanged) => void; - +simpleUnion3: (a: SimpleUnion3) => void; - +simpleUnion4: (a: SimpleUnion4) => void; - - +simpleArray: (a: SimpleArray) => void; - +simpleArrayChange: (a: SimpleArrayChange) => void; + readonly exampleFunction: (a: SimpleObject) => void; + readonly simpleObject: (a: SimpleObject) => void; + readonly beforeMismatchGeneric: (a: BeforeMismatchGeneric) => void; + readonly afterMismatchGeneric: (a: AfterMismatchGeneric) => void; + + readonly beforeMatchingGeneric: (a: BeforeMatchingGeneric) => void; + readonly afterMatchingGeneric: (a: AfterMatchingGeneric) => void; + + readonly arrayBufferType: (a: ArrayBufferType) => void; + readonly booleanType: (a: BooleanType) => void; + readonly stringType: (a: StringType) => void; + + readonly simpleFunction: (a: string) => string; + readonly simpleFunction2: (a: string) => number; + readonly simpleFunction3: (foo: string) => string; + readonly simpleFunction4: (a: number) => string; + + readonly simpleUnion: (a: SimpleUnion) => void; + readonly simpleUnionLonger: (a: SimpleUnionLonger) => void; + readonly simpleUnionOrderChanged: (a: SimpleUnionOrderChanged) => void; + readonly simpleUnion2: (a: SimpleUnion2) => void; + readonly simpleUnion2OrderChanged: (a: SimpleUnion2OrderChanged) => void; + readonly simpleUnion3: (a: SimpleUnion3) => void; + readonly simpleUnion4: (a: SimpleUnion4) => void; + + readonly simpleArray: (a: SimpleArray) => void; + readonly simpleArrayChange: (a: SimpleArrayChange) => void; } -TurboModuleRegistry.getEnforcing( - 'NativeModuleTest', -) as Spec; +TurboModuleRegistry.getEnforcing('NativeModuleTest') as Spec; diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-changed/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-changed/NativeModule.js.flow index 77455654a4d1..751c2b273b21 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-changed/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-changed/NativeModule.js.flow @@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => { - +exampleConstant: string, + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: string, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-optional-constant-readonly/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-optional-constant-readonly/NativeModule.js.flow index 9a3af67e4d8c..1ccfbb6c1bb9 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-optional-constant-readonly/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-optional-constant-readonly/NativeModule.js.flow @@ -13,8 +13,8 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => Readonly<{ + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => Readonly<{ constant?: string, }>; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-optional-constant/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-optional-constant/NativeModule.js.flow index 944e5ebcdd9a..140a3f64eac0 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-optional-constant/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-optional-constant/NativeModule.js.flow @@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => { - +constant?: string, + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => { + readonly constant?: string, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-required-constant-readonly/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-required-constant-readonly/NativeModule.js.flow index e9f36f05ad2b..d6adf2fb0398 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-required-constant-readonly/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-required-constant-readonly/NativeModule.js.flow @@ -13,8 +13,8 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => Readonly<{ + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => Readonly<{ constant: string, }>; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-required-constant/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-required-constant/NativeModule.js.flow index 8af008dc5670..fc1f8f5c968e 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-required-constant/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-added-required-constant/NativeModule.js.flow @@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => { - +constant: string, + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => { + readonly constant: string, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-readonly/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-readonly/NativeModule.js.flow index 9a4ebdc57d1c..8e940d86fecc 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-readonly/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants-readonly/NativeModule.js.flow @@ -13,8 +13,8 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => Readonly<{}>; + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => Readonly<{}>; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants/NativeModule.js.flow index 6705dc831d4f..b31c7fbba30f 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-get-constants/NativeModule.js.flow @@ -13,8 +13,8 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => {}; + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => {}; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-alias-changed/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-alias-changed/NativeModule.js.flow index 3c908428e969..91b7c1a6eb8a 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-alias-changed/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-alias-changed/NativeModule.js.flow @@ -15,7 +15,7 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type MyType = () => Promise; export interface Spec extends TurboModule { - +exampleFunction: (a: MyType, b: number) => void; + readonly exampleFunction: (a: MyType, b: number) => void; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-alias/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-alias/NativeModule.js.flow index 56a1908cb607..7bc0475822b8 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-alias/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-alias/NativeModule.js.flow @@ -15,7 +15,7 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type MyType = () => Promise; export interface Spec extends TurboModule { - +exampleFunction: (a: MyType, b: number) => void; + readonly exampleFunction: (a: MyType, b: number) => void; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-changed/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-changed/NativeModule.js.flow index 47a742ae444a..be9e66105248 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-changed/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-changed/NativeModule.js.flow @@ -13,7 +13,7 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: ( + readonly exampleFunction: ( a: { a1: string, a2: number, @@ -22,8 +22,8 @@ export interface Spec extends TurboModule { }, b: number, ) => void; - +getConstants: () => { - +exampleConstant: string, + readonly getConstants: () => { + readonly exampleConstant: string, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-nullable/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-nullable/NativeModule.js.flow index 17a07752fa39..65cd98a27dda 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-nullable/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-nullable/NativeModule.js.flow @@ -13,7 +13,7 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: ( + readonly exampleFunction: ( a: ?{ a1: string, a2?: number, @@ -22,8 +22,8 @@ export interface Spec extends TurboModule { }, b: number, ) => void; - +getConstants: () => { - +exampleConstant: string, + readonly getConstants: () => { + readonly exampleConstant: string, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-optional/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-optional/NativeModule.js.flow index f2c638174886..de709bb05a9e 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-optional/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested-optional/NativeModule.js.flow @@ -13,7 +13,7 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: ( + readonly exampleFunction: ( a: { a1: string, a2?: number, @@ -22,8 +22,8 @@ export interface Spec extends TurboModule { }, b: number, ) => void; - +getConstants: () => { - +exampleConstant: string, + readonly getConstants: () => { + readonly exampleConstant: string, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested/NativeModule.js.flow index 8bee824e2144..3b00a720e4db 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-nested/NativeModule.js.flow @@ -13,7 +13,7 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: ( + readonly exampleFunction: ( a: { a1: string, a2: number, @@ -21,8 +21,8 @@ export interface Spec extends TurboModule { }, b: number, ) => void; - +getConstants: () => { - +exampleConstant: string, + readonly getConstants: () => { + readonly exampleConstant: string, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-type-diffing-types/NativeTypeDiffingTypes.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-type-diffing-types/NativeTypeDiffingTypes.js.flow index f27cc20a7b33..60593f5a4b89 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-type-diffing-types/NativeTypeDiffingTypes.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-type-diffing-types/NativeTypeDiffingTypes.js.flow @@ -170,55 +170,63 @@ enum EnumUnsorted { } export interface Spec extends TurboModule { - +stringLiteral0: (a: StringLiteral0) => void; - +stringLiteral1: (a: StringLiteral1) => void; - - +booleanLiteral0: (a: BooleanLiteral0) => void; - +booleanLiteral1: (a: BooleanLiteral1) => void; - - +numericLiteral0: (a: NumericLiteral0) => void; - +numericLiteral1: (a: NumericLiteral1) => void; - - +stringLiteralUnion0: (a: StringLiteralUnion0) => void; - +stringLiteralUnion1: (a: StringLiteralUnion1) => void; - +stringLiteralUnion2: (a: StringLiteralUnion2) => void; - - +referenceType: (a: ReferenceType) => void; - +referenceType2: (a: ReferenceType2) => void; - +referenceType3: (a: ReferenceType3) => void; - - +referenceGeneric: (a: ReferenceGeneric) => void; - +referenceGeneric2: (a: ReferenceGeneric2) => void; - - +objectTypeWithProps: (a: ObjectTypeWithProps) => void; - +objectTypeLessProps: (a: ObjectTypeLessProps) => void; - +objectTypeWithDifferentProps: (a: ObjectTypeWithDifferentProps) => void; - +objectTypeWithNesting: (a: ObjectTypeWithNesting) => void; - +objectTypeWithChanges: (a: ObjectTypeWithChanges) => void; - +objectTypeWithNestedChanges: (a: ObjectTypeWithNestedChanges) => void; - +objectTypeWithTwoOptionals: (a: ObjectTypeWithTwoOptionals) => void; - +objectTypeWithOptionalNestedChange: (a: ObjectTypeWithOptionalNestedChange) => void; - +nonNullableType: (a: NonNullableType) => void; - +nullableType: (a: NullableType) => void; - +genericObjectType: (a: GenericObjectType) => void; - +unsafeObjectType: (a: UnsafeObjectType) => void; - +optionalTypeLessProps: (a: OptionalTypeLessProps) => void; - +objectTypeLiteral1: (a: ObjectTypeLiteral1) => void; - +objectTypeLiteral2: (a: ObjectTypeLiteral2) => void; - +objectTypeLiteral1TypeAlias: (a: ObjectTypeLiteral1TypeAlias) => void; - +objectTypeLiteral2TypeAlias: (a: ObjectTypeLiteral2TypeAlias) => void; - +genericObjectType: (a: Object) => void; - - +mapWithKey: (a: MapWithKey) => void; - +mapWithKey2: (a: MapWithKey2) => void; - - +enum: (a: Enum) => void; - +enumWithTypeChange: (a: EnumWithTypeChange) => void; - +enumWithRemoval: (a: EnumWithRemoval) => void; - +enumWithValueChange: (a: EnumWithValueChange) => void; - +enumUnsorted: (a: EnumUnsorted) => void; + readonly stringLiteral0: (a: StringLiteral0) => void; + readonly stringLiteral1: (a: StringLiteral1) => void; + + readonly booleanLiteral0: (a: BooleanLiteral0) => void; + readonly booleanLiteral1: (a: BooleanLiteral1) => void; + + readonly numericLiteral0: (a: NumericLiteral0) => void; + readonly numericLiteral1: (a: NumericLiteral1) => void; + + readonly stringLiteralUnion0: (a: StringLiteralUnion0) => void; + readonly stringLiteralUnion1: (a: StringLiteralUnion1) => void; + readonly stringLiteralUnion2: (a: StringLiteralUnion2) => void; + + readonly referenceType: (a: ReferenceType) => void; + readonly referenceType2: (a: ReferenceType2) => void; + readonly referenceType3: (a: ReferenceType3) => void; + + readonly referenceGeneric: (a: ReferenceGeneric) => void; + readonly referenceGeneric2: (a: ReferenceGeneric2) => void; + + readonly objectTypeWithProps: (a: ObjectTypeWithProps) => void; + readonly objectTypeLessProps: (a: ObjectTypeLessProps) => void; + readonly objectTypeWithDifferentProps: ( + a: ObjectTypeWithDifferentProps, + ) => void; + readonly objectTypeWithNesting: (a: ObjectTypeWithNesting) => void; + readonly objectTypeWithChanges: (a: ObjectTypeWithChanges) => void; + readonly objectTypeWithNestedChanges: ( + a: ObjectTypeWithNestedChanges, + ) => void; + readonly objectTypeWithTwoOptionals: (a: ObjectTypeWithTwoOptionals) => void; + readonly objectTypeWithOptionalNestedChange: ( + a: ObjectTypeWithOptionalNestedChange, + ) => void; + readonly nonNullableType: (a: NonNullableType) => void; + readonly nullableType: (a: NullableType) => void; + readonly genericObjectType: (a: GenericObjectType) => void; + readonly unsafeObjectType: (a: UnsafeObjectType) => void; + readonly optionalTypeLessProps: (a: OptionalTypeLessProps) => void; + readonly objectTypeLiteral1: (a: ObjectTypeLiteral1) => void; + readonly objectTypeLiteral2: (a: ObjectTypeLiteral2) => void; + readonly objectTypeLiteral1TypeAlias: ( + a: ObjectTypeLiteral1TypeAlias, + ) => void; + readonly objectTypeLiteral2TypeAlias: ( + a: ObjectTypeLiteral2TypeAlias, + ) => void; + readonly genericObjectType: (a: Object) => void; + + readonly mapWithKey: (a: MapWithKey) => void; + readonly mapWithKey2: (a: MapWithKey2) => void; + + readonly enum: (a: Enum) => void; + readonly enumWithTypeChange: (a: EnumWithTypeChange) => void; + readonly enumWithRemoval: (a: EnumWithRemoval) => void; + readonly enumWithValueChange: (a: EnumWithValueChange) => void; + readonly enumUnsorted: (a: EnumUnsorted) => void; } -TurboModuleRegistry.getEnforcing( - 'NativeModuleTest', -) as Spec; +TurboModuleRegistry.getEnforcing('NativeModuleTest') as Spec; diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-dictionary-changed/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-dictionary-changed/NativeModule.js.flow index d3b76db667f0..9bc3d07fc9e5 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-dictionary-changed/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-dictionary-changed/NativeModule.js.flow @@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: {[key: string]: string}, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: {[key: string]: string}, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-dictionary/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-dictionary/NativeModule.js.flow index 6bfaf126dace..e7092067e477 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-dictionary/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-dictionary/NativeModule.js.flow @@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: {[key: string]: number}, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: {[key: string]: number}, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-changes/NativeModule.js.flow index 97c14a626e5b..57a4aaa4ac08 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-changes/NativeModule.js.flow @@ -20,9 +20,9 @@ enum TestEnum { } export interface Spec extends TurboModule { - +exampleFunction: (a: TestEnum, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: TestEnum, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-changes/NativeModule.js.flow index b976a2795881..b0d3a670ddf0 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-changes/NativeModule.js.flow @@ -20,9 +20,9 @@ enum TestEnum { } export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => { - +exampleConstant: TestEnum, + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: TestEnum, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-type-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-type-changes/NativeModule.js.flow index f1ec89117bd4..829480d56358 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-type-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-type-changes/NativeModule.js.flow @@ -19,9 +19,9 @@ enum TestEnum { } export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => { - +exampleConstant: TestEnum, + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: TestEnum, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-value-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-value-changes/NativeModule.js.flow index 09e201a6c843..8788d73a3e04 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-value-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native-value-changes/NativeModule.js.flow @@ -19,9 +19,9 @@ enum TestEnum { } export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => { - +exampleConstant: TestEnum, + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: TestEnum, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native/NativeModule.js.flow index a70bf90322c1..d903cf7ba2ff 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-from-native/NativeModule.js.flow @@ -19,9 +19,9 @@ enum TestEnum { } export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => { - +exampleConstant: TestEnum, + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: TestEnum, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-type-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-type-changes/NativeModule.js.flow index 9463313d32e0..1ac7cd374c56 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-type-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-type-changes/NativeModule.js.flow @@ -20,9 +20,9 @@ enum TestEnum { } export interface Spec extends TurboModule { - +exampleFunction: (a: TestEnum, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: TestEnum, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-value-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-value-changes/NativeModule.js.flow index 287e8ccfe70a..ca5d6c5cb7de 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-value-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum-value-changes/NativeModule.js.flow @@ -19,9 +19,9 @@ enum TestEnum { } export interface Spec extends TurboModule { - +exampleFunction: (a: TestEnum, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: TestEnum, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum/NativeModule.js.flow index 3c3a4b4f88d1..d07fc73e1669 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-enum/NativeModule.js.flow @@ -19,9 +19,9 @@ enum TestEnum { } export interface Spec extends TurboModule { - +exampleFunction: (a: TestEnum, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: TestEnum, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-optional-argument/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-optional-argument/NativeModule.js.flow index 26c5adb3cb0b..cfb6c420a55c 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-optional-argument/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-optional-argument/NativeModule.js.flow @@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number, c?: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: string, b: number, c?: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-boolean-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-boolean-changes/NativeModule.js.flow index 9f2c88d7cfbe..931f2b0b03ac 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-boolean-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-boolean-changes/NativeModule.js.flow @@ -16,9 +16,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type BooleanUnion = true | false; export interface Spec extends TurboModule { - +exampleFunction: (a: BooleanUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: BooleanUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-boolean/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-boolean/NativeModule.js.flow index 9c4b5e278cc9..1f16fe5c225b 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-boolean/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-boolean/NativeModule.js.flow @@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type BooleanUnion = true; export interface Spec extends TurboModule { - +exampleFunction: (a: BooleanUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: BooleanUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-changes/NativeModule.js.flow index 9959a7de531a..e174a6bbfc9a 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-changes/NativeModule.js.flow @@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type testUnion = 'a' | 'b' | 'c' | 'd'; export interface Spec extends TurboModule { - +exampleFunction: (a: testUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: testUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-confusing-string-literals/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-confusing-string-literals/NativeModule.js.flow index 12b23fc01aaa..b5faaa106479 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-confusing-string-literals/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-confusing-string-literals/NativeModule.js.flow @@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type testUnion = 'a' | '0' | '1' | 'a long string'; export interface Spec extends TurboModule { - +exampleFunction: (a: testUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: testUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-from-native-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-from-native-changes/NativeModule.js.flow index 85168428f4aa..650f086b854f 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-from-native-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-from-native-changes/NativeModule.js.flow @@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type testUnion = 'a' | 'b' | 'c' | 'd'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => { - +exampleConstant: testUnion, + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: testUnion, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-from-native/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-from-native/NativeModule.js.flow index 351e61da2d48..983924e816c2 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-from-native/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-from-native/NativeModule.js.flow @@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type testUnion = 'a' | 'b' | 'c'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => { - +exampleConstant: testUnion, + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: testUnion, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-number-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-number-changes/NativeModule.js.flow index e2bb96047bb8..15e80722798b 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-number-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-number-changes/NativeModule.js.flow @@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type NumberUnion = 4 | 5 | 6; export interface Spec extends TurboModule { - +exampleFunction: (a: NumberUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: NumberUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-number/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-number/NativeModule.js.flow index 00676cf3ca9e..eaaeeaafe013 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-number/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-number/NativeModule.js.flow @@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type NumberUnion = 1 | 2 | 3; export interface Spec extends TurboModule { - +exampleFunction: (a: NumberUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: NumberUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object-added/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object-added/NativeModule.js.flow index ba7cb421101d..f5183eef7a51 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object-added/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object-added/NativeModule.js.flow @@ -30,9 +30,9 @@ type ObjectC = {| type ObjectUnion = ObjectA | ObjectB | ObjectC; export interface Spec extends TurboModule { - +exampleFunction: (a: ObjectUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: ObjectUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object-changes/NativeModule.js.flow index 23a4a19e3452..fc05ed87058b 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object-changes/NativeModule.js.flow @@ -26,9 +26,9 @@ type ObjectB = {| type ObjectUnion = ObjectA | ObjectB; export interface Spec extends TurboModule { - +exampleFunction: (a: ObjectUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: ObjectUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object/NativeModule.js.flow index 39555ab1f767..3c23ff9a66f3 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-object/NativeModule.js.flow @@ -25,9 +25,9 @@ type ObjectB = {| type ObjectUnion = ObjectA | ObjectB; export interface Spec extends TurboModule { - +exampleFunction: (a: ObjectUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: ObjectUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-type-changes/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-type-changes/NativeModule.js.flow index affde92dc8c2..872c3754cb04 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-type-changes/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union-type-changes/NativeModule.js.flow @@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type testUnion = 1 | 2 | 3; export interface Spec extends TurboModule { - +exampleFunction: (a: testUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: testUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union/NativeModule.js.flow index 9a1e788e3b1d..f77ea1595716 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module-with-union/NativeModule.js.flow @@ -15,9 +15,9 @@ import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboMo type testUnion = 'a' | 'b' | 'c'; export interface Spec extends TurboModule { - +exampleFunction: (a: testUnion, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: testUnion, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module/NativeModule.js.flow b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module/NativeModule.js.flow index f84d19c86fae..fc04caa5d46c 100644 --- a/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module/NativeModule.js.flow +++ b/packages/react-native-compatibility-check/src/__tests__/__fixtures__/native-module/NativeModule.js.flow @@ -13,9 +13,9 @@ import type {TurboModule} from 'react-native/Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +exampleFunction: (a: string, b: number) => void; - +getConstants: () => { - +exampleConstant: number, + readonly exampleFunction: (a: string, b: number) => void; + readonly getConstants: () => { + readonly exampleConstant: number, }; } diff --git a/packages/react-native-popup-menu-android/js/PopupMenuAndroid.android.js b/packages/react-native-popup-menu-android/js/PopupMenuAndroid.android.js index ccebd6ccd8ff..379448c3650e 100644 --- a/packages/react-native-popup-menu-android/js/PopupMenuAndroid.android.js +++ b/packages/react-native-popup-menu-android/js/PopupMenuAndroid.android.js @@ -28,7 +28,7 @@ type PopupMenuSelectionEvent = NativeSyntheticEvent< type PopupMenuDismissEvent = NativeSyntheticEvent>; export type PopupMenuAndroidInstance = { - +show: () => void, + readonly show: () => void, }; type Props = { diff --git a/packages/react-native-popup-menu-android/js/PopupMenuAndroid.js b/packages/react-native-popup-menu-android/js/PopupMenuAndroid.js index cdb973a4f440..2ade8fa6e686 100644 --- a/packages/react-native-popup-menu-android/js/PopupMenuAndroid.js +++ b/packages/react-native-popup-menu-android/js/PopupMenuAndroid.js @@ -37,7 +37,7 @@ const styles = StyleSheet.create({ }); export type PopupMenuAndroidInstance = { - +show: () => void, + readonly show: () => void, }; type Props = { diff --git a/packages/react-native-popup-menu-android/js/PopupMenuAndroidNativeComponent.android.js b/packages/react-native-popup-menu-android/js/PopupMenuAndroidNativeComponent.android.js index 331d1d56854b..76eaae6edace 100644 --- a/packages/react-native-popup-menu-android/js/PopupMenuAndroidNativeComponent.android.js +++ b/packages/react-native-popup-menu-android/js/PopupMenuAndroidNativeComponent.android.js @@ -38,7 +38,7 @@ type NativeProps = Readonly<{ type ComponentType = HostComponent; interface NativeCommands { - +show: (viewRef: React.ElementRef) => void; + readonly show: (viewRef: React.ElementRef) => void; } export const Commands: NativeCommands = codegenNativeCommands({ diff --git a/packages/react-native/Libraries/Animated/nodes/AnimatedColor.js b/packages/react-native/Libraries/Animated/nodes/AnimatedColor.js index 7f068989e061..712c259d72ca 100644 --- a/packages/react-native/Libraries/Animated/nodes/AnimatedColor.js +++ b/packages/react-native/Libraries/Animated/nodes/AnimatedColor.js @@ -30,18 +30,18 @@ export type AnimatedColorConfig = Readonly<{ type ColorListenerCallback = (value: ColorValue) => unknown; export type RgbaValue = { - +r: number, - +g: number, - +b: number, - +a: number, + readonly r: number, + readonly g: number, + readonly b: number, + readonly a: number, ... }; type RgbaAnimatedValue = { - +r: AnimatedValue, - +g: AnimatedValue, - +b: AnimatedValue, - +a: AnimatedValue, + readonly r: AnimatedValue, + readonly g: AnimatedValue, + readonly b: AnimatedValue, + readonly a: AnimatedValue, ... }; diff --git a/packages/react-native/Libraries/Animated/nodes/AnimatedProps.js b/packages/react-native/Libraries/Animated/nodes/AnimatedProps.js index e053d91635a2..a29bd5ed5a55 100644 --- a/packages/react-native/Libraries/Animated/nodes/AnimatedProps.js +++ b/packages/react-native/Libraries/Animated/nodes/AnimatedProps.js @@ -30,7 +30,7 @@ export type AnimatedPropsAllowlist = Readonly<{ }>; type TargetView = { - +instance: TargetViewInstance, + readonly instance: TargetViewInstance, connectedViewTag: ?number, }; type TargetViewInstance = React.ElementRef; diff --git a/packages/react-native/Libraries/Animated/nodes/AnimatedValueXY.js b/packages/react-native/Libraries/Animated/nodes/AnimatedValueXY.js index acc969ad2d20..0c008919c8b8 100644 --- a/packages/react-native/Libraries/Animated/nodes/AnimatedValueXY.js +++ b/packages/react-native/Libraries/Animated/nodes/AnimatedValueXY.js @@ -45,8 +45,8 @@ export default class AnimatedValueXY extends AnimatedWithChildren { constructor( valueIn?: ?{ - +x: number | AnimatedValue, - +y: number | AnimatedValue, + readonly x: number | AnimatedValue, + readonly y: number | AnimatedValue, ... }, config?: ?AnimatedValueXYConfig, diff --git a/packages/react-native/Libraries/Blob/URLSearchParams.js.flow b/packages/react-native/Libraries/Blob/URLSearchParams.js.flow index 32ab77b30b7c..df5b32557dda 100644 --- a/packages/react-native/Libraries/Blob/URLSearchParams.js.flow +++ b/packages/react-native/Libraries/Blob/URLSearchParams.js.flow @@ -10,7 +10,7 @@ declare export class URLSearchParams { _searchParams: Array<[string, string]>; - +size: number; + readonly size: number; constructor( params?: Record | string | Array<[string, string]>, ): void; diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js index d19eb049ee1f..1911429065ba 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollView.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollView.js @@ -135,19 +135,19 @@ export interface ScrollViewScrollToOptions { // Public methods for ScrollView export interface ScrollViewImperativeMethods { - +getScrollResponder: () => ScrollResponderType; - +getScrollableNode: () => ?number; - +getInnerViewNode: () => ?number; - +getInnerViewRef: () => InnerViewInstance | null; - +getNativeScrollRef: () => PublicScrollViewInstance | null; - +scrollTo: ( + readonly getScrollResponder: () => ScrollResponderType; + readonly getScrollableNode: () => ?number; + readonly getInnerViewNode: () => ?number; + readonly getInnerViewRef: () => InnerViewInstance | null; + readonly getNativeScrollRef: () => PublicScrollViewInstance | null; + readonly scrollTo: ( options?: ScrollViewScrollToOptions | number, deprecatedX?: number, deprecatedAnimated?: boolean, ) => void; - +scrollToEnd: (options?: ?ScrollViewScrollToOptions) => void; - +flashScrollIndicators: () => void; - +scrollResponderZoomTo: ( + readonly scrollToEnd: (options?: ?ScrollViewScrollToOptions) => void; + readonly flashScrollIndicators: () => void; + readonly scrollResponderZoomTo: ( rect: { x: number, y: number, @@ -157,7 +157,7 @@ export interface ScrollViewImperativeMethods { }, animated?: boolean, // deprecated, put this inside the rect argument instead ) => void; - +scrollResponderScrollNativeHandleToKeyboard: ( + readonly scrollResponderScrollNativeHandleToKeyboard: ( nodeHandle: number | HostInstance, additionalOffset?: number, preventNegativeScrollOffset?: boolean, diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollViewCommands.js b/packages/react-native/Libraries/Components/ScrollView/ScrollViewCommands.js index 6e57b7a776aa..bee614292c72 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollViewCommands.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollViewCommands.js @@ -16,20 +16,20 @@ import * as React from 'react'; type ScrollViewNativeComponentType = HostComponent<{...}>; interface NativeCommands { - +flashScrollIndicators: ( + readonly flashScrollIndicators: ( viewRef: React.ElementRef, ) => void; - +scrollTo: ( + readonly scrollTo: ( viewRef: React.ElementRef, x: Double, y: Double, animated: boolean, ) => void; - +scrollToEnd: ( + readonly scrollToEnd: ( viewRef: React.ElementRef, animated: boolean, ) => void; - +zoomToRect: ( + readonly zoomToRect: ( viewRef: React.ElementRef, rect: { x: Double, diff --git a/packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index 72804f697538..692b4b7e63ac 100644 --- a/packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/packages/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -40,7 +40,7 @@ export type ScrollViewStickyHeaderProps = Readonly<{ }>; interface Instance extends React.ElementRef { - +setNextHeaderY: number => void; + readonly setNextHeaderY: number => void; } const ScrollViewStickyHeader: component( diff --git a/packages/react-native/Libraries/Components/TextInput/InputAccessoryView.js b/packages/react-native/Libraries/Components/TextInput/InputAccessoryView.js index cf487dd02471..0ecc6f77c1c7 100644 --- a/packages/react-native/Libraries/Components/TextInput/InputAccessoryView.js +++ b/packages/react-native/Libraries/Components/TextInput/InputAccessoryView.js @@ -78,7 +78,7 @@ import * as React from 'react'; /** @build-types emit-as-interface Expo compatibility */ export type InputAccessoryViewProps = Readonly<{ - +children: React.Node, + readonly children: React.Node, /** * An ID which is used to associate this `InputAccessoryView` to * specified TextInput(s). diff --git a/packages/react-native/Libraries/Components/TextInput/TextInputNativeCommands.js b/packages/react-native/Libraries/Components/TextInput/TextInputNativeCommands.js index 9da88998c47c..63cc9a373bae 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInputNativeCommands.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInputNativeCommands.js @@ -13,9 +13,9 @@ import type {Int32} from '../../Types/CodegenTypes'; import * as React from 'react'; export interface TextInputNativeCommands { - +focus: (viewRef: React.ElementRef) => void; - +blur: (viewRef: React.ElementRef) => void; - +setTextAndSelection: ( + readonly focus: (viewRef: React.ElementRef) => void; + readonly blur: (viewRef: React.ElementRef) => void; + readonly setTextAndSelection: ( viewRef: React.ElementRef, mostRecentEventCount: Int32, value: ?string, // in theory this is nullable diff --git a/packages/react-native/Libraries/Components/Touchable/Touchable.js b/packages/react-native/Libraries/Components/Touchable/Touchable.js index 23358c37aaaa..72c4aef50d6e 100644 --- a/packages/react-native/Libraries/Components/Touchable/Touchable.js +++ b/packages/react-native/Libraries/Components/Touchable/Touchable.js @@ -25,16 +25,16 @@ import Position from './Position'; import * as React from 'react'; const extractSingleTouch = (nativeEvent: { - +changedTouches: ReadonlyArray, - +force?: number, - +identifier: number, - +locationX: number, - +locationY: number, - +pageX: number, - +pageY: number, - +target: ?number, - +timestamp: number, - +touches: ReadonlyArray, + readonly changedTouches: ReadonlyArray, + readonly force?: number, + readonly identifier: number, + readonly locationX: number, + readonly locationY: number, + readonly pageX: number, + readonly pageY: number, + readonly target: ?number, + readonly timestamp: number, + readonly touches: ReadonlyArray, }) => { const touches = nativeEvent.touches; const changedTouches = nativeEvent.changedTouches; diff --git a/packages/react-native/Libraries/Components/View/ViewNativeComponent.js b/packages/react-native/Libraries/Components/View/ViewNativeComponent.js index 2a28cd4bd992..3185121e81a7 100644 --- a/packages/react-native/Libraries/Components/View/ViewNativeComponent.js +++ b/packages/react-native/Libraries/Components/View/ViewNativeComponent.js @@ -21,10 +21,10 @@ const ViewNativeComponent: HostComponent = })); interface NativeCommands { - +focus: (viewRef: HostInstance) => void; - +blur: (viewRef: HostInstance) => void; - +hotspotUpdate: (viewRef: HostInstance, x: number, y: number) => void; - +setPressed: (viewRef: HostInstance, pressed: boolean) => void; + readonly focus: (viewRef: HostInstance) => void; + readonly blur: (viewRef: HostInstance) => void; + readonly hotspotUpdate: (viewRef: HostInstance, x: number, y: number) => void; + readonly setPressed: (viewRef: HostInstance, pressed: boolean) => void; } export const Commands: NativeCommands = codegenNativeCommands({ diff --git a/packages/react-native/Libraries/Core/ReactFiberErrorDialog.js b/packages/react-native/Libraries/Core/ReactFiberErrorDialog.js index d47ed4c6377f..9b0a36dfedb3 100644 --- a/packages/react-native/Libraries/Core/ReactFiberErrorDialog.js +++ b/packages/react-native/Libraries/Core/ReactFiberErrorDialog.js @@ -13,9 +13,9 @@ import type {ExtendedError} from './ExtendedError'; import ExceptionsManager, {SyntheticError} from './ExceptionsManager'; export type CapturedError = { - +componentStack: string, - +error: unknown, - +errorBoundary: ?{...}, + readonly componentStack: string, + readonly error: unknown, + readonly errorBoundary: ?{...}, ... }; diff --git a/packages/react-native/Libraries/Image/AssetSourceResolver.js b/packages/react-native/Libraries/Image/AssetSourceResolver.js index cb665428333f..2b1e9647608a 100644 --- a/packages/react-native/Libraries/Image/AssetSourceResolver.js +++ b/packages/react-native/Libraries/Image/AssetSourceResolver.js @@ -11,11 +11,11 @@ 'use strict'; export type ResolvedAssetSource = { - +__packager_asset: boolean, - +width: ?number, - +height: ?number, - +uri: string, - +scale: number, + readonly __packager_asset: boolean, + readonly width: ?number, + readonly height: ?number, + readonly uri: string, + readonly scale: number, }; // From @react-native/assets-registry diff --git a/packages/react-native/Libraries/Image/ImageSource.js b/packages/react-native/Libraries/Image/ImageSource.js index 89e79245e543..de099b77c4b3 100644 --- a/packages/react-native/Libraries/Image/ImageSource.js +++ b/packages/react-native/Libraries/Image/ImageSource.js @@ -21,32 +21,32 @@ export interface ImageURISource { * resource (which should be wrapped in the `require('./path/to/image.png')` * function). */ - +uri?: ?string; + readonly uri?: ?string; /** * `bundle` is the iOS asset bundle which the image is included in. This * will default to [NSBundle mainBundle] if not set. * @platform ios */ - +bundle?: ?string; + readonly bundle?: ?string; /** * `method` is the HTTP Method to use. Defaults to GET if not specified. */ - +method?: ?string; + readonly method?: ?string; /** * `headers` is an object representing the HTTP headers to send along with the * request for a remote image. */ - +headers?: ?{[string]: string}; + readonly headers?: ?{[string]: string}; /** * `body` is the HTTP body to send with the request. This must be a valid * UTF-8 string, and will be sent exactly as specified, with no * additional encoding (e.g. URL-escaping or base64) applied. */ - +body?: ?string; + readonly body?: ?string; /** * `cache` determines how the requests handles potentially cached @@ -66,20 +66,20 @@ export interface ImageURISource { * to a URL load request, no attempt is made to load the data from the originating source, * and the load is considered to have failed. */ - +cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'); + readonly cache?: ?('default' | 'reload' | 'force-cache' | 'only-if-cached'); /** * `width` and `height` can be specified if known at build time, in which case * these will be used to set the default `` component dimensions. */ - +width?: ?number; - +height?: ?number; + readonly width?: ?number; + readonly height?: ?number; /** * `scale` is used to indicate the scale factor of the image. Defaults to 1.0 if * unspecified, meaning that one image pixel equates to one display point / DIP. */ - +scale?: ?number; + readonly scale?: ?number; } export type ImageRequireSource = number; diff --git a/packages/react-native/Libraries/Image/ImageSourceUtils.js b/packages/react-native/Libraries/Image/ImageSourceUtils.js index 9c3375eafc22..7e5ea6436d5a 100644 --- a/packages/react-native/Libraries/Image/ImageSourceUtils.js +++ b/packages/react-native/Libraries/Image/ImageSourceUtils.js @@ -26,10 +26,10 @@ export type ImageSourceHeaders = { export function getImageSourcesFromImageProps(imageProps: ImageProps): | ?ResolvedAssetSource | ReadonlyArray<{ - +uri: string, - +headers: ImageSourceHeaders, - +width: ?number, - +height: ?number, + readonly uri: string, + readonly headers: ImageSourceHeaders, + readonly width: ?number, + readonly height: ?number, ... }> { let source = resolveAssetSource(imageProps.source); diff --git a/packages/react-native/Libraries/Image/ImageViewNativeComponent.js b/packages/react-native/Libraries/Image/ImageViewNativeComponent.js index fd6c79ed87ba..94e6970863b3 100644 --- a/packages/react-native/Libraries/Image/ImageViewNativeComponent.js +++ b/packages/react-native/Libraries/Image/ImageViewNativeComponent.js @@ -45,7 +45,7 @@ type ImageHostComponentProps = Readonly<{ }>; interface NativeCommands { - +setIsVisible_EXPERIMENTAL: ( + readonly setIsVisible_EXPERIMENTAL: ( viewRef: HostInstance, isVisible: boolean, time: number, diff --git a/packages/react-native/Libraries/NativeComponent/ViewConfig.js b/packages/react-native/Libraries/NativeComponent/ViewConfig.js index 857db000cb32..9b19492ff643 100644 --- a/packages/react-native/Libraries/NativeComponent/ViewConfig.js +++ b/packages/react-native/Libraries/NativeComponent/ViewConfig.js @@ -43,9 +43,9 @@ export function createViewConfig( } function composeIndexers( - maybeA: ?{+[string]: T}, - maybeB: ?{+[string]: T}, -): {+[string]: T} { + maybeA: ?{readonly [string]: T}, + maybeB: ?{readonly [string]: T}, +): {readonly [string]: T} { return maybeA == null || maybeB == null ? (maybeA ?? maybeB ?? {}) : {...maybeA, ...maybeB}; diff --git a/packages/react-native/Libraries/NativeComponent/ViewConfigIgnore.js b/packages/react-native/Libraries/NativeComponent/ViewConfigIgnore.js index d45d688c6e20..487913175e43 100644 --- a/packages/react-native/Libraries/NativeComponent/ViewConfigIgnore.js +++ b/packages/react-native/Libraries/NativeComponent/ViewConfigIgnore.js @@ -37,7 +37,7 @@ export function DynamicallyInjectedByGestureHandler( * TODO(T110872225): Remove this logic, after achieving platform-consistency */ export function ConditionallyIgnoredEventHandlers< - const T extends {+[name: string]: true}, + const T extends {readonly [name: string]: true}, >(value: T): T | void { if (Platform.OS === 'ios') { return value; diff --git a/packages/react-native/Libraries/ReactNative/AppContainer-dev.js b/packages/react-native/Libraries/ReactNative/AppContainer-dev.js index db3e0868daa7..a0abc38caec4 100644 --- a/packages/react-native/Libraries/ReactNative/AppContainer-dev.js +++ b/packages/react-native/Libraries/ReactNative/AppContainer-dev.js @@ -44,7 +44,9 @@ if (reactDevToolsHook) { type ExternalInspection = { externalInspectingEnabled: boolean, - +reportToExternalInspection: (viewData: TouchedViewDataAtPoint) => void, + readonly reportToExternalInspection: ( + viewData: TouchedViewDataAtPoint, + ) => void, }; type InspectorDeferredProps = { diff --git a/packages/react-native/Libraries/ReactNative/DisplayMode.js b/packages/react-native/Libraries/ReactNative/DisplayMode.js index 4de3035833b6..83df15dab306 100644 --- a/packages/react-native/Libraries/ReactNative/DisplayMode.js +++ b/packages/react-native/Libraries/ReactNative/DisplayMode.js @@ -12,7 +12,7 @@ export opaque type DisplayModeType = number; /** DisplayMode should be in sync with the method displayModeToInt from * react/renderer/uimanager/primitives.h. */ -const DisplayMode: {+[string]: DisplayModeType} = Object.freeze({ +const DisplayMode: {readonly [string]: DisplayModeType} = Object.freeze({ VISIBLE: 1, SUSPENDED: 2, HIDDEN: 3, diff --git a/packages/react-native/Libraries/ReactNative/FabricUIManager.js b/packages/react-native/Libraries/ReactNative/FabricUIManager.js index cc55ca8b59fa..8f33a442b64b 100644 --- a/packages/react-native/Libraries/ReactNative/FabricUIManager.js +++ b/packages/react-native/Libraries/ReactNative/FabricUIManager.js @@ -28,62 +28,65 @@ import defineLazyObjectProperty from '../Utilities/defineLazyObjectProperty'; export type NodeSet = Array; export type NodeProps = {...}; export interface Spec { - +createNode: ( + readonly createNode: ( reactTag: number, viewName: string, rootTag: RootTag, props: NodeProps, instanceHandle: InternalInstanceHandle, ) => Node; - +cloneNode: (node: Node) => Node; - +cloneNodeWithNewChildren: (node: Node) => Node; - +cloneNodeWithNewProps: (node: Node, newProps: NodeProps) => Node; - +cloneNodeWithNewChildrenAndProps: (node: Node, newProps: NodeProps) => Node; - +createChildSet: (rootTag: RootTag) => NodeSet; - +appendChild: (parentNode: Node, child: Node) => Node; - +appendChildToSet: (childSet: NodeSet, child: Node) => void; - +completeRoot: (rootTag: RootTag, childSet: NodeSet) => void; - +measure: ( + readonly cloneNode: (node: Node) => Node; + readonly cloneNodeWithNewChildren: (node: Node) => Node; + readonly cloneNodeWithNewProps: (node: Node, newProps: NodeProps) => Node; + readonly cloneNodeWithNewChildrenAndProps: ( + node: Node, + newProps: NodeProps, + ) => Node; + readonly createChildSet: (rootTag: RootTag) => NodeSet; + readonly appendChild: (parentNode: Node, child: Node) => Node; + readonly appendChildToSet: (childSet: NodeSet, child: Node) => void; + readonly completeRoot: (rootTag: RootTag, childSet: NodeSet) => void; + readonly measure: ( node: Node | NativeElementReference, callback: MeasureOnSuccessCallback, ) => void; - +measureInWindow: ( + readonly measureInWindow: ( node: Node | NativeElementReference, callback: MeasureInWindowOnSuccessCallback, ) => void; - +measureLayout: ( + readonly measureLayout: ( node: Node | NativeElementReference, relativeNode: Node | NativeElementReference, onFail: () => void, onSuccess: MeasureLayoutOnSuccessCallback, ) => void; - +configureNextLayoutAnimation: ( + readonly configureNextLayoutAnimation: ( config: LayoutAnimationConfig, callback: () => void, // check what is returned here errorCallback: () => void, ) => void; - +sendAccessibilityEvent: (node: Node, eventType: string) => void; - +findShadowNodeByTag_DEPRECATED: (reactTag: number) => ?Node; - +setNativeProps: ( + readonly sendAccessibilityEvent: (node: Node, eventType: string) => void; + readonly findShadowNodeByTag_DEPRECATED: (reactTag: number) => ?Node; + readonly setNativeProps: ( node: Node | NativeElementReference, newProps: NodeProps, ) => void; - +dispatchCommand: ( + readonly dispatchCommand: ( node: Node, commandName: string, args: Array, ) => void; - +findNodeAtPoint: ( + readonly findNodeAtPoint: ( node: Node, locationX: number, locationY: number, callback: (instanceHandle: ?InternalInstanceHandle) => void, ) => void; - +compareDocumentPosition: ( + readonly compareDocumentPosition: ( node: Node | NativeElementReference, otherNode: Node | NativeElementReference, ) => number; - +getBoundingClientRect: ( + readonly getBoundingClientRect: ( node: Node | NativeElementReference, includeTransform: boolean, ) => ?[ @@ -92,16 +95,16 @@ export interface Spec { /* width: */ number, /* height: */ number, ]; - +setIsJSResponder: ( + readonly setIsJSResponder: ( node: Node | NativeElementReference, isJSResponder: boolean, blockNativeResponder: boolean, ) => void; - +unstable_DefaultEventPriority: number; - +unstable_DiscreteEventPriority: number; - +unstable_ContinuousEventPriority: number; - +unstable_IdleEventPriority: number; - +unstable_getCurrentEventPriority: () => number; + readonly unstable_DefaultEventPriority: number; + readonly unstable_DiscreteEventPriority: number; + readonly unstable_ContinuousEventPriority: number; + readonly unstable_IdleEventPriority: number; + readonly unstable_getCurrentEventPriority: () => number; } let nativeFabricUIManagerProxy: ?Spec; diff --git a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js index 5b38c6dbc2d5..c9acc144e067 100644 --- a/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js +++ b/packages/react-native/Libraries/StyleSheet/StyleSheetTypes.js @@ -1092,7 +1092,7 @@ export type ____ImageStyleProp_Internal = StyleProp< export type ____Styles_Internal = { // $FlowFixMe[incompatible-exact] // $FlowFixMe[incompatible-type] - +[key: string]: Partial<____DangerouslyImpreciseStyle_Internal>, + readonly [key: string]: Partial<____DangerouslyImpreciseStyle_Internal>, ... }; diff --git a/packages/react-native/Libraries/StyleSheet/private/_TransformStyle.js b/packages/react-native/Libraries/StyleSheet/private/_TransformStyle.js index 21f657353714..b46421463c3a 100644 --- a/packages/react-native/Libraries/StyleSheet/private/_TransformStyle.js +++ b/packages/react-native/Libraries/StyleSheet/private/_TransformStyle.js @@ -51,29 +51,31 @@ export type ____TransformStyle_Internal = Readonly<{ Readonly< MaximumOneOf< MergeUnion< - | {+perspective: number | AnimatedNode} - | {+rotate: string | AnimatedNode} - | {+rotateX: string | AnimatedNode} - | {+rotateY: string | AnimatedNode} - | {+rotateZ: string | AnimatedNode} - | {+scale: number | AnimatedNode} - | {+scaleX: number | AnimatedNode} - | {+scaleY: number | AnimatedNode} - | {+translateX: number | string | AnimatedNode} - | {+translateY: number | string | AnimatedNode} + | {readonly perspective: number | AnimatedNode} + | {readonly rotate: string | AnimatedNode} + | {readonly rotateX: string | AnimatedNode} + | {readonly rotateY: string | AnimatedNode} + | {readonly rotateZ: string | AnimatedNode} + | {readonly scale: number | AnimatedNode} + | {readonly scaleX: number | AnimatedNode} + | {readonly scaleY: number | AnimatedNode} + | {readonly translateX: number | string | AnimatedNode} + | {readonly translateY: number | string | AnimatedNode} | { - +translate: + readonly translate: | [ number | string | AnimatedNode, number | string | AnimatedNode, ] | AnimatedNode, } - | {+skewX: string | AnimatedNode} - | {+skewY: string | AnimatedNode} + | {readonly skewX: string | AnimatedNode} + | {readonly skewY: string | AnimatedNode} // TODO: what is the actual type it expects? | { - +matrix: ReadonlyArray | AnimatedNode, + readonly matrix: + | ReadonlyArray + | AnimatedNode, }, >, >, diff --git a/packages/react-native/Libraries/Text/TextEffectNativeComponent.js b/packages/react-native/Libraries/Text/TextEffectNativeComponent.js index f11d5ecfd5aa..8a6617e6cc4c 100644 --- a/packages/react-native/Libraries/Text/TextEffectNativeComponent.js +++ b/packages/react-native/Libraries/Text/TextEffectNativeComponent.js @@ -15,7 +15,7 @@ import * as React from 'react'; type NativeTextEffectProps = Readonly<{ effectName?: ?string, - effectProps?: ?Readonly<{+[string]: unknown}>, + effectProps?: ?Readonly<{readonly [string]: unknown}>, children?: React.Node, }>; diff --git a/packages/react-native/Libraries/TurboModule/RCTExport.js b/packages/react-native/Libraries/TurboModule/RCTExport.js index 09761f057ac3..9f8775142ff3 100644 --- a/packages/react-native/Libraries/TurboModule/RCTExport.js +++ b/packages/react-native/Libraries/TurboModule/RCTExport.js @@ -30,7 +30,7 @@ // eslint-disable-next-line no-unused-vars export interface DEPRECATED_RCTExport { - +getConstants?: () => {...}; + readonly getConstants?: () => {...}; } export interface TurboModule extends DEPRECATED_RCTExport {} diff --git a/packages/react-native/Libraries/Types/CoreEventTypes.js b/packages/react-native/Libraries/Types/CoreEventTypes.js index d2d0b34deee5..3889ec8b3d59 100644 --- a/packages/react-native/Libraries/Types/CoreEventTypes.js +++ b/packages/react-native/Libraries/Types/CoreEventTypes.js @@ -89,7 +89,7 @@ export interface NativeUIEvent { /** * Returns a long with details about the event, depending on the event type. */ - +detail: number; + readonly detail: number; } /** @@ -99,72 +99,72 @@ export interface NativeMouseEvent extends NativeUIEvent { /** * The X coordinate of the mouse pointer in global (screen) coordinates. */ - +screenX: number; + readonly screenX: number; /** * The Y coordinate of the mouse pointer in global (screen) coordinates. */ - +screenY: number; + readonly screenY: number; /** * The X coordinate of the mouse pointer relative to the whole document. */ - +pageX: number; + readonly pageX: number; /** * The Y coordinate of the mouse pointer relative to the whole document. */ - +pageY: number; + readonly pageY: number; /** * The X coordinate of the mouse pointer in local (DOM content) coordinates. */ - +clientX: number; + readonly clientX: number; /** * The Y coordinate of the mouse pointer in local (DOM content) coordinates. */ - +clientY: number; + readonly clientY: number; /** * Alias for NativeMouseEvent.clientX */ - +x: number; + readonly x: number; /** * Alias for NativeMouseEvent.clientY */ - +y: number; + readonly y: number; /** * Returns true if the control key was down when the mouse event was fired. */ - +ctrlKey: boolean; + readonly ctrlKey: boolean; /** * Returns true if the shift key was down when the mouse event was fired. */ - +shiftKey: boolean; + readonly shiftKey: boolean; /** * Returns true if the alt key was down when the mouse event was fired. */ - +altKey: boolean; + readonly altKey: boolean; /** * Returns true if the meta key was down when the mouse event was fired. */ - +metaKey: boolean; + readonly metaKey: boolean; /** * The button number that was pressed (if applicable) when the mouse event was fired. */ - +button: number; + readonly button: number; /** * The buttons being depressed (if any) when the mouse event was fired. */ - +buttons: number; + readonly buttons: number; /** * The secondary target for the event, if there is one. */ - +relatedTarget: null | number | HostInstance; + readonly relatedTarget: null | number | HostInstance; // offset is proposed: https://drafts.csswg.org/cssom-view/#extensions-to-the-mouseevent-interface /** * The X coordinate of the mouse pointer between that event and the padding edge of the target node */ - +offsetX: number; + readonly offsetX: number; /** * The Y coordinate of the mouse pointer between that event and the padding edge of the target node */ - +offsetY: number; + readonly offsetY: number; } /** @@ -174,48 +174,48 @@ export interface NativePointerEvent extends NativeMouseEvent { /** * A unique identifier for the pointer causing the event. */ - +pointerId: number; + readonly pointerId: number; /** * The width (magnitude on the X axis), in CSS pixels, of the contact geometry of the pointer */ - +width: number; + readonly width: number; /** * The height (magnitude on the Y axis), in CSS pixels, of the contact geometry of the pointer. */ - +height: number; + readonly height: number; /** * The normalized pressure of the pointer input in the range 0 to 1, where 0 and 1 represent * the minimum and maximum pressure the hardware is capable of detecting, respectively. */ - +pressure: number; + readonly pressure: number; /** * The normalized tangential pressure of the pointer input (also known as barrel pressure or * cylinder stress) in the range -1 to 1, where 0 is the neutral position of the control. */ - +tangentialPressure: number; + readonly tangentialPressure: number; /** * The plane angle (in degrees, in the range of -90 to 90) between the Y–Z plane and the plane * containing both the pointer (e.g. pen stylus) axis and the Y axis. */ - +tiltX: number; + readonly tiltX: number; /** * The plane angle (in degrees, in the range of -90 to 90) between the X–Z plane and the plane * containing both the pointer (e.g. pen stylus) axis and the X axis. */ - +tiltY: number; + readonly tiltY: number; /** * The clockwise rotation of the pointer (e.g. pen stylus) around its major axis in degrees, * with a value in the range 0 to 359. */ - +twist: number; + readonly twist: number; /** * Indicates the device type that caused the event (mouse, pen, touch, etc.) */ - +pointerType: string; + readonly pointerType: string; /** * Indicates if the pointer represents the primary pointer of this pointer type. */ - +isPrimary: boolean; + readonly isPrimary: boolean; } export type PointerEvent = NativeSyntheticEvent; diff --git a/packages/react-native/Libraries/Types/UIManagerJSInterface.js b/packages/react-native/Libraries/Types/UIManagerJSInterface.js index 4dc3fe1aac85..26d59a2c13c4 100644 --- a/packages/react-native/Libraries/Types/UIManagerJSInterface.js +++ b/packages/react-native/Libraries/Types/UIManagerJSInterface.js @@ -11,6 +11,6 @@ import type {Spec} from '../ReactNative/NativeUIManager'; export interface UIManagerJSInterface extends Spec { - +getViewManagerConfig: (viewManagerName: string) => Object; - +hasViewManagerConfig: (viewManagerName: string) => boolean; + readonly getViewManagerConfig: (viewManagerName: string) => Object; + readonly hasViewManagerConfig: (viewManagerName: string) => boolean; } diff --git a/packages/react-native/Libraries/Utilities/Appearance.js b/packages/react-native/Libraries/Utilities/Appearance.js index 936b03f93852..2d11088f1301 100644 --- a/packages/react-native/Libraries/Utilities/Appearance.js +++ b/packages/react-native/Libraries/Utilities/Appearance.js @@ -30,14 +30,14 @@ type Appearance = { }; let lazyState: ?{ - +NativeAppearance: INativeAppearance, + readonly NativeAppearance: INativeAppearance, // Cache the color scheme to reduce the cost of reading it between changes. // NOTE: If `NativeAppearance` is null, this will always be null. appearance: ?Appearance, // NOTE: This is non-nullable to make it easier for `onChangedListener` to // return a non-nullable `EventSubscription` value. This is not the common // path, so we do not have to over-optimize it. - +eventEmitter: EventEmitter<{change: [Appearance]}>, + readonly eventEmitter: EventEmitter<{change: [Appearance]}>, }; /** diff --git a/packages/react-native/Libraries/Utilities/BackHandler.android.js b/packages/react-native/Libraries/Utilities/BackHandler.android.js index d29e71fa07b7..c47b0f6a22be 100644 --- a/packages/react-native/Libraries/Utilities/BackHandler.android.js +++ b/packages/react-native/Libraries/Utilities/BackHandler.android.js @@ -63,8 +63,8 @@ RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function (nativeEvent) { * ``` */ type TBackHandler = { - +exitApp: () => void, - +addEventListener: ( + readonly exitApp: () => void, + readonly addEventListener: ( eventName: BackPressEventName, handler: BackPressHandler, ) => {remove: () => void, ...}, diff --git a/packages/react-native/Libraries/Utilities/BackHandler.js.flow b/packages/react-native/Libraries/Utilities/BackHandler.js.flow index eeef9af7b3fa..bf50d60d209a 100644 --- a/packages/react-native/Libraries/Utilities/BackHandler.js.flow +++ b/packages/react-native/Libraries/Utilities/BackHandler.js.flow @@ -13,8 +13,8 @@ export type BackPressEventName = 'backPress' | 'hardwareBackPress'; export interface HardwareBackPressEvent { - +type: string; - +timeStamp: number; + readonly type: string; + readonly timeStamp: number; } type TBackHandler = { diff --git a/packages/react-native/Libraries/Utilities/differ/deepDiffer.js b/packages/react-native/Libraries/Utilities/differ/deepDiffer.js index f739779ae7d3..0f5d48cc7270 100644 --- a/packages/react-native/Libraries/Utilities/differ/deepDiffer.js +++ b/packages/react-native/Libraries/Utilities/differ/deepDiffer.js @@ -13,10 +13,13 @@ let logListeners; type LogListeners = { - +onDifferentFunctionsIgnored: (nameOne: ?string, nameTwo: ?string) => void, + readonly onDifferentFunctionsIgnored: ( + nameOne: ?string, + nameTwo: ?string, + ) => void, }; -type Options = {+unsafelyIgnoreFunctions?: boolean}; +type Options = {readonly unsafelyIgnoreFunctions?: boolean}; function unstable_setLogListeners(listeners: ?LogListeners) { logListeners = listeners; diff --git a/packages/react-native/Libraries/vendor/emitter/EventEmitter.js b/packages/react-native/Libraries/vendor/emitter/EventEmitter.js index 4b7224431975..9f60d3e8ee31 100644 --- a/packages/react-native/Libraries/vendor/emitter/EventEmitter.js +++ b/packages/react-native/Libraries/vendor/emitter/EventEmitter.js @@ -41,9 +41,9 @@ export interface IEventEmitter< } interface Registration { - +context: unknown; - +listener: (...args: TArgs) => unknown; - +remove: () => void; + readonly context: unknown; + readonly listener: (...args: TArgs) => unknown; + readonly remove: () => void; } type Registry< diff --git a/packages/react-native/flow/bom.js.flow b/packages/react-native/flow/bom.js.flow index d6466e09d6f3..64fd2d2b1a64 100644 --- a/packages/react-native/flow/bom.js.flow +++ b/packages/react-native/flow/bom.js.flow @@ -114,12 +114,12 @@ declare class PerformanceEntry { // https://w3c.github.io/user-timing/#performancemark declare class PerformanceMark extends PerformanceEntry { constructor(name: string, markOptions?: PerformanceMarkOptions): void; - +detail: unknown; + readonly detail: unknown; } // https://w3c.github.io/user-timing/#performancemeasure declare class PerformanceMeasure extends PerformanceEntry { - +detail: unknown; + readonly detail: unknown; } // https://w3c.github.io/server-timing/#the-performanceservertiming-interface @@ -207,8 +207,8 @@ declare interface EventCounts { } declare class Performance { - +eventCounts: EventCounts; - +timeOrigin: DOMHighResTimeStamp; + readonly eventCounts: EventCounts; + readonly timeOrigin: DOMHighResTimeStamp; clearMarks(name?: string): void; clearMeasures(name?: string): void; @@ -284,7 +284,7 @@ declare class FormData { } declare class DOMRectReadOnly { - +bottom: number; + readonly bottom: number; constructor(x: number, y: number, width: number, height: number): void; static fromRect(rectangle?: { height: number, @@ -293,13 +293,13 @@ declare class DOMRectReadOnly { y: number, ... }): DOMRectReadOnly; - +height: number; - +left: number; - +right: number; - +top: number; - +width: number; - +x: number; - +y: number; + readonly height: number; + readonly left: number; + readonly right: number; + readonly top: number; + readonly width: number; + readonly x: number; + readonly y: number; } declare class DOMRect extends DOMRectReadOnly { @@ -331,23 +331,23 @@ declare class MutationRecord { // Always an empty NodeList for `attributes` and `characterData` mutations. // React Native currently only supports `childList`, so this contains the // added nodes for that mutation type. - +addedNodes: NodeList; + readonly addedNodes: NodeList; // Always `null` in React Native (only `childList` mutations are supported). - +attributeName: null; + readonly attributeName: null; // Always `null` in React Native (only `childList` mutations are supported). - +nextSibling: null; + readonly nextSibling: null; // Always `null` in React Native (only `childList` mutations are supported, // and `attributeOldValue`/`characterDataOldValue` are not supported). - +oldValue: null; + readonly oldValue: null; // Always `null` in React Native (only `childList` mutations are supported). - +previousSibling: null; + readonly previousSibling: null; // Always an empty NodeList for `attributes` and `characterData` mutations. // React Native currently only supports `childList`, so this contains the // removed nodes for that mutation type. - +removedNodes: NodeList; - +target: Node; + readonly removedNodes: NodeList; + readonly target: Node; // React Native currently only supports `childList` mutations. - +type: 'childList'; + readonly type: 'childList'; } // React Native currently only supports `childList` mutations, so `childList` @@ -355,8 +355,8 @@ declare class MutationRecord { // `attributeOldValue`/`characterData`/`characterDataOldValue` options are not // supported and will throw if provided. declare type MutationObserverInit = { - +childList: true, - +subtree?: boolean, + readonly childList: true, + readonly subtree?: boolean, ... }; @@ -372,17 +372,17 @@ declare class MutationObserver { } declare type IntersectionObserverEntry = { - +boundingClientRect: DOMRectReadOnly, - +intersectionRatio: number, - +intersectionRect: DOMRectReadOnly, - +isIntersecting: boolean, + readonly boundingClientRect: DOMRectReadOnly, + readonly intersectionRatio: number, + readonly intersectionRect: DOMRectReadOnly, + readonly isIntersecting: boolean, // Always non-null in React Native. - +rootBounds: DOMRectReadOnly, + readonly rootBounds: DOMRectReadOnly, // React Native-specific extension. Equivalent to `intersectionRatio` but // computed against the `rnRootThreshold` root-relative thresholds. - +rnRootIntersectionRatio: number, - +target: Element, - +time: DOMHighResTimeStamp, + readonly rnRootIntersectionRatio: number, + readonly target: Element, + readonly time: DOMHighResTimeStamp, ... }; @@ -410,12 +410,12 @@ declare class IntersectionObserver { ): void; disconnect(): void; observe(target: Element): void; - +root: Element | null; - +rootMargin: string; + readonly root: Element | null; + readonly rootMargin: string; // React Native-specific extension. The thresholds expressed as a fraction of // the root's size (set via the `rnRootThreshold` option). - +rnRootThresholds: ReadonlyArray | null; - +thresholds: ReadonlyArray; + readonly rnRootThresholds: ReadonlyArray | null; + readonly thresholds: ReadonlyArray; unobserve(target: Element): void; } @@ -689,7 +689,7 @@ declare class Request { referrer: string; referrerPolicy: ReferrerPolicyType; - +signal: AbortSignal; + readonly signal: AbortSignal; text(): Promise; url: string; } @@ -697,15 +697,15 @@ declare class Request { declare class AbortController { abort(reason?: $FlowFixMe): void; constructor(): void; - +signal: AbortSignal; + readonly signal: AbortSignal; } declare class AbortSignal extends EventTarget { static abort(reason?: $FlowFixMe): AbortSignal; static any(signals: Iterable): AbortSignal; - +aborted: boolean; + readonly aborted: boolean; onabort: (event: Event) => unknown; - +reason: $FlowFixMe; + readonly reason: $FlowFixMe; throwIfAborted(): void; static timeout(time: number): AbortSignal; } @@ -741,8 +741,8 @@ declare type FileSystemHandleKind = 'file' | 'directory'; // https://wicg.github.io/file-system-access/#api-filesystemhandle declare class FileSystemHandle { - +kind: FileSystemHandleKind; - +name: string; + readonly kind: FileSystemHandleKind; + readonly name: string; isSameEntry: (other: FileSystemHandle) => Promise; queryPermission?: ( @@ -755,7 +755,7 @@ declare class FileSystemHandle { // https://fs.spec.whatwg.org/#api-filesystemfilehandle declare class FileSystemFileHandle extends FileSystemHandle { - +kind: 'file'; + readonly kind: 'file'; constructor(name: string): void; @@ -768,7 +768,7 @@ declare class FileSystemFileHandle extends FileSystemHandle { // https://fs.spec.whatwg.org/#api-filesystemdirectoryhandle declare class FileSystemDirectoryHandle extends FileSystemHandle { - +kind: 'directory'; + readonly kind: 'directory'; constructor(name: string): void; diff --git a/packages/react-native/flow/cssom.js.flow b/packages/react-native/flow/cssom.js.flow index af1bd371362e..50bd5c15deac 100644 --- a/packages/react-native/flow/cssom.js.flow +++ b/packages/react-native/flow/cssom.js.flow @@ -10,12 +10,12 @@ declare class StyleSheet { disabled: boolean; - +href: string; - +media: MediaList; - +ownerNode: Node; - +parentStyleSheet: ?StyleSheet; - +title: string; - +type: string; + readonly href: string; + readonly media: MediaList; + readonly ownerNode: Node; + readonly parentStyleSheet: ?StyleSheet; + readonly title: string; + readonly type: string; } declare class StyleSheetList { @@ -35,10 +35,10 @@ declare class MediaList { } declare class CSSStyleSheet extends StyleSheet { - +cssRules: CSSRuleList; + readonly cssRules: CSSRuleList; deleteRule(index: number): void; insertRule(rule: string, index: number): number; - +ownerRule: ?CSSRule; + readonly ownerRule: ?CSSRule; replace(text: string): Promise; replaceSync(text: string): void; } @@ -56,24 +56,24 @@ declare class CSSRule { static MEDIA_RULE: number; static NAMESPACE_RULE: number; static PAGE_RULE: number; - +parentRule: ?CSSRule; - +parentStyleSheet: ?CSSStyleSheet; + readonly parentRule: ?CSSRule; + readonly parentStyleSheet: ?CSSStyleSheet; static REGION_STYLE_RULE: number; static STYLE_RULE: number; static SUPPORTS_RULE: number; - +type: number; + readonly type: number; static UNKNOWN_RULE: number; static VIEWPORT_RULE: number; } declare class CSSKeyframeRule extends CSSRule { keyText: string; - +style: CSSStyleDeclaration; + readonly style: CSSStyleDeclaration; } declare class CSSKeyframesRule extends CSSRule { appendRule(rule: string): void; - +cssRules: CSSRuleList; + readonly cssRules: CSSRuleList; deleteRule(select: string): void; findRule(select: string): CSSKeyframeRule | null; name: string; @@ -418,7 +418,7 @@ type CompositeOperation = 'replace' | 'add' | 'accumulate'; type CompositeOperationOrAuto = CompositeOperation | 'auto'; declare class AnimationTimeline { - +currentTime: number | null; + readonly currentTime: number | null; } type DocumentTimelineOptions = { @@ -522,19 +522,19 @@ declare class Animation extends EventTarget { currentTime: number | null; effect: AnimationEffect | null; finish(): void; - +finished: Promise; + readonly finished: Promise; id: string; oncancel: ?(ev: AnimationPlaybackEvent) => unknown; onfinish: ?(ev: AnimationPlaybackEvent) => unknown; onremove: ?(ev: AnimationPlaybackEvent) => unknown; pause(): void; - +pending: boolean; + readonly pending: boolean; persist(): void; play(): void; playbackRate: number; - +playState: AnimationPlayState; - +ready: Promise; - +replaceState: AnimationReplaceState; + readonly playState: AnimationPlayState; + readonly ready: Promise; + readonly replaceState: AnimationReplaceState; reverse(): void; startTime: number | null; timeline: AnimationTimeline | null; @@ -570,6 +570,6 @@ declare class AnimationPlaybackEvent extends Event { type: string, animationEventInitDict?: AnimationPlaybackEvent$Init, ): void; - +currentTime: number | null; - +timelineTime: number | null; + readonly currentTime: number | null; + readonly timelineTime: number | null; } diff --git a/packages/react-native/flow/dom.js.flow b/packages/react-native/flow/dom.js.flow index 678d6b52e8a9..55e96b385ebd 100644 --- a/packages/react-native/flow/dom.js.flow +++ b/packages/react-native/flow/dom.js.flow @@ -32,12 +32,12 @@ declare class Blob { } declare class FileReader extends EventTarget { - +EMPTY: 0; - +LOADING: 1; - +DONE: 2; - +error: null | DOMError; - +readyState: 0 | 1 | 2; - +result: null | string | ArrayBuffer; + readonly EMPTY: 0; + readonly LOADING: 1; + readonly DONE: 2; + readonly error: null | DOMError; + readonly readyState: 0 | 1 | 2; + readonly result: null | string | ArrayBuffer; abort(): void; onabort: null | ((ev: ProgressEvent) => any); onerror: null | ((ev: ProgressEvent) => any); @@ -117,8 +117,8 @@ declare type DOMStringMap = {[key: string]: string, ...}; declare class DOMStringList { @@iterator(): Iterator; - +[key: number]: string; - +length: number; + readonly [key: number]: string; + readonly length: number; item(number): string | null; contains(string): boolean; } @@ -140,16 +140,16 @@ declare interface CustomElementRegistry { } declare interface ShadowRoot extends DocumentFragment { - +delegatesFocus: boolean; - +host: Element; + readonly delegatesFocus: boolean; + readonly host: Element; // flowlint unsafe-getters-setters:off get innerHTML(): string; set innerHTML(value: string | TrustedHTML): void; // flowlint unsafe-getters-setters:error - +mode: ShadowRootMode; + readonly mode: ShadowRootMode; // From DocumentOrShadowRoot Mixin. - +styleSheets: StyleSheetList; + readonly styleSheets: StyleSheetList; adoptedStyleSheets: Array; } @@ -650,17 +650,17 @@ declare class Event { /** * Returns the type of event, e.g. "click", "hashchange", or "submit". */ - +type: string; + readonly type: string; /** * Returns the object to which event is dispatched (its target). */ - +target: EventTarget; // TODO: nullable + readonly target: EventTarget; // TODO: nullable /** @deprecated */ - +srcElement: Element; // TODO: nullable + readonly srcElement: Element; // TODO: nullable /** * Returns the object whose event listener's callback is currently being invoked. */ - +currentTarget: EventTarget; // TODO: nullable + readonly currentTarget: EventTarget; // TODO: nullable /** * Returns the invocation target objects of event's path (objects on which * listeners will be invoked), except for any nodes in shadow trees of which @@ -669,15 +669,15 @@ declare class Event { */ composedPath(): Array; - +NONE: number; - +AT_TARGET: number; - +BUBBLING_PHASE: number; - +CAPTURING_PHASE: number; + readonly NONE: number; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; /** * Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, * and BUBBLING_PHASE. */ - +eventPhase: number; + readonly eventPhase: number; /** * When dispatched in a tree, invoking this method prevents event from reaching @@ -696,14 +696,14 @@ declare class Event { * event goes through its target's ancestors in reverse tree order, and * false otherwise. */ - +bubbles: boolean; + readonly bubbles: boolean; /** * Returns true or false depending on how event was initialized. Its * return value does not always carry meaning, but true can indicate * that part of the operation during which event was dispatched, can * be canceled by invoking the preventDefault() method. */ - +cancelable: boolean; + readonly cancelable: boolean; // returnValue: boolean; // legacy, and some subclasses still define it as a string! /** * If invoked when the cancelable attribute value is true, and while @@ -716,28 +716,28 @@ declare class Event { * Returns true if preventDefault() was invoked successfully to indicate * cancelation, and false otherwise. */ - +defaultPrevented: boolean; + readonly defaultPrevented: boolean; /** * Returns true or false depending on how event was initialized. True if * event invokes listeners past a ShadowRoot node that is the root of its * target, and false otherwise. */ - +composed: boolean; + readonly composed: boolean; /** * Returns true if event was dispatched by the user agent, and false otherwise. */ - +isTrusted: boolean; + readonly isTrusted: boolean; /** * Returns the event's timestamp as the number of milliseconds measured relative * to the time origin. */ - +timeStamp: number; + readonly timeStamp: number; /** Non-standard. See Event.prototype.composedPath */ - +deepPath?: () => EventTarget[]; + readonly deepPath?: () => EventTarget[]; /** Non-standard. See Event.prototype.composed */ - +scoped: boolean; + readonly scoped: boolean; /** * @deprecated @@ -831,15 +831,15 @@ type WheelEvent$Init = { }; declare class WheelEvent extends MouseEvent { - static +DOM_DELTA_PIXEL: 0x00; - static +DOM_DELTA_LINE: 0x01; - static +DOM_DELTA_PAGE: 0x02; + static readonly DOM_DELTA_PIXEL: 0x00; + static readonly DOM_DELTA_LINE: 0x01; + static readonly DOM_DELTA_PAGE: 0x02; constructor(type: string, eventInitDict?: WheelEvent$Init): void; - +deltaX: number; - +deltaY: number; - +deltaZ: number; - +deltaMode: 0x00 | 0x01 | 0x02; + readonly deltaX: number; + readonly deltaY: number; + readonly deltaZ: number; + readonly deltaMode: 0x00 | 0x01 | 0x02; } declare class DragEvent extends MouseEvent { @@ -907,7 +907,7 @@ type PageTransitionEventInit = { // https://html.spec.whatwg.org/multipage/browsing-the-web.html#the-pagetransitionevent-interface declare class PageTransitionEvent extends Event { constructor(type: string, init?: PageTransitionEventInit): void; - +persisted: boolean; + readonly persisted: boolean; } // used for websockets and postMessage, for example. See: @@ -929,12 +929,12 @@ declare class EventSource extends EventTarget { url: string, configuration?: {withCredentials: boolean, ...}, ): void; - +CLOSED: 2; - +CONNECTING: 0; - +OPEN: 1; - +readyState: 0 | 1 | 2; - +url: string; - +withCredentials: boolean; + readonly CLOSED: 2; + readonly CONNECTING: 0; + readonly OPEN: 1; + readonly readyState: 0 | 1 | 2; + readonly url: string; + readonly withCredentials: boolean; onerror: () => void; onmessage: MessageEventListener; onopen: () => void; @@ -1028,33 +1028,33 @@ declare class KeyboardEvent extends UIEvent { constructor(typeArg: string, init?: KeyboardEvent$Init): void; /** `true` if the Alt (alternative) (or "Option") key modifier was active. */ - +altKey: boolean; + readonly altKey: boolean; /** * Holds a string that identifies the physical key being pressed. The value * is not affected by the current keyboard layout or modifier state, so a * particular key will always return the same value. */ - +code: string; + readonly code: string; /** `true` if the Control (control) key modifier was active. */ - +ctrlKey: boolean; + readonly ctrlKey: boolean; /** * `true` if the key event occurs as part of a composition session, i.e., * after a `compositionstart` event and before the corresponding * `compositionend` event. */ - +isComposing: boolean; + readonly isComposing: boolean; /** * Holds a [key attribute value](https://www.w3.org/TR/uievents-key/#key-attribute-value) * corresponding to the key pressed. */ - +key: string; + readonly key: string; /** An indication of the logical location of the key on the device. */ - +location: number; + readonly location: number; /** `true` if the meta (Meta) key (or "Command") modifier was active. */ - +metaKey: boolean; + readonly metaKey: boolean; /** `true` if the key has been pressed in a sustained manner. */ - +repeat: boolean; + readonly repeat: boolean; /** `true` if the shift (Shift) key modifier was active. */ - +shiftKey: boolean; + readonly shiftKey: boolean; /** * Queries the state of a modifier using a key value. @@ -1072,7 +1072,7 @@ declare class KeyboardEvent extends UIEvent { * * @deprecated You should use KeyboardEvent.key instead, if available. */ - +charCode: number; + readonly charCode: number; /** * Holds a system- and implementation-dependent numerical code signifying * the unmodified identifier associated with the key pressed. Unlike the @@ -1084,7 +1084,7 @@ declare class KeyboardEvent extends UIEvent { * * @deprecated You should use KeyboardEvent.key instead, if available. */ - +keyCode: number; + readonly keyCode: number; /** * Holds a system- and implementation-dependent numerical code signifying * the unmodified identifier associated with the key pressed. In most cases, @@ -1092,7 +1092,7 @@ declare class KeyboardEvent extends UIEvent { * * @deprecated You should use KeyboardEvent.key instead, if available. */ - +which: number; + readonly which: number; } type InputEvent$Init = { @@ -1107,10 +1107,10 @@ type InputEvent$Init = { declare class InputEvent extends UIEvent { constructor(typeArg: string, inputEventInit: InputEvent$Init): void; - +data: string | null; - +dataTransfer: DataTransfer | null; - +inputType: string; - +isComposing: boolean; + readonly data: string | null; + readonly dataTransfer: DataTransfer | null; + readonly inputType: string; + readonly isComposing: boolean; getTargetRanges(): Array; // TODO: StaticRange } @@ -1144,11 +1144,11 @@ declare class ErrorEvent extends Event { ... }, ): void; - +message: string; - +filename: string; - +lineno: number; - +colno: number; - +error: any; + readonly message: string; + readonly filename: string; + readonly lineno: number; + readonly colno: number; + readonly error: any; } // https://html.spec.whatwg.org/multipage/web-messaging.html#broadcasting-to-other-browsing-contexts @@ -1216,7 +1216,7 @@ type ClipboardItemOptions = { }; declare class ClipboardItem { - +types: ReadonlyArray; + readonly types: ReadonlyArray; getType(type: string): Promise; constructor( items: {[type: string]: ClipboardItemData}, @@ -1233,7 +1233,7 @@ type ClipboardEvent$Init = { declare class ClipboardEvent extends Event { constructor(type: ClipboardEventTypes, eventInit?: ClipboardEvent$Init): void; - +clipboardData: ?DataTransfer; // readonly + readonly clipboardData: ?DataTransfer; // readonly } // https://www.w3.org/TR/2017/WD-css-transitions-1-20171130/#interface-transitionevent @@ -1252,9 +1252,9 @@ declare class TransitionEvent extends Event { eventInit?: TransitionEvent$Init, ): void; - +propertyName: string; // readonly - +elapsedTime: number; // readonly - +pseudoElement: string; // readonly + readonly propertyName: string; // readonly + readonly elapsedTime: number; // readonly + readonly pseudoElement: string; // readonly } // https://www.w3.org/TR/html50/browsers.html#beforeunloadevent @@ -1263,18 +1263,18 @@ declare class BeforeUnloadEvent extends Event { } declare class SecurityPolicyViolationEvent extends Event { - +documentURI: string; - +referrer: string; - +blockedURI: string; - +effectiveDirective: string; - +violatedDirective: string; - +originalPolicy: string; - +sourceFile: string; - +sample: string; - +disposition: 'enforce' | 'report'; - +statusCode: number; - +lineNumber: number; - +columnNumber: number; + readonly documentURI: string; + readonly referrer: string; + readonly blockedURI: string; + readonly effectiveDirective: string; + readonly violatedDirective: string; + readonly originalPolicy: string; + readonly sourceFile: string; + readonly sample: string; + readonly disposition: 'enforce' | 'report'; + readonly statusCode: number; + readonly lineNumber: number; + readonly columnNumber: number; } // https://developer.mozilla.org/en-US/docs/Web/API/USBConnectionEvent @@ -1288,7 +1288,7 @@ declare class Node extends EventTarget { baseURI: ?string; childNodes: NodeList; firstChild: ?Node; - +isConnected: boolean; + readonly isConnected: boolean; lastChild: ?Node; nextSibling: ?Node; nodeName: string; @@ -1391,13 +1391,13 @@ declare class HTMLCollection { // from https://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-register // See also https://github.com/w3c/webcomponents/ type ElementRegistrationOptions = { - +prototype?: { + readonly prototype?: { // from https://www.w3.org/TR/custom-elements/#types-of-callbacks // See also https://github.com/w3c/webcomponents/ - +createdCallback?: () => unknown, - +attachedCallback?: () => unknown, - +detachedCallback?: () => unknown, - +attributeChangedCallback?: (( + readonly createdCallback?: () => unknown, + readonly attachedCallback?: () => unknown, + readonly detachedCallback?: () => unknown, + readonly attributeChangedCallback?: (( // attribute is set attributeLocalName: string, oldAttributeValue: null, @@ -1420,28 +1420,28 @@ type ElementRegistrationOptions = { ) => unknown), ... }, - +extends?: string, + readonly extends?: string, ... }; type ElementCreationOptions = {is: string, ...}; declare class Document extends Node { - +timeline: DocumentTimeline; + readonly timeline: DocumentTimeline; getAnimations(): Array; - +URL: string; + readonly URL: string; adoptNode(source: T): T; anchors: HTMLCollection; applets: HTMLCollection; body: HTMLBodyElement | null; - +characterSet: string; + readonly characterSet: string; /** * Legacy alias of `characterSet` * @deprecated */ - +charset: string; + readonly charset: string; close(): void; - +contentType: string; + readonly contentType: string; cookie: string; createAttribute(name: string): Attr; createAttributeNS(namespaceURI: string | null, qualifiedName: string): Attr; @@ -1696,10 +1696,10 @@ declare class Document extends Node { createTextNode(data: string): Text; currentScript: HTMLScriptElement | null; dir: 'rtl' | 'ltr'; - +doctype: DocumentType | null; - +documentElement: HTMLElement | null; + readonly doctype: DocumentType | null; + readonly documentElement: HTMLElement | null; documentMode: number; - +documentURI: string; + readonly documentURI: string; domain: string | null; embeds: HTMLCollection; exitFullscreen(): Promise; @@ -2033,13 +2033,13 @@ declare class Document extends Node { ): HTMLCollection; head: HTMLHeadElement | null; images: HTMLCollection; - +implementation: DOMImplementation; + readonly implementation: DOMImplementation; importNode(importedNode: T, deep: boolean): T; /** * Legacy alias of `characterSet` * @deprecated */ - +inputEncoding: string; + readonly inputEncoding: string; lastModified: string; links: HTMLCollection; media: string; @@ -2071,7 +2071,7 @@ declare class Document extends Node { elementFromPoint(x: number, y: number): HTMLElement | null; elementsFromPoint(x: number, y: number): Array; defaultView: any; - +compatMode: 'BackCompat' | 'CSS1Compat'; + readonly compatMode: 'BackCompat' | 'CSS1Compat'; hidden: boolean; // Pointer Lock specification @@ -2712,7 +2712,7 @@ declare class Document extends Node { getElementById(elementId: string): HTMLElement | null; // From DocumentOrShadowRoot Mixin. - +styleSheets: StyleSheetList; + readonly styleSheets: StyleSheetList; adoptedStyleSheets: Array; } @@ -2857,7 +2857,7 @@ declare class Element extends Node implements Animatable { scrollLeft: number; scrollTop: number; scrollWidth: number; - +tagName: string; + readonly tagName: string; // TODO: a lot more ARIA properties ariaHidden: void | 'true' | 'false'; @@ -3466,8 +3466,8 @@ declare class HTMLTableElement extends HTMLElement { caption: HTMLTableCaptionElement | null; tHead: HTMLTableSectionElement | null; tFoot: HTMLTableSectionElement | null; - +tBodies: HTMLCollection; - +rows: HTMLCollection; + readonly tBodies: HTMLCollection; + readonly rows: HTMLCollection; createTHead(): HTMLTableSectionElement; deleteTHead(): void; createTFoot(): HTMLTableSectionElement; @@ -3489,7 +3489,7 @@ declare class HTMLTableColElement extends HTMLElement { declare class HTMLTableSectionElement extends HTMLElement { tagName: 'THEAD' | 'TFOOT' | 'TBODY'; - +rows: HTMLCollection; + readonly rows: HTMLCollection; insertRow(index?: number): HTMLTableRowElement; deleteRow(index: number): void; } @@ -3498,15 +3498,15 @@ declare class HTMLTableCellElement extends HTMLElement { tagName: 'TD' | 'TH'; colSpan: number; rowSpan: number; - +cellIndex: number; + readonly cellIndex: number; } declare class HTMLTableRowElement extends HTMLElement { tagName: 'TR'; align: 'left' | 'right' | 'center'; - +rowIndex: number; - +sectionRowIndex: number; - +cells: HTMLCollection; + readonly rowIndex: number; + readonly sectionRowIndex: number; + readonly cells: HTMLCollection; deleteCell(index: number): void; insertCell(index?: number): HTMLTableCellElement; } @@ -5965,13 +5965,13 @@ declare class URL { host: string; hostname: string; href: string; - +origin: string; + readonly origin: string; password: string; pathname: string; port: string; protocol: string; search: string; - +searchParams: URLSearchParams; + readonly searchParams: URLSearchParams; username: string; toString(): string; toJSON(): string; @@ -6250,30 +6250,30 @@ type NotificationOptions = { declare class Notification extends EventTarget { constructor(title: string, options?: NotificationOptions): void; - static +permission: NotificationPermission; + static readonly permission: NotificationPermission; static requestPermission( callback?: (perm: NotificationPermission) => unknown, ): Promise; - static +maxActions: number; + static readonly maxActions: number; onclick: ?(evt: Event) => unknown; onclose: ?(evt: Event) => unknown; onerror: ?(evt: Event) => unknown; onshow: ?(evt: Event) => unknown; - +title: string; - +dir: NotificationDirection; - +lang: string; - +body: string; - +tag: string; - +image?: string; - +icon?: string; - +badge?: string; - +vibrate?: Array; - +timestamp: number; - +renotify: boolean; - +silent: boolean; - +requireInteraction: boolean; - +data: any; - +actions: Array; + readonly title: string; + readonly dir: NotificationDirection; + readonly lang: string; + readonly body: string; + readonly tag: string; + readonly image?: string; + readonly icon?: string; + readonly badge?: string; + readonly vibrate?: Array; + readonly timestamp: number; + readonly renotify: boolean; + readonly silent: boolean; + readonly requireInteraction: boolean; + readonly data: any; + readonly actions: Array; close(): void; } diff --git a/packages/react-native/src/private/animated/NativeAnimatedHelper.js b/packages/react-native/src/private/animated/NativeAnimatedHelper.js index fd8c8f56f436..f27650b3d327 100644 --- a/packages/react-native/src/private/animated/NativeAnimatedHelper.js +++ b/packages/react-native/src/private/animated/NativeAnimatedHelper.js @@ -32,7 +32,7 @@ import nullthrows from 'nullthrows'; interface NativeAnimatedModuleSpec extends NativeAnimatedTurboModuleSpec { // connectAnimatedNodeToShadowNodeFamily is available only in NativeAnimatedNonTurboModule - +connectAnimatedNodeToShadowNodeFamily?: ( + readonly connectAnimatedNodeToShadowNodeFamily?: ( nodeTag: number, // $FlowExpectedError[unclear-type]. shadowNode: Object, diff --git a/packages/react-native/src/private/components/virtualcollection/Virtual.js b/packages/react-native/src/private/components/virtualcollection/Virtual.js index b2556864f4a5..fbb4d5fc37a5 100644 --- a/packages/react-native/src/private/components/virtualcollection/Virtual.js +++ b/packages/react-native/src/private/components/virtualcollection/Virtual.js @@ -25,7 +25,7 @@ export interface VirtualCollection { * or a getter function that is computed on access. However, it should remain * constant for the lifetime of this object. */ - +size: number; + readonly size: number; /** * If an item exists at the supplied index, this should return a consistent @@ -41,8 +41,8 @@ export interface VirtualCollection { * array is eagerly allocated. */ export class VirtualArray implements VirtualCollection { - +size: number; - +at: (index: number) => T; + readonly size: number; + readonly at: (index: number) => T; constructor(input: Readonly<$ArrayLike>) { const array = [...input]; diff --git a/packages/react-native/src/private/devsupport/devmenu/elementinspector/Inspector.js b/packages/react-native/src/private/devsupport/devmenu/elementinspector/Inspector.js index e56629c32574..58ec505cad23 100644 --- a/packages/react-native/src/private/devsupport/devmenu/elementinspector/Inspector.js +++ b/packages/react-native/src/private/devsupport/devmenu/elementinspector/Inspector.js @@ -49,7 +49,9 @@ export type ElementsHierarchy = InspectorData['hierarchy']; type ExternalInspection = { externalInspectingEnabled: boolean, - +reportToExternalInspection: (viewData: TouchedViewDataAtPoint) => void, + readonly reportToExternalInspection: ( + viewData: TouchedViewDataAtPoint, + ) => void, }; type Props = { diff --git a/packages/react-native/src/private/devsupport/devmenu/specs/NativeDevMenu.js b/packages/react-native/src/private/devsupport/devmenu/specs/NativeDevMenu.js index 163855a1321a..d3d16e866198 100644 --- a/packages/react-native/src/private/devsupport/devmenu/specs/NativeDevMenu.js +++ b/packages/react-native/src/private/devsupport/devmenu/specs/NativeDevMenu.js @@ -13,10 +13,10 @@ import type {TurboModule} from '../../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +show: () => void; - +reload: () => void; - +setProfilingEnabled: (enabled: boolean) => void; - +setHotLoadingEnabled: (enabled: boolean) => void; + readonly show: () => void; + readonly reload: () => void; + readonly setProfilingEnabled: (enabled: boolean) => void; + readonly setHotLoadingEnabled: (enabled: boolean) => void; } export default TurboModuleRegistry.getEnforcing('DevMenu') as Spec; diff --git a/packages/react-native/src/private/devsupport/rndevtools/specs/NativeReactDevToolsRuntimeSettingsModule.js b/packages/react-native/src/private/devsupport/rndevtools/specs/NativeReactDevToolsRuntimeSettingsModule.js index 7a09b9cf0f2f..ebc1a0239d02 100644 --- a/packages/react-native/src/private/devsupport/rndevtools/specs/NativeReactDevToolsRuntimeSettingsModule.js +++ b/packages/react-native/src/private/devsupport/rndevtools/specs/NativeReactDevToolsRuntimeSettingsModule.js @@ -24,8 +24,10 @@ export type PartialReloadAndProfileConfig = { }; export interface Spec extends TurboModule { - +setReloadAndProfileConfig: (config: PartialReloadAndProfileConfig) => void; - +getReloadAndProfileConfig: () => ReloadAndProfileConfig; + readonly setReloadAndProfileConfig: ( + config: PartialReloadAndProfileConfig, + ) => void; + readonly getReloadAndProfileConfig: () => ReloadAndProfileConfig; } export default TurboModuleRegistry.get( diff --git a/packages/react-native/src/private/devsupport/rndevtools/specs/NativeReactDevToolsSettingsManager.js b/packages/react-native/src/private/devsupport/rndevtools/specs/NativeReactDevToolsSettingsManager.js index fc647e66a64a..028ace09c982 100644 --- a/packages/react-native/src/private/devsupport/rndevtools/specs/NativeReactDevToolsSettingsManager.js +++ b/packages/react-native/src/private/devsupport/rndevtools/specs/NativeReactDevToolsSettingsManager.js @@ -13,8 +13,8 @@ import type {TurboModule} from '../../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +setGlobalHookSettings: (settings: string) => void; - +getGlobalHookSettings: () => ?string; + readonly setGlobalHookSettings: (settings: string) => void; + readonly getGlobalHookSettings: () => ?string; } export default TurboModuleRegistry.get( diff --git a/packages/react-native/src/private/renderer/errorhandling/ErrorHandlers.js b/packages/react-native/src/private/renderer/errorhandling/ErrorHandlers.js index d722feb6039b..d8b54ed477cd 100644 --- a/packages/react-native/src/private/renderer/errorhandling/ErrorHandlers.js +++ b/packages/react-native/src/private/renderer/errorhandling/ErrorHandlers.js @@ -16,9 +16,9 @@ import ExceptionsManager, { import * as React from 'react'; type ErrorInfo = { - +componentStack?: ?string, + readonly componentStack?: ?string, // $FlowFixMe[unclear-type] unknown props and state. - +errorBoundary?: ?React.Component, + readonly errorBoundary?: ?React.Component, }; function getExtendedError( diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js index 6c935ae61dec..dc0f3eae0940 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js @@ -111,8 +111,8 @@ type AndroidDrawerLayoutNativeProps = Readonly<{ type NativeType = HostComponent; interface NativeCommands { - +openDrawer: (viewRef: React.ElementRef) => void; - +closeDrawer: (viewRef: React.ElementRef) => void; + readonly openDrawer: (viewRef: React.ElementRef) => void; + readonly closeDrawer: (viewRef: React.ElementRef) => void; } export const Commands: NativeCommands = codegenNativeCommands({ diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js index 7d2385c79781..da6309cc1f0a 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js @@ -59,7 +59,7 @@ type AndroidSwipeRefreshLayoutNativeProps = Readonly<{ type NativeType = HostComponent; interface NativeCommands { - +setNativeRefreshing: ( + readonly setNativeRefreshing: ( viewRef: React.ElementRef, value: boolean, ) => void; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js index 14bff1e74b4c..ccc16fdaba71 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js @@ -47,7 +47,7 @@ type AndroidSwitchNativeProps = Readonly<{ type NativeType = HostComponent; interface NativeCommands { - +setNativeValue: ( + readonly setNativeValue: ( viewRef: React.ElementRef, value: boolean, ) => void; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js index 924267092a0d..be635142f431 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js @@ -36,15 +36,15 @@ export type ElementRectangle = { }; interface NativeCommands { - +highlightTraceUpdates: ( + readonly highlightTraceUpdates: ( viewRef: React.ElementRef, updates: ReadonlyArray, ) => void; - +highlightElements: ( + readonly highlightElements: ( viewRef: React.ElementRef, elements: ReadonlyArray, ) => void; - +clearElementsHighlights: ( + readonly clearElementsHighlights: ( viewRef: React.ElementRef, ) => void; } diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js index 061717b08918..9024d7e34f29 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js @@ -55,7 +55,7 @@ type PullToRefreshNativeProps = Readonly<{ type ComponentType = HostComponent; interface NativeCommands { - +setNativeRefreshing: ( + readonly setNativeRefreshing: ( viewRef: React.ElementRef, refreshing: boolean, ) => void; diff --git a/packages/react-native/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js b/packages/react-native/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js index 6c6a2bcc2f04..6484c8e21f1a 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +++ b/packages/react-native/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js @@ -48,7 +48,10 @@ type SwitchNativeProps = Readonly<{ type ComponentType = HostComponent; interface NativeCommands { - +setValue: (viewRef: React.ElementRef, value: boolean) => void; + readonly setValue: ( + viewRef: React.ElementRef, + value: boolean, + ) => void; } export const Commands: NativeCommands = codegenNativeCommands({ diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAccessibilityInfo.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAccessibilityInfo.js index 8f566494188d..d17c50925e9f 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAccessibilityInfo.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAccessibilityInfo.js @@ -13,28 +13,28 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +isReduceMotionEnabled: ( + readonly isReduceMotionEnabled: ( onSuccess: (isReduceMotionEnabled: boolean) => void, ) => void; - +isInvertColorsEnabled?: ( + readonly isInvertColorsEnabled?: ( onSuccess: (isInvertColorsEnabled: boolean) => void, ) => void; - +isHighTextContrastEnabled?: ( + readonly isHighTextContrastEnabled?: ( onSuccess: (isHighTextContrastEnabled: boolean) => void, ) => void; - +isTouchExplorationEnabled: ( + readonly isTouchExplorationEnabled: ( onSuccess: (isScreenReaderEnabled: boolean) => void, ) => void; - +isAccessibilityServiceEnabled?: ?( + readonly isAccessibilityServiceEnabled?: ?( onSuccess: (isAccessibilityServiceEnabled: boolean) => void, ) => void; - +setAccessibilityFocus: (reactTag: number) => void; - +announceForAccessibility: (announcement: string) => void; - +getRecommendedTimeoutMillis?: ( + readonly setAccessibilityFocus: (reactTag: number) => void; + readonly announceForAccessibility: (announcement: string) => void; + readonly getRecommendedTimeoutMillis?: ( mSec: number, onSuccess: (recommendedTimeoutMillis: number) => void, ) => void; - +isGrayscaleEnabled?: ( + readonly isGrayscaleEnabled?: ( onSuccess: (isGrayscaleEnabled: boolean) => void, ) => void; } 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 cc1693d0a830..b54a36179a1b 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAccessibilityManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAccessibilityManager.js @@ -13,55 +13,55 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getCurrentBoldTextState: ( + readonly getCurrentBoldTextState: ( onSuccess: (isBoldTextEnabled: boolean) => void, onError: (error: Object) => void, ) => void; - +getCurrentGrayscaleState: ( + readonly getCurrentGrayscaleState: ( onSuccess: (isGrayscaleEnabled: boolean) => void, onError: (error: Object) => void, ) => void; - +getCurrentInvertColorsState: ( + readonly getCurrentInvertColorsState: ( onSuccess: (isInvertColorsEnabled: boolean) => void, onError: (error: Object) => void, ) => void; - +getCurrentReduceMotionState: ( + readonly getCurrentReduceMotionState: ( onSuccess: (isReduceMotionEnabled: boolean) => void, onError: (error: Object) => void, ) => void; - +getCurrentDarkerSystemColorsState?: ( + readonly getCurrentDarkerSystemColorsState?: ( onSuccess: (isDarkerSystemColorsEnabled: boolean) => void, onError: (error: Object) => void, ) => void; - +getCurrentPrefersCrossFadeTransitionsState?: ( + readonly getCurrentPrefersCrossFadeTransitionsState?: ( onSuccess: (prefersCrossFadeTransitions: boolean) => void, onError: (error: Object) => void, ) => void; - +getCurrentReduceTransparencyState: ( + readonly getCurrentReduceTransparencyState: ( onSuccess: (isReduceTransparencyEnabled: boolean) => void, onError: (error: Object) => void, ) => void; - +getCurrentVoiceOverState: ( + readonly getCurrentVoiceOverState: ( onSuccess: (isScreenReaderEnabled: boolean) => void, onError: (error: Object) => void, ) => void; - +setAccessibilityContentSizeMultipliers: (JSMultipliers: { - +extraSmall?: ?number, - +small?: ?number, - +medium?: ?number, - +large?: ?number, - +extraLarge?: ?number, - +extraExtraLarge?: ?number, - +extraExtraExtraLarge?: ?number, - +accessibilityMedium?: ?number, - +accessibilityLarge?: ?number, - +accessibilityExtraLarge?: ?number, - +accessibilityExtraExtraLarge?: ?number, - +accessibilityExtraExtraExtraLarge?: ?number, + readonly setAccessibilityContentSizeMultipliers: (JSMultipliers: { + readonly extraSmall?: ?number, + readonly small?: ?number, + readonly medium?: ?number, + readonly large?: ?number, + readonly extraLarge?: ?number, + readonly extraExtraLarge?: ?number, + readonly extraExtraExtraLarge?: ?number, + readonly accessibilityMedium?: ?number, + readonly accessibilityLarge?: ?number, + readonly accessibilityExtraLarge?: ?number, + readonly accessibilityExtraExtraLarge?: ?number, + readonly accessibilityExtraExtraExtraLarge?: ?number, }) => void; - +setAccessibilityFocus: (reactTag: number) => void; - +announceForAccessibility: (announcement: string) => void; - +announceForAccessibilityWithOptions?: ( + readonly setAccessibilityFocus: (reactTag: number) => void; + readonly announceForAccessibility: (announcement: string) => void; + readonly announceForAccessibilityWithOptions?: ( announcement: string, options: {queue?: boolean, priority?: 'low' | 'default' | 'high'}, ) => void; 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 4177737cc53e..b4017988a264 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeActionSheetManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeActionSheetManager.js @@ -13,44 +13,44 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => {}; - +showActionSheetWithOptions: ( + readonly getConstants: () => {}; + readonly showActionSheetWithOptions: ( options: { - +title?: ?string, - +message?: ?string, - +options: ?Array, - +destructiveButtonIndices?: ?Array, - +cancelButtonIndex?: ?number, - +anchor?: ?number, - +tintColor?: ?number, - +cancelButtonTintColor?: ?number, - +disabledButtonTintColor?: ?number, - +userInterfaceStyle?: ?string, - +disabledButtonIndices?: Array, + readonly title?: ?string, + readonly message?: ?string, + readonly options: ?Array, + readonly destructiveButtonIndices?: ?Array, + readonly cancelButtonIndex?: ?number, + readonly anchor?: ?number, + readonly tintColor?: ?number, + readonly cancelButtonTintColor?: ?number, + readonly disabledButtonTintColor?: ?number, + readonly userInterfaceStyle?: ?string, + readonly disabledButtonIndices?: Array, }, callback: (buttonIndex: number) => void, ) => void; - +showShareActionSheetWithOptions: ( + readonly showShareActionSheetWithOptions: ( options: { - +message?: ?string, - +url?: ?string, - +subject?: ?string, - +anchor?: ?number, - +tintColor?: ?number, - +cancelButtonTintColor?: ?number, - +disabledButtonTintColor?: ?number, - +excludedActivityTypes?: ?Array, - +userInterfaceStyle?: ?string, + readonly message?: ?string, + readonly url?: ?string, + readonly subject?: ?string, + readonly anchor?: ?number, + readonly tintColor?: ?number, + readonly cancelButtonTintColor?: ?number, + readonly disabledButtonTintColor?: ?number, + readonly excludedActivityTypes?: ?Array, + readonly userInterfaceStyle?: ?string, }, failureCallback: (error: { - +domain: string, - +code: string, - +userInfo?: ?Object, - +message: string, + readonly domain: string, + readonly code: string, + readonly userInfo?: ?Object, + readonly message: string, }) => void, successCallback: (completed: boolean, activityType: ?string) => void, ) => void; - +dismissActionSheet?: () => void; + readonly dismissActionSheet?: () => void; } export default TurboModuleRegistry.get('ActionSheetManager') as ?Spec; 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 43510a83c4ab..603984af224d 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAlertManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAlertManager.js @@ -26,7 +26,7 @@ export type Args = { }; export interface Spec extends TurboModule { - +alertWithArgs: ( + readonly alertWithArgs: ( args: Args, callback: (id: number, value: string) => void, ) => void; 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 f71e7f9dcf5c..ea72f860bbd3 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js @@ -28,51 +28,71 @@ export type AnimatedNodeConfig = Object; export type AnimatingNodeConfig = Object; export interface Spec extends TurboModule { - +startOperationBatch: () => void; - +finishOperationBatch: () => void; - +createAnimatedNode: (tag: number, config: AnimatedNodeConfig) => void; - +updateAnimatedNodeConfig?: (tag: number, config: AnimatedNodeConfig) => void; - +getValue: (tag: number, saveValueCallback: SaveValueCallback) => void; - +startListeningToAnimatedNodeValue: (tag: number) => void; - +stopListeningToAnimatedNodeValue: (tag: number) => void; - +connectAnimatedNodes: (parentTag: number, childTag: number) => void; - +disconnectAnimatedNodes: (parentTag: number, childTag: number) => void; - +startAnimatingNode: ( + readonly startOperationBatch: () => void; + readonly finishOperationBatch: () => void; + readonly createAnimatedNode: ( + tag: number, + config: AnimatedNodeConfig, + ) => void; + readonly updateAnimatedNodeConfig?: ( + tag: number, + config: AnimatedNodeConfig, + ) => void; + readonly getValue: ( + tag: number, + saveValueCallback: SaveValueCallback, + ) => void; + readonly startListeningToAnimatedNodeValue: (tag: number) => void; + readonly stopListeningToAnimatedNodeValue: (tag: number) => void; + readonly connectAnimatedNodes: (parentTag: number, childTag: number) => void; + readonly disconnectAnimatedNodes: ( + parentTag: number, + childTag: number, + ) => void; + readonly startAnimatingNode: ( animationId: number, nodeTag: number, config: AnimatingNodeConfig, endCallback: EndCallback, ) => void; - +stopAnimation: (animationId: number) => void; - +setAnimatedNodeValue: (nodeTag: number, value: number) => void; - +setAnimatedNodeOffset: (nodeTag: number, offset: number) => void; - +flattenAnimatedNodeOffset: (nodeTag: number) => void; - +extractAnimatedNodeOffset: (nodeTag: number) => void; - +connectAnimatedNodeToView: (nodeTag: number, viewTag: number) => void; - +connectAnimatedNodeToShadowNodeFamily?: ( + readonly stopAnimation: (animationId: number) => void; + readonly setAnimatedNodeValue: (nodeTag: number, value: number) => void; + readonly setAnimatedNodeOffset: (nodeTag: number, offset: number) => void; + readonly flattenAnimatedNodeOffset: (nodeTag: number) => void; + readonly extractAnimatedNodeOffset: (nodeTag: number) => void; + readonly connectAnimatedNodeToView: ( + nodeTag: number, + viewTag: number, + ) => void; + readonly connectAnimatedNodeToShadowNodeFamily?: ( nodeTag: number, shadowNode: Object, ) => void; - +disconnectAnimatedNodeFromView: (nodeTag: number, viewTag: number) => void; - +restoreDefaultValues: (nodeTag: number) => void; - +dropAnimatedNode: (tag: number) => void; - +addAnimatedEventToView: ( + readonly disconnectAnimatedNodeFromView: ( + nodeTag: number, + viewTag: number, + ) => void; + readonly restoreDefaultValues: (nodeTag: number) => void; + readonly dropAnimatedNode: (tag: number) => void; + readonly addAnimatedEventToView: ( viewTag: number, eventName: string, eventMapping: EventMapping, ) => void; - +removeAnimatedEventFromView: ( + readonly removeAnimatedEventFromView: ( viewTag: number, eventName: string, animatedNodeTag: number, ) => void; // Events - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; // All of the above in a batched mode - +queueAndExecuteBatchedOperations?: (operationsAndArgs: Array) => void; + readonly queueAndExecuteBatchedOperations?: ( + operationsAndArgs: Array, + ) => void; } const NativeModule: ?Spec = !shouldUseTurboAnimatedModule() 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 5a20ac1539de..f634843ce3b4 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedTurboModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAnimatedTurboModule.js @@ -28,47 +28,67 @@ export type AnimatedNodeConfig = Object; export type AnimatingNodeConfig = Object; export interface Spec extends TurboModule { - +startOperationBatch: () => void; - +finishOperationBatch: () => void; - +createAnimatedNode: (tag: number, config: AnimatedNodeConfig) => void; - +updateAnimatedNodeConfig?: (tag: number, config: AnimatedNodeConfig) => void; - +getValue: (tag: number, saveValueCallback: SaveValueCallback) => void; - +startListeningToAnimatedNodeValue: (tag: number) => void; - +stopListeningToAnimatedNodeValue: (tag: number) => void; - +connectAnimatedNodes: (parentTag: number, childTag: number) => void; - +disconnectAnimatedNodes: (parentTag: number, childTag: number) => void; - +startAnimatingNode: ( + readonly startOperationBatch: () => void; + readonly finishOperationBatch: () => void; + readonly createAnimatedNode: ( + tag: number, + config: AnimatedNodeConfig, + ) => void; + readonly updateAnimatedNodeConfig?: ( + tag: number, + config: AnimatedNodeConfig, + ) => void; + readonly getValue: ( + tag: number, + saveValueCallback: SaveValueCallback, + ) => void; + readonly startListeningToAnimatedNodeValue: (tag: number) => void; + readonly stopListeningToAnimatedNodeValue: (tag: number) => void; + readonly connectAnimatedNodes: (parentTag: number, childTag: number) => void; + readonly disconnectAnimatedNodes: ( + parentTag: number, + childTag: number, + ) => void; + readonly startAnimatingNode: ( animationId: number, nodeTag: number, config: AnimatingNodeConfig, endCallback: EndCallback, ) => void; - +stopAnimation: (animationId: number) => void; - +setAnimatedNodeValue: (nodeTag: number, value: number) => void; - +setAnimatedNodeOffset: (nodeTag: number, offset: number) => void; - +flattenAnimatedNodeOffset: (nodeTag: number) => void; - +extractAnimatedNodeOffset: (nodeTag: number) => void; - +connectAnimatedNodeToView: (nodeTag: number, viewTag: number) => void; - +disconnectAnimatedNodeFromView: (nodeTag: number, viewTag: number) => void; - +restoreDefaultValues: (nodeTag: number) => void; - +dropAnimatedNode: (tag: number) => void; - +addAnimatedEventToView: ( + readonly stopAnimation: (animationId: number) => void; + readonly setAnimatedNodeValue: (nodeTag: number, value: number) => void; + readonly setAnimatedNodeOffset: (nodeTag: number, offset: number) => void; + readonly flattenAnimatedNodeOffset: (nodeTag: number) => void; + readonly extractAnimatedNodeOffset: (nodeTag: number) => void; + readonly connectAnimatedNodeToView: ( + nodeTag: number, + viewTag: number, + ) => void; + readonly disconnectAnimatedNodeFromView: ( + nodeTag: number, + viewTag: number, + ) => void; + readonly restoreDefaultValues: (nodeTag: number) => void; + readonly dropAnimatedNode: (tag: number) => void; + readonly addAnimatedEventToView: ( viewTag: number, eventName: string, eventMapping: EventMapping, ) => void; - +removeAnimatedEventFromView: ( + readonly removeAnimatedEventFromView: ( viewTag: number, eventName: string, animatedNodeTag: number, ) => void; // Events - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; // All of the above in a batched mode - +queueAndExecuteBatchedOperations?: (operationsAndArgs: Array) => void; + readonly queueAndExecuteBatchedOperations?: ( + operationsAndArgs: Array, + ) => void; } const NativeModule: ?Spec = shouldUseTurboAnimatedModule() 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 8e39fc4f4527..85f8159ea175 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAppState.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAppState.js @@ -19,15 +19,15 @@ export type AppStateConstants = { export type AppState = {app_state: string}; export interface Spec extends TurboModule { - +getConstants: () => AppStateConstants; - +getCurrentAppState: ( + readonly getConstants: () => AppStateConstants; + readonly getCurrentAppState: ( success: (appState: AppState) => void, error: (error: Object) => void, ) => void; // Events - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; } export default TurboModuleRegistry.getEnforcing('AppState') as Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAppearance.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAppearance.js index 24293ff900ae..2dc50b9171f2 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAppearance.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeAppearance.js @@ -21,12 +21,12 @@ export type AppearancePreferences = { }; export interface Spec extends TurboModule { - +getColorScheme: () => ColorSchemeName; - +setColorScheme: (colorScheme: ColorSchemeOverride) => void; + readonly getColorScheme: () => ColorSchemeName; + readonly setColorScheme: (colorScheme: ColorSchemeOverride) => void; // RCTEventEmitter - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; } export default TurboModuleRegistry.get('Appearance') as ?Spec; 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 6fc6cb1a349c..929a1cf098d2 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeBlobModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeBlobModule.js @@ -15,13 +15,13 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod export type Constants = {BLOB_URI_SCHEME: ?string, BLOB_URI_HOST: ?string}; export interface Spec extends TurboModule { - +getConstants: () => Constants; - +addNetworkingHandler: () => void; - +addWebSocketHandler: (id: number) => void; - +removeWebSocketHandler: (id: number) => void; - +sendOverSocket: (blob: Object, socketID: number) => void; - +createFromParts: (parts: Array, withId: string) => void; - +release: (blobId: string) => void; + readonly getConstants: () => Constants; + 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 release: (blobId: string) => void; } const NativeModule = TurboModuleRegistry.get('BlobModule'); diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeClipboard.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeClipboard.js index be7a5b71582f..952a0c5cba70 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeClipboard.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeClipboard.js @@ -13,9 +13,9 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => {}; - +getString: () => Promise; - +setString: (content: string) => void; + readonly getConstants: () => {}; + readonly getString: () => Promise; + readonly setString: (content: string) => void; } export default TurboModuleRegistry.getEnforcing('Clipboard') as Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDevLoadingView.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDevLoadingView.js index c33a8309e70b..809b2ad5dee8 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDevLoadingView.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDevLoadingView.js @@ -13,13 +13,13 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +showMessage: ( + readonly showMessage: ( message: string, withColor: ?number, withBackgroundColor: ?number, withDismissButton: ?boolean, ) => void; - +hide: () => void; + readonly hide: () => void; } export default TurboModuleRegistry.get('DevLoadingView') as ?Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDevSettings.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDevSettings.js index 6234049f72ff..4f351bb102d0 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDevSettings.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDevSettings.js @@ -13,21 +13,21 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +reload: () => void; - +reloadWithReason?: (reason: string) => void; - +onFastRefresh?: () => void; - +setHotLoadingEnabled: (isHotLoadingEnabled: boolean) => void; - +setProfilingEnabled: (isProfilingEnabled: boolean) => void; - +toggleElementInspector: () => void; - +addMenuItem: (title: string) => void; - +openDebugger?: () => void; + readonly reload: () => void; + readonly reloadWithReason?: (reason: string) => void; + readonly onFastRefresh?: () => void; + readonly setHotLoadingEnabled: (isHotLoadingEnabled: boolean) => void; + readonly setProfilingEnabled: (isProfilingEnabled: boolean) => void; + readonly toggleElementInspector: () => void; + readonly addMenuItem: (title: string) => void; + readonly openDebugger?: () => void; // Events - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; // iOS only. - +setIsShakeToShowDevMenuEnabled: (enabled: boolean) => void; + readonly setIsShakeToShowDevMenuEnabled: (enabled: boolean) => void; } export default TurboModuleRegistry.getEnforcing('DevSettings') as Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDeviceEventManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDeviceEventManager.js index dd498408d85c..4efff76e66a0 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDeviceEventManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDeviceEventManager.js @@ -13,7 +13,7 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +invokeDefaultBackPressHandler: () => void; + readonly invokeDefaultBackPressHandler: () => void; } export default TurboModuleRegistry.get('DeviceEventManager') as ?Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDeviceInfo.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDeviceInfo.js index 4ef344afe8ea..df2f70c62def 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDeviceInfo.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDeviceInfo.js @@ -35,13 +35,13 @@ export type DimensionsPayload = { }; export type DeviceInfoConstants = { - +Dimensions: DimensionsPayload, - +isEdgeToEdge?: boolean, - +isIPhoneX_deprecated?: boolean, + readonly Dimensions: DimensionsPayload, + readonly isEdgeToEdge?: boolean, + readonly isIPhoneX_deprecated?: boolean, }; export interface Spec extends TurboModule { - +getConstants: () => DeviceInfoConstants; + readonly getConstants: () => DeviceInfoConstants; } const NativeModule: Spec = TurboModuleRegistry.getEnforcing('DeviceInfo'); diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDialogManagerAndroid.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDialogManagerAndroid.js index 215fbd6601ff..d4287cc53ada 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDialogManagerAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeDialogManagerAndroid.js @@ -31,14 +31,14 @@ export type DialogOptions = { }; export interface Spec extends TurboModule { - +getConstants: () => { - +buttonClicked: DialogAction, - +dismissed: DialogAction, - +buttonPositive: DialogButtonKey, - +buttonNegative: DialogButtonKey, - +buttonNeutral: DialogButtonKey, + readonly getConstants: () => { + readonly buttonClicked: DialogAction, + readonly dismissed: DialogAction, + readonly buttonPositive: DialogButtonKey, + readonly buttonNegative: DialogButtonKey, + readonly buttonNeutral: DialogButtonKey, }; - +showAlert: ( + readonly showAlert: ( config: DialogOptions, onError: (error: string) => void, onAction: (action: DialogAction, buttonKey?: DialogButtonKey) => void, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeExceptionsManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeExceptionsManager.js index 0547d9af5a27..28b22c11de98 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeExceptionsManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeExceptionsManager.js @@ -35,20 +35,20 @@ export type ExceptionData = { }; export interface Spec extends TurboModule { // Deprecated: Use `reportException` - +reportFatalException: ( + readonly reportFatalException: ( message: string, stack: Array, exceptionId: number, ) => void; // Deprecated: Use `reportException` - +reportSoftException: ( + readonly reportSoftException: ( message: string, stack: Array, exceptionId: number, ) => void; - +reportException?: (data: ExceptionData) => void; + readonly reportException?: (data: ExceptionData) => void; // TODO(T53311281): This is a noop on iOS now. Implement it. - +dismissRedbox?: () => void; + readonly dismissRedbox?: () => void; } const NativeModule = 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 dc88374aabe2..835bd532ee75 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeFileReaderModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeFileReaderModule.js @@ -13,8 +13,8 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +readAsDataURL: (data: Object) => Promise; - +readAsText: (data: Object, encoding: string) => Promise; + readonly readAsDataURL: (data: Object) => Promise; + readonly readAsText: (data: Object, encoding: string) => Promise; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeFrameRateLogger.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeFrameRateLogger.js index 8792cc9ae3c6..8cfb7571ba10 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeFrameRateLogger.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeFrameRateLogger.js @@ -13,10 +13,10 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +setGlobalOptions: (options: {+debug?: ?boolean}) => void; - +setContext: (context: string) => void; - +beginScroll: () => void; - +endScroll: () => void; + readonly setGlobalOptions: (options: {readonly debug?: ?boolean}) => void; + readonly setContext: (context: string) => void; + readonly beginScroll: () => void; + readonly endScroll: () => void; } export default TurboModuleRegistry.get('FrameRateLogger') as ?Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeHeadlessJsTaskSupport.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeHeadlessJsTaskSupport.js index 471204e3c38e..a9b2bb290135 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeHeadlessJsTaskSupport.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeHeadlessJsTaskSupport.js @@ -13,8 +13,8 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +notifyTaskFinished: (taskId: number) => void; - +notifyTaskRetry: (taskId: number) => Promise; + readonly notifyTaskFinished: (taskId: number) => void; + readonly notifyTaskRetry: (taskId: number) => Promise; } export default TurboModuleRegistry.get('HeadlessJsTaskSupport') as ?Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeI18nManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeI18nManager.js index dbd9135987d4..467cedb3d4b2 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeI18nManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeI18nManager.js @@ -19,7 +19,7 @@ export type I18nManagerConstants = { }; export interface Spec extends TurboModule { - +getConstants: () => I18nManagerConstants; + readonly getConstants: () => I18nManagerConstants; allowRTL: (allowRTL: boolean) => void; forceRTL: (forceRTL: boolean) => void; swapLeftAndRightInRTL: (flipStyles: boolean) => void; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageEditor.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageEditor.js index e43706c9b01b..a196e7e9ba3f 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageEditor.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageEditor.js @@ -13,17 +13,17 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; type Options = { - +offset: { - +x: number, - +y: number, + readonly offset: { + readonly x: number, + readonly y: number, }, - +size: { - +width: number, - +height: number, + readonly size: { + readonly width: number, + readonly height: number, }, - +displaySize?: ?{ - +width: number, - +height: number, + readonly displaySize?: ?{ + readonly width: number, + readonly height: number, }, /** * Enum with potential values: @@ -33,13 +33,13 @@ type Options = { * - center * - repeat */ - +resizeMode?: ?string, - +allowExternalStorage?: boolean, + readonly resizeMode?: ?string, + readonly allowExternalStorage?: boolean, }; export interface Spec extends TurboModule { - +getConstants: () => {}; - +cropImage: ( + readonly getConstants: () => {}; + readonly cropImage: ( uri: string, cropData: Options, successCallback: (uri: string) => void, 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 c60d7a4267c8..dc30094b4189 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderAndroid.js @@ -19,12 +19,15 @@ export type ImageSize = { }; export interface Spec extends TurboModule { - +abortRequest: (requestId: number) => void; - +getConstants: () => {}; - +getSize: (uri: string) => Promise; - +getSizeWithHeaders: (uri: string, headers: Object) => Promise; - +prefetchImage: (uri: string, requestId: number) => Promise; - +queryCache: (uris: Array) => Promise; + readonly abortRequest: (requestId: number) => void; + readonly getConstants: () => {}; + readonly getSize: (uri: string) => Promise; + readonly getSizeWithHeaders: ( + uri: string, + headers: Object, + ) => Promise; + readonly prefetchImage: (uri: string, requestId: number) => 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 c9cf98c5a0ef..bdc908509ae2 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js @@ -14,10 +14,10 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => {}; + readonly getConstants: () => {}; // Return [width, height] of image uri - +getSize: (uri: string) => Promise>; - +getSizeWithHeaders: ( + readonly getSize: (uri: string) => Promise>; + readonly getSizeWithHeaders: ( uri: string, headers: Object, ) => Promise<{ @@ -25,13 +25,13 @@ export interface Spec extends TurboModule { height: number, ... }>; - +prefetchImage: (uri: string) => Promise; - +prefetchImageWithMetadata?: ( + readonly prefetchImage: (uri: string) => Promise; + readonly prefetchImageWithMetadata?: ( uri: string, queryRootName: string, rootTag: RootTag, ) => Promise; - +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/NativeImageStoreAndroid.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageStoreAndroid.js index 7fee26fb4b0a..6a5023d52202 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageStoreAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageStoreAndroid.js @@ -13,8 +13,8 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => {}; - +getBase64ForTag: ( + readonly getConstants: () => {}; + readonly getBase64ForTag: ( uri: string, successCallback: (base64ImageData: string) => void, errorCallback: (error: string) => void, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageStoreIOS.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageStoreIOS.js index 83054f085b57..f3127547be29 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageStoreIOS.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeImageStoreIOS.js @@ -13,15 +13,18 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => {}; - +getBase64ForTag: ( + readonly getConstants: () => {}; + readonly getBase64ForTag: ( uri: string, successCallback: (base64ImageData: string) => void, errorCallback: (error: {message: string}) => void, ) => void; - +hasImageForTag: (uri: string, callback: (hasImage: boolean) => void) => void; - +removeImageForTag: (uri: string) => void; - +addImageFromBase64: ( + readonly hasImageForTag: ( + uri: string, + callback: (hasImage: boolean) => void, + ) => void; + readonly removeImageForTag: (uri: string) => void; + readonly addImageFromBase64: ( base64ImageData: string, successCallback: (uri: string) => void, errorCallback: (error: {message: string}) => void, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeIntentAndroid.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeIntentAndroid.js index ef8b4d4828c6..cc1f752d66f4 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeIntentAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeIntentAndroid.js @@ -13,11 +13,11 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getInitialURL: () => Promise; - +canOpenURL: (url: string) => Promise; - +openURL: (url: string) => Promise; - +openSettings: () => Promise; - +sendIntent: ( + readonly getInitialURL: () => Promise; + readonly canOpenURL: (url: string) => Promise; + readonly openURL: (url: string) => Promise; + readonly openSettings: () => Promise; + readonly sendIntent: ( action: string, extras: ?Array<{ key: string, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeJSCHeapCapture.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeJSCHeapCapture.js index cbd257b9af48..5350809583ce 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeJSCHeapCapture.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeJSCHeapCapture.js @@ -13,7 +13,7 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +captureComplete: (path: string, error: ?string) => void; + readonly captureComplete: (path: string, error: ?string) => void; } export default TurboModuleRegistry.get('JSCHeapCapture') as ?Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeKeyboardObserver.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeKeyboardObserver.js index 456615af0144..641e74739d3b 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeKeyboardObserver.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeKeyboardObserver.js @@ -13,8 +13,8 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; } export default TurboModuleRegistry.get('KeyboardObserver') as ?Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeLinkingManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeLinkingManager.js index 98f5a319722c..fab06fc992f7 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeLinkingManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeLinkingManager.js @@ -14,14 +14,14 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod export interface Spec extends TurboModule { // Common interface - +getInitialURL: () => Promise; - +canOpenURL: (url: string) => Promise; - +openURL: (url: string) => Promise; - +openSettings: () => Promise; + readonly getInitialURL: () => Promise; + readonly canOpenURL: (url: string) => Promise; + readonly openURL: (url: string) => Promise; + readonly openSettings: () => Promise; // Events - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; } export default TurboModuleRegistry.get('LinkingManager') as ?Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeLogBox.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeLogBox.js index 75926a289c80..64e8039443ec 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeLogBox.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeLogBox.js @@ -13,8 +13,8 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +show: () => void; - +hide: () => void; + readonly show: () => void; + readonly hide: () => void; } export default TurboModuleRegistry.get('LogBox') as ?Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeModalManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeModalManager.js index 0ac1400ccb17..b25723b1b2bc 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeModalManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeModalManager.js @@ -14,8 +14,8 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod export interface Spec extends TurboModule { // RCTEventEmitter - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; } export default TurboModuleRegistry.get('ModalManager') 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 8de52013daf4..df9fec835c5e 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingAndroid.js @@ -15,7 +15,7 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod type Header = [string, string]; export interface Spec extends TurboModule { - +sendRequest: ( + readonly sendRequest: ( method: string, url: string, requestId: number, @@ -26,12 +26,12 @@ export interface Spec extends TurboModule { timeout: number, withCredentials: boolean, ) => void; - +abortRequest: (requestId: number) => void; - +clearCookies: (callback: (result: boolean) => void) => void; + readonly abortRequest: (requestId: number) => void; + readonly clearCookies: (callback: (result: boolean) => void) => void; // RCTEventEmitter - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; } export default TurboModuleRegistry.getEnforcing('Networking') as Spec; 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 05fc5118dae6..5fc56cb35bd5 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js @@ -13,7 +13,7 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +sendRequest: ( + readonly sendRequest: ( query: { method: string, url: string, @@ -23,16 +23,16 @@ export interface Spec extends TurboModule { incrementalUpdates: boolean, timeout: number, withCredentials: boolean, - +unstable_devToolsRequestId?: string, + readonly unstable_devToolsRequestId?: string, }, callback: (requestId: number) => void, ) => void; - +abortRequest: (requestId: number) => void; - +clearCookies: (callback: (result: boolean) => void) => void; + readonly abortRequest: (requestId: number) => void; + readonly clearCookies: (callback: (result: boolean) => void) => void; // RCTEventEmitter - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; } export default TurboModuleRegistry.getEnforcing('Networking') as Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativePermissionsAndroid.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativePermissionsAndroid.js index 24dc4bc654f4..2b0c1a324732 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativePermissionsAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativePermissionsAndroid.js @@ -65,12 +65,14 @@ export type PermissionType = */ export interface Spec extends TurboModule { - +checkPermission: (permission: PermissionType) => Promise; - +requestPermission: (permission: PermissionType) => Promise; - +shouldShowRequestPermissionRationale: ( + readonly checkPermission: (permission: PermissionType) => Promise; + readonly requestPermission: ( + permission: PermissionType, + ) => Promise; + readonly shouldShowRequestPermissionRationale: ( permission: string, ) => Promise; - +requestMultiplePermissions: ( + readonly requestMultiplePermissions: ( permissions: Array, ) => Promise<{[permission: PermissionType]: PermissionStatus, ...}>; } diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativePlatformConstantsAndroid.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativePlatformConstantsAndroid.js index 8b1dff5bf885..ae0f71b99205 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativePlatformConstantsAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativePlatformConstantsAndroid.js @@ -35,8 +35,8 @@ export type PlatformConstantsAndroid = { }; export interface Spec extends TurboModule { - +getConstants: () => PlatformConstantsAndroid; - +getAndroidID: () => string; + readonly getConstants: () => PlatformConstantsAndroid; + readonly getAndroidID: () => string; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativePlatformConstantsIOS.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativePlatformConstantsIOS.js index 110557795733..05ca551426b2 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativePlatformConstantsIOS.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativePlatformConstantsIOS.js @@ -29,7 +29,7 @@ export type PlatformConstantsIOS = { }; export interface Spec extends TurboModule { - +getConstants: () => PlatformConstantsIOS; + readonly getConstants: () => PlatformConstantsIOS; } export default TurboModuleRegistry.getEnforcing( 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 3c0f30919d21..ad4ed1de0529 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativePushNotificationManagerIOS.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativePushNotificationManagerIOS.js @@ -19,14 +19,14 @@ type Permissions = { }; type Notification = { - +alertTitle?: ?string, - +alertBody?: ?string, - +userInfo?: ?Object, + readonly alertTitle?: ?string, + readonly alertBody?: ?string, + readonly userInfo?: ?Object, /** * Identifier for the notification category. See the [Apple documentation](https://developer.apple.com/documentation/usernotifications/declaring_your_actionable_notification_types) * for more details. */ - +category?: ?string, + readonly category?: ?string, /** * Actual type: string | number * @@ -35,7 +35,7 @@ type Notification = { * If you use `presentLocalNotification`, both will be ignored * and the notification will be shown immediately. */ - +fireDate?: ?number, + readonly fireDate?: ?number, /** * Seconds from now to display the notification. * @@ -44,22 +44,22 @@ type Notification = { * If you use `presentLocalNotification`, both will be ignored * and the notification will be shown immediately. */ - +fireIntervalSeconds?: ?number, + readonly fireIntervalSeconds?: ?number, /** Badge count to display on the app icon. */ - +applicationIconBadgeNumber?: ?number, + readonly applicationIconBadgeNumber?: ?number, /** Whether to silence the notification sound. */ - +isSilent?: ?boolean, + readonly isSilent?: ?boolean, /** * Custom notification sound. Can only be set when creating notifications. * This will be null for notifications retrieved via * getScheduledLocalNotifications or getDeliveredNotifications. */ - +soundName?: ?string, + readonly soundName?: ?string, }; export interface Spec extends TurboModule { - +getConstants: () => {}; - +onFinishRemoteNotification: ( + readonly getConstants: () => {}; + readonly onFinishRemoteNotification: ( notificationId: string, /** * Type: @@ -69,33 +69,37 @@ export interface Spec extends TurboModule { */ fetchResult: string, ) => void; - +setApplicationIconBadgeNumber: (num: number) => void; - +getApplicationIconBadgeNumber: (callback: (num: number) => void) => void; - +requestPermissions: (permission: { - +alert: boolean, - +badge: boolean, - +sound: boolean, + readonly setApplicationIconBadgeNumber: (num: number) => void; + readonly getApplicationIconBadgeNumber: ( + callback: (num: number) => void, + ) => void; + readonly requestPermissions: (permission: { + readonly alert: boolean, + readonly badge: boolean, + readonly sound: boolean, }) => Promise; - +abandonPermissions: () => void; - +checkPermissions: (callback: (permissions: Permissions) => void) => void; - +presentLocalNotification: (notification: Notification) => void; - +scheduleLocalNotification: (notification: Notification) => void; - +cancelAllLocalNotifications: () => void; - +cancelLocalNotifications: (userInfo: Object) => void; - +getInitialNotification: () => Promise; - +getScheduledLocalNotifications: ( + readonly abandonPermissions: () => void; + readonly checkPermissions: ( + callback: (permissions: Permissions) => void, + ) => void; + readonly presentLocalNotification: (notification: Notification) => void; + readonly scheduleLocalNotification: (notification: Notification) => void; + readonly cancelAllLocalNotifications: () => void; + readonly cancelLocalNotifications: (userInfo: Object) => void; + readonly getInitialNotification: () => Promise; + readonly getScheduledLocalNotifications: ( callback: (notification: Notification) => void, ) => void; - +removeAllDeliveredNotifications: () => void; - +removeDeliveredNotifications: (identifiers: Array) => void; - +getDeliveredNotifications: ( + readonly removeAllDeliveredNotifications: () => void; + readonly removeDeliveredNotifications: (identifiers: Array) => void; + readonly getDeliveredNotifications: ( callback: (notification: Array) => void, ) => void; - +getAuthorizationStatus: ( + readonly getAuthorizationStatus: ( callback: (authorizationStatus: number) => void, ) => void; - +addListener: (eventType: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventType: string) => void; + readonly removeListeners: (count: number) => void; } export default TurboModuleRegistry.get( 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 c16d64bf58f8..b61cd62c78ef 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeRedBox.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeRedBox.js @@ -13,8 +13,8 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +setExtraData: (extraData: Object, forIdentifier: string) => void; - +dismiss: () => void; + readonly setExtraData: (extraData: Object, forIdentifier: string) => void; + readonly dismiss: () => void; } export default TurboModuleRegistry.get('RedBox') as ?Spec; 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 2cfb9ccb8184..65ee3fe605c1 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js @@ -31,37 +31,37 @@ export type ObjectStruct = { }; export interface Spec extends TurboModule { - +onPress: EventEmitter; - +onClick: EventEmitter; - +onChange: EventEmitter; - +onSubmit: EventEmitter; + readonly onPress: EventEmitter; + readonly onClick: EventEmitter; + readonly onChange: EventEmitter; + readonly onSubmit: EventEmitter; // Exported methods. - +getConstants: () => { + readonly getConstants: () => { const1: boolean, const2: number, const3: string, }; - +voidFunc: () => void; - +getBool: (arg: boolean) => boolean; - +getEnum?: (arg: EnumInt) => EnumInt; - +getNumber: (arg: number) => number; - +getString: (arg: string) => string; - +getArray: (arg: Array) => Array; - +getObject: (arg: Object) => Object; - +getUnsafeObject: (arg: UnsafeObject) => UnsafeObject; - +getRootTag: (arg: RootTag) => RootTag; - +getValue: (x: number, y: string, z: Object) => Object; - +getValueWithCallback: (callback: (value: string) => void) => void; - +getValueWithPromise: (error: boolean) => Promise; - +voidFuncThrows?: () => void; - +getObjectThrows?: (arg: Object) => Object; - +promiseThrows?: () => Promise; - +voidFuncAssert?: () => void; - +getObjectAssert?: (arg: Object) => Object; - +promiseAssert?: () => Promise; + readonly voidFunc: () => void; + readonly getBool: (arg: boolean) => boolean; + 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 getUnsafeObject: (arg: UnsafeObject) => UnsafeObject; + readonly getRootTag: (arg: RootTag) => RootTag; + readonly getValue: (x: number, y: string, z: Object) => Object; + readonly getValueWithCallback: (callback: (value: string) => void) => void; + readonly getValueWithPromise: (error: boolean) => Promise; + readonly voidFuncThrows?: () => void; + readonly getObjectThrows?: (arg: Object) => Object; + readonly promiseThrows?: () => Promise; + readonly voidFuncAssert?: () => void; + readonly getObjectAssert?: (arg: Object) => Object; + readonly promiseAssert?: () => Promise; // Android-only - +getImageUrl?: () => Promise; + readonly getImageUrl?: () => Promise; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSegmentFetcher.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSegmentFetcher.js index 69a0400b6d61..bf7bfdaa7303 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSegmentFetcher.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSegmentFetcher.js @@ -13,12 +13,12 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +fetchSegment: ( + readonly fetchSegment: ( segmentId: number, options: Object, // flowlint-line unclear-type: off callback: (error: ?Object) => void, // flowlint-line unclear-type: off ) => void; - +getSegment?: ( + readonly getSegment?: ( segmentId: number, options: Object, // flowlint-line unclear-type: off callback: (error: ?Object, path: ?string) => void, // flowlint-line unclear-type: off 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 c9b6f48c1a8e..5cc6c4cb1443 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSettingsManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSettingsManager.js @@ -13,11 +13,11 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => { + readonly getConstants: () => { settings: Object, }; - +setValues: (values: Object) => void; - +deleteValues: (values: Array) => void; + readonly setValues: (values: Object) => void; + readonly deleteValues: (values: Array) => void; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeShareModule.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeShareModule.js index fb676c3f77b3..fb3eaa4a902f 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeShareModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeShareModule.js @@ -13,8 +13,8 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => {}; - +share: ( + readonly getConstants: () => {}; + readonly share: ( content: {title?: string, message?: string}, dialogTitle?: string, ) => Promise<{action: string}>; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSoundManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSoundManager.js index 6ecd2954c9c0..81154f7aefd5 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSoundManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSoundManager.js @@ -16,7 +16,7 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod * Native Module used for playing sounds in native platform. */ export interface Spec extends TurboModule { - +playTouchSound: () => void; + readonly playTouchSound: () => void; } export default TurboModuleRegistry.get('SoundManager') as ?Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSourceCode.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSourceCode.js index 6918a583feea..3353866ab4fe 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSourceCode.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeSourceCode.js @@ -17,7 +17,7 @@ export type SourceCodeConstants = { }; export interface Spec extends TurboModule { - +getConstants: () => SourceCodeConstants; + readonly getConstants: () => SourceCodeConstants; } const NativeModule = TurboModuleRegistry.getEnforcing('SourceCode'); diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeStatusBarManagerAndroid.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeStatusBarManagerAndroid.js index 03ba33b72248..4ef517a7928b 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeStatusBarManagerAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeStatusBarManagerAndroid.js @@ -13,20 +13,20 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => { - +HEIGHT: number, - +DEFAULT_BACKGROUND_COLOR: number, + readonly getConstants: () => { + readonly HEIGHT: number, + readonly DEFAULT_BACKGROUND_COLOR: number, }; - +setColor: (color: number, animated: boolean) => void; - +setTranslucent: (translucent: boolean) => void; + readonly setColor: (color: number, animated: boolean) => void; + readonly setTranslucent: (translucent: boolean) => void; /** * - statusBarStyles can be: * - 'default' * - 'dark-content' */ - +setStyle: (statusBarStyle?: ?string) => void; - +setHidden: (hidden: boolean) => void; + readonly setStyle: (statusBarStyle?: ?string) => void; + readonly setHidden: (hidden: boolean) => void; } const NativeModule = TurboModuleRegistry.getEnforcing('StatusBarManager'); @@ -34,8 +34,8 @@ let constants = null; const NativeStatusBarManager = { getConstants(): { - +HEIGHT: number, - +DEFAULT_BACKGROUND_COLOR?: number, + readonly HEIGHT: number, + readonly DEFAULT_BACKGROUND_COLOR?: number, } { if (constants == null) { constants = NativeModule.getConstants(); diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeStatusBarManagerIOS.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeStatusBarManagerIOS.js index a18bc292d52b..525a99eadd65 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeStatusBarManagerIOS.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeStatusBarManagerIOS.js @@ -13,16 +13,16 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => { - +HEIGHT: number, - +DEFAULT_BACKGROUND_COLOR?: number, + readonly getConstants: () => { + readonly HEIGHT: number, + readonly DEFAULT_BACKGROUND_COLOR?: number, }; // TODO(T47754272) Can we remove this method? - +getHeight: (callback: (result: {height: number}) => void) => void; - +setNetworkActivityIndicatorVisible: (visible: boolean) => void; - +addListener: (eventType: string) => void; - +removeListeners: (count: number) => void; + readonly getHeight: (callback: (result: {height: number}) => void) => void; + readonly setNetworkActivityIndicatorVisible: (visible: boolean) => void; + readonly addListener: (eventType: string) => void; + readonly removeListeners: (count: number) => void; /** * - statusBarStyles can be: @@ -30,11 +30,11 @@ export interface Spec extends TurboModule { * - 'dark-content' * - 'light-content' */ - +setStyle: (statusBarStyle?: ?string, animated: boolean) => void; + readonly setStyle: (statusBarStyle?: ?string, animated: boolean) => void; /** * - withAnimation can be: 'none' | 'fade' | 'slide' */ - +setHidden: (hidden: boolean, withAnimation: string) => void; + readonly setHidden: (hidden: boolean, withAnimation: string) => void; } const NativeModule = TurboModuleRegistry.getEnforcing('StatusBarManager'); @@ -42,8 +42,8 @@ let constants = null; const NativeStatusBarManager = { getConstants(): { - +HEIGHT: number, - +DEFAULT_BACKGROUND_COLOR?: number, + readonly HEIGHT: number, + readonly DEFAULT_BACKGROUND_COLOR?: number, } { if (constants == null) { constants = NativeModule.getConstants(); diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeTiming.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeTiming.js index 48b475f71dc8..d75f09ef5d64 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeTiming.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeTiming.js @@ -14,14 +14,14 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +createTimer: ( + readonly createTimer: ( callbackID: number, duration: number, jsSchedulingTime: number, repeats: boolean, ) => void; - +deleteTimer: (timerID: number) => void; - +setSendIdleEvents: (sendIdleEvents: boolean) => void; + readonly deleteTimer: (timerID: number) => void; + readonly setSendIdleEvents: (sendIdleEvents: boolean) => void; } export default TurboModuleRegistry.get('Timing') as ?Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeToastAndroid.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeToastAndroid.js index 84ed5fc58ba8..ff45a8c4d4d5 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeToastAndroid.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeToastAndroid.js @@ -13,20 +13,20 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => { + readonly getConstants: () => { SHORT: number, LONG: number, TOP: number, BOTTOM: number, CENTER: number, }; - +show: (message: string, duration: number) => void; - +showWithGravity: ( + readonly show: (message: string, duration: number) => void; + readonly showWithGravity: ( message: string, duration: number, gravity: number, ) => void; - +showWithGravityAndOffset: ( + readonly showWithGravityAndOffset: ( message: string, duration: number, gravity: number, diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeUIManager.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeUIManager.js index 9603db949952..59683ec59aec 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeUIManager.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeUIManager.js @@ -37,15 +37,19 @@ export type NativeMeasureLayoutOnSuccessCallback = ( ) => void; export interface Spec extends TurboModule { - +getConstants: () => Object; - +createView: ( + readonly getConstants: () => Object; + readonly createView: ( reactTag: number, viewName: string, rootTag: RootTag, props: Object, ) => void; - +updateView: (reactTag: number, viewName: string, props: Object) => void; - +findSubviewIn: ( + readonly updateView: ( + reactTag: number, + viewName: string, + props: Object, + ) => void; + readonly findSubviewIn: ( reactTag: number, point: Array, callback: ( @@ -63,7 +67,7 @@ export interface Spec extends TurboModule { * commandID - Id of the native method that should be called. * commandArgs - Args of the native method that we can pass from JS to native. */ - +dispatchViewManagerCommand: ( + readonly dispatchViewManagerCommand: ( reactTag: number, commandID: number, // number || string commandArgs?: Array, @@ -87,7 +91,7 @@ export interface Spec extends TurboModule { * * @deprecated Use `ref.measure` instead. */ - +measure: ( + readonly measure: ( reactTag: number, callback: NativeMeasureOnSuccessCallback, ) => void; @@ -108,11 +112,11 @@ export interface Spec extends TurboModule { * * @deprecated Use `ref.measureInWindow` instead. */ - +measureInWindow: ( + readonly measureInWindow: ( reactTag: number, callback: NativeMeasureInWindowOnSuccessCallback, ) => void; - +viewIsDescendantOf: ( + readonly viewIsDescendantOf: ( reactTag: number, ancestorReactTag: number, callback: (result: Array) => void, @@ -127,13 +131,13 @@ export interface Spec extends TurboModule { * * @deprecated Use `ref.measureLayout` instead. */ - +measureLayout: ( + readonly measureLayout: ( reactTag: number, ancestorReactTag: number, errorCallback: (error: Object) => void, callback: NativeMeasureLayoutOnSuccessCallback, ) => void; - +measureLayoutRelativeToParent: ( + readonly measureLayoutRelativeToParent: ( reactTag: number, errorCallback: (error: Object) => void, callback: ( @@ -143,15 +147,21 @@ export interface Spec extends TurboModule { height: number, ) => void, ) => void; - +setJSResponder: (reactTag: number, blockNativeResponder: boolean) => void; - +clearJSResponder: () => void; - +configureNextLayoutAnimation: ( + readonly setJSResponder: ( + reactTag: number, + blockNativeResponder: boolean, + ) => void; + readonly clearJSResponder: () => void; + readonly configureNextLayoutAnimation: ( config: Object, callback: () => void, // check what is returned here errorCallback: (error: Object) => void, ) => void; - +setChildren: (containerTag: number, reactTags: Array) => void; - +manageChildren: ( + readonly setChildren: ( + containerTag: number, + reactTags: Array, + ) => void; + readonly manageChildren: ( containerTag: number, moveFromIndices: Array, moveToIndices: Array, @@ -161,8 +171,8 @@ export interface Spec extends TurboModule { ) => void; // Android only - +getConstantsForViewManager?: (viewManagerName: string) => ?Object; - +getDefaultEventTypes?: () => Array; + readonly getConstantsForViewManager?: (viewManagerName: string) => ?Object; + readonly getDefaultEventTypes?: () => Array; /** * Automatically animates views to their new positions when the * next layout happens. @@ -175,13 +185,16 @@ export interface Spec extends TurboModule { * UIManager.setLayoutAnimationEnabledExperimental && UIManager.setLayoutAnimationEnabledExperimental(true); * ``` */ - +setLayoutAnimationEnabledExperimental?: (enabled: boolean) => void; - +sendAccessibilityEvent?: (reactTag: number, eventType: number) => void; + readonly setLayoutAnimationEnabledExperimental?: (enabled: boolean) => void; + readonly sendAccessibilityEvent?: ( + reactTag: number, + eventType: number, + ) => void; // ios only - +lazilyLoadView?: (name: string) => Object; // revisit return - +focus?: (reactTag: number) => void; - +blur?: (reactTag: number) => void; + readonly lazilyLoadView?: (name: string) => Object; // revisit return + readonly focus?: (reactTag: number) => void; + readonly blur?: (reactTag: number) => void; } export default TurboModuleRegistry.getEnforcing('UIManager') as Spec; diff --git a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeVibration.js b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeVibration.js index 6387e218788d..487dea565a36 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeVibration.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeVibration.js @@ -13,12 +13,12 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getConstants: () => {}; - +vibrate: (pattern: number) => void; + readonly getConstants: () => {}; + readonly vibrate: (pattern: number) => void; // Android only - +vibrateByPattern: (pattern: Array, repeat: number) => void; - +cancel: () => void; + readonly vibrateByPattern: (pattern: Array, repeat: number) => void; + readonly cancel: () => void; } export default TurboModuleRegistry.getEnforcing('Vibration') as Spec; 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 8032c9a8252c..7feb712212a8 100644 --- a/packages/react-native/src/private/specs_DEPRECATED/modules/NativeWebSocketModule.js +++ b/packages/react-native/src/private/specs_DEPRECATED/modules/NativeWebSocketModule.js @@ -13,20 +13,20 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +connect: ( + readonly connect: ( url: string, protocols: ?Array, options: {headers?: Object}, socketID: number, ) => void; - +send: (message: string, forSocketID: number) => void; - +sendBinary: (base64String: string, forSocketID: number) => void; - +ping: (socketID: number) => void; - +close: (code: number, reason: string, socketID: number) => void; + readonly send: (message: string, forSocketID: number) => void; + readonly sendBinary: (base64String: string, forSocketID: number) => void; + readonly ping: (socketID: number) => void; + readonly close: (code: number, reason: string, socketID: number) => void; // RCTEventEmitter - +addListener: (eventName: string) => void; - +removeListeners: (count: number) => void; + readonly addListener: (eventName: string) => void; + readonly removeListeners: (count: number) => void; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native/src/private/testing/fantom/specs/NativeCPUTime.js b/packages/react-native/src/private/testing/fantom/specs/NativeCPUTime.js index e8639d6d7910..2d846fd0d594 100644 --- a/packages/react-native/src/private/testing/fantom/specs/NativeCPUTime.js +++ b/packages/react-native/src/private/testing/fantom/specs/NativeCPUTime.js @@ -17,8 +17,8 @@ import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/Turbo * measurements and benchmarks. It is not meant to be used in production. */ export interface Spec extends TurboModule { - +getCPUTimeNanos: () => number; - +hasAccurateCPUTimeNanosForBenchmarks: () => boolean; + readonly getCPUTimeNanos: () => number; + readonly hasAccurateCPUTimeNanosForBenchmarks: () => boolean; } export default TurboModuleRegistry.getEnforcing('CPUTimeCxx') as Spec; diff --git a/packages/react-native/src/private/testing/fantom/specs/NativeFantomTestSpecificMethods.js b/packages/react-native/src/private/testing/fantom/specs/NativeFantomTestSpecificMethods.js index 9005466d30ba..7827549e7450 100644 --- a/packages/react-native/src/private/testing/fantom/specs/NativeFantomTestSpecificMethods.js +++ b/packages/react-native/src/private/testing/fantom/specs/NativeFantomTestSpecificMethods.js @@ -23,9 +23,13 @@ import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/Turbo * that this is the only way to test the behavior. */ export interface Spec extends TurboModule { - +registerForcedCloneCommitHook: () => void; - +takeFunctionAndNoop: (fn: () => void) => void; - +setRootNodeSize: (surfaceId: Int32, width: Float, height: Float) => void; + readonly registerForcedCloneCommitHook: () => void; + readonly takeFunctionAndNoop: (fn: () => void) => void; + readonly setRootNodeSize: ( + surfaceId: Int32, + width: Float, + height: Float, + ) => void; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native/src/private/viewtransition/specs/NativeViewTransition.js b/packages/react-native/src/private/viewtransition/specs/NativeViewTransition.js index c3bebd473528..52817be7732e 100644 --- a/packages/react-native/src/private/viewtransition/specs/NativeViewTransition.js +++ b/packages/react-native/src/private/viewtransition/specs/NativeViewTransition.js @@ -13,7 +13,7 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +getViewTransitionInstance: ( + readonly getViewTransitionInstance: ( name: string, pseudo: string, ) => ?{ @@ -23,9 +23,11 @@ export interface Spec extends TurboModule { height: number, nativeTag: number, }; - +findPseudoElementShadowNodeByTag: (reactTag: number) => ?unknown /* Node */; - +waitForTransitionAnimation: (animationId: number) => void; - +transitionAnimationFinished: (animationId: number) => void; + readonly findPseudoElementShadowNodeByTag: ( + reactTag: number, + ) => ?unknown /* Node */; + readonly waitForTransitionAnimation: (animationId: number) => void; + readonly transitionAnimationFinished: (animationId: number) => void; } export default TurboModuleRegistry.get( diff --git a/packages/react-native/src/private/webapis/dom/events/CustomEvent.js b/packages/react-native/src/private/webapis/dom/events/CustomEvent.js index fd5922a36d6b..918bd984702e 100644 --- a/packages/react-native/src/private/webapis/dom/events/CustomEvent.js +++ b/packages/react-native/src/private/webapis/dom/events/CustomEvent.js @@ -20,7 +20,7 @@ import type {EventInit} from './Event'; import Event from './Event'; export interface CustomEventInit extends EventInit { - +detail?: unknown; + readonly detail?: unknown; } export default class CustomEvent extends Event { diff --git a/packages/react-native/src/private/webapis/dom/events/Event.js b/packages/react-native/src/private/webapis/dom/events/Event.js index f918f9796e56..4b161026426e 100644 --- a/packages/react-native/src/private/webapis/dom/events/Event.js +++ b/packages/react-native/src/private/webapis/dom/events/Event.js @@ -39,21 +39,21 @@ import { } from './internals/EventInternals'; export interface EventInit { - +bubbles?: boolean; - +cancelable?: boolean; - +composed?: boolean; + readonly bubbles?: boolean; + readonly cancelable?: boolean; + readonly composed?: boolean; } export default class Event { - static +NONE: 0; - static +CAPTURING_PHASE: 1; - static +AT_TARGET: 2; - static +BUBBLING_PHASE: 3; - - +NONE: 0; - +CAPTURING_PHASE: 1; - +AT_TARGET: 2; - +BUBBLING_PHASE: 3; + static readonly NONE: 0; + static readonly CAPTURING_PHASE: 1; + static readonly AT_TARGET: 2; + static readonly BUBBLING_PHASE: 3; + + readonly NONE: 0; + readonly CAPTURING_PHASE: 1; + readonly AT_TARGET: 2; + readonly BUBBLING_PHASE: 3; _bubbles: boolean; _cancelable: boolean; diff --git a/packages/react-native/src/private/webapis/dom/events/EventTarget.js b/packages/react-native/src/private/webapis/dom/events/EventTarget.js index 92bebb55c4a5..e794efcc3379 100644 --- a/packages/react-native/src/private/webapis/dom/events/EventTarget.js +++ b/packages/react-native/src/private/webapis/dom/events/EventTarget.js @@ -55,9 +55,9 @@ export type AddEventListenerOptions = Readonly<{ }>; type EventListenerRegistration = { - +callback: EventListener, - +passive: boolean, - +once: boolean, + readonly callback: EventListener, + readonly passive: boolean, + readonly once: boolean, removed: boolean, }; diff --git a/packages/react-native/src/private/webapis/dom/nodes/specs/NativeDOM.js b/packages/react-native/src/private/webapis/dom/nodes/specs/NativeDOM.js index 1cb40bc1286f..12a34399221c 100644 --- a/packages/react-native/src/private/webapis/dom/nodes/specs/NativeDOM.js +++ b/packages/react-native/src/private/webapis/dom/nodes/specs/NativeDOM.js @@ -51,25 +51,25 @@ export interface Spec extends TurboModule { * Methods from the `Node` interface (for `ReadOnlyNode`). */ - +compareDocumentPosition: ( + readonly compareDocumentPosition: ( nativeNodeReference: unknown /* NativeNodeReference */, otherNativeNodeReference: unknown /* NativeNodeReference */, ) => number; - +getChildNodes: ( + readonly getChildNodes: ( nativeNodeReference: unknown /* NativeNodeReference */, ) => ReadonlyArray /* $ReadOnlyArray */; - +getElementById?: ( + readonly getElementById?: ( nativeNodeReference: unknown /* NativeNodeReference */, id: string, ) => unknown /* ?InstanceHandle */; - +getParentNode: ( + readonly getParentNode: ( nativeNodeReference: unknown /* NativeNodeReference */, ) => unknown /* ?InstanceHandle */; - +isConnected: ( + readonly isConnected: ( nativeNodeReference: unknown /* NativeNodeReference */, ) => boolean; @@ -77,46 +77,46 @@ export interface Spec extends TurboModule { * Methods from the `Element` interface (for `ReactNativeElement`). */ - +getBorderWidth: ( + readonly getBorderWidth: ( nativeElementReference: unknown /* NativeElementReference */, ) => ReadonlyArray /* [topWidth: number, rightWidth: number, bottomWidth: number, leftWidth: number] */; - +getBoundingClientRect: ( + readonly getBoundingClientRect: ( nativeElementReference: unknown /* NativeElementReference */, includeTransform: boolean, ) => ReadonlyArray /* [x: number, y: number, width: number, height: number] */; - +getInnerSize: ( + readonly getInnerSize: ( nativeElementReference: unknown /* NativeElementReference */, ) => ReadonlyArray /* [width: number, height: number] */; - +getScrollPosition: ( + readonly getScrollPosition: ( nativeElementReference: unknown /* NativeElementReference */, ) => ReadonlyArray /* [scrollLeft: number, scrollTop: number] */; - +getScrollSize: ( + readonly getScrollSize: ( nativeElementReference: unknown /* NativeElementReference */, ) => ReadonlyArray /* [scrollWidth: number, scrollHeight: number] */; - +getTagName: ( + readonly getTagName: ( nativeElementReference: unknown /* NativeElementReference */, ) => string; - +getTextContent: ( + readonly getTextContent: ( nativeElementReference: unknown /* NativeElementReference */, ) => string; - +hasPointerCapture: ( + readonly hasPointerCapture: ( nativeElementReference: unknown /* NativeElementReference */, pointerId: number, ) => boolean; - +releasePointerCapture: ( + readonly releasePointerCapture: ( nativeElementReference: unknown /* NativeElementReference */, pointerId: number, ) => void; - +setPointerCapture: ( + readonly setPointerCapture: ( nativeElementReference: unknown /* NativeElementReference */, pointerId: number, ) => void; @@ -125,7 +125,7 @@ export interface Spec extends TurboModule { * Methods from the `HTMLElement` interface (for `ReactNativeElement`). */ - +getOffset: ( + readonly getOffset: ( nativeElementReference: unknown /* NativeElementReference */, ) => ReadonlyArray /* [offsetParent: ?InstanceHandle, top: number, left: number] */; @@ -133,7 +133,7 @@ export interface Spec extends TurboModule { * Special methods to handle the root node. */ - +linkRootNode?: ( + readonly linkRootNode?: ( rootTag: number /* RootTag */, instanceHandle: unknown /* InstanceHandle */, ) => unknown /* ?NativeElementReference */; @@ -142,17 +142,17 @@ export interface Spec extends TurboModule { * Legacy layout APIs (for `ReactNativeElement`). */ - +measure: ( + readonly measure: ( nativeElementReference: unknown, callback: MeasureOnSuccessCallback, ) => void; - +measureInWindow: ( + readonly measureInWindow: ( nativeElementReference: unknown, callback: MeasureInWindowOnSuccessCallback, ) => void; - +measureLayout: ( + readonly measureLayout: ( nativeElementReference: unknown, relativeNode: unknown, onFail: () => void, @@ -163,7 +163,7 @@ export interface Spec extends TurboModule { * Legacy direct manipulation APIs (for `ReactNativeElement`). */ - +setNativeProps: ( + readonly setNativeProps: ( nativeElementReference: unknown, updatePayload: unknown, ) => void; @@ -184,7 +184,7 @@ export interface RefinedSpec { * revision of the shadow tree (if any). If any of the nodes is not present, * it just indicates they are disconnected. */ - +compareDocumentPosition: ( + readonly compareDocumentPosition: ( nativeNodeReference: NativeNodeReference, otherNativeNodeReference: NativeNodeReference, ) => number; @@ -197,7 +197,7 @@ export interface RefinedSpec { * of an active shadow tree, it returns an array of instance handles of its * children. Otherwise, it returns an empty array. */ - +getChildNodes: ( + readonly getChildNodes: ( nativeNodeReference: NativeNodeReference, ) => ReadonlyArray; @@ -208,7 +208,7 @@ export interface RefinedSpec { * If the document is active and contains an element with the given ID, it * returns the instance handle of that element. Otherwise, it returns `null`. */ - +getElementById: (rootTag: RootTag, id: string) => ?InstanceHandle; + readonly getElementById: (rootTag: RootTag, id: string) => ?InstanceHandle; /** * This is a React Native implementation of `Node.prototype.parentNode` @@ -218,7 +218,9 @@ export interface RefinedSpec { * an active shadow tree, it returns the instance handle of its parent. * Otherwise, it returns `null`. */ - +getParentNode: (nativeNodeReference: NativeNodeReference) => ?InstanceHandle; + readonly getParentNode: ( + nativeNodeReference: NativeNodeReference, + ) => ?InstanceHandle; /** * This is a React Native implementation of `Node.prototype.isConnected` @@ -227,7 +229,7 @@ export interface RefinedSpec { * Indicates whether a version of the given shadow node is present in the * current revision of an active shadow tree. */ - +isConnected: (nativeNodeReference: NativeNodeReference) => boolean; + readonly isConnected: (nativeNodeReference: NativeNodeReference) => boolean; /* * Methods from the `Element` interface (for `ReactNativeElement`). @@ -245,7 +247,7 @@ export interface RefinedSpec { * it has an inline display, it returns `undefined`. Otherwise, it returns its * border size. */ - +getBorderWidth: ( + readonly getBorderWidth: ( nativeElementReference: NativeElementReference, ) => Readonly< [ @@ -267,7 +269,7 @@ export interface RefinedSpec { * to implement methods like [`offsetWidth`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetWidth) * and [`offsetHeight`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight). */ - +getBoundingClientRect: ( + readonly getBoundingClientRect: ( nativeElementReference: NativeElementReference, includeTransform: boolean, ) => Readonly< @@ -291,7 +293,7 @@ export interface RefinedSpec { * it has an inline display, it returns `undefined`. Otherwise, it returns its * inner size. */ - +getInnerSize: ( + readonly getInnerSize: ( nativeElementReference: NativeElementReference, ) => Readonly<[/* width: */ number, /* height: */ number]>; @@ -306,7 +308,7 @@ export interface RefinedSpec { * (because any of its ancestors or itself have 'display: none'), it returns * `undefined`. Otherwise, it returns the scroll position. */ - +getScrollPosition: ( + readonly getScrollPosition: ( nativeElementReference: NativeElementReference, ) => Readonly<[/* scrollLeft: */ number, /* scrollTop: */ number]>; @@ -322,7 +324,7 @@ export interface RefinedSpec { * (because any of its ancestors or itself have 'display: none'), it returns * `undefined`. Otherwise, it returns the scroll size. */ - +getScrollSize: ( + readonly getScrollSize: ( nativeElementReference: NativeElementReference, ) => Readonly<[/* scrollWidth: */ number, /* scrollHeight: */ number]>; @@ -330,7 +332,9 @@ export interface RefinedSpec { * This is a method to access the normalized tag name of a shadow node, to * implement `Element.prototype.tagName` (see https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName). */ - +getTagName: (nativeElementReference: NativeElementReference) => string; + readonly getTagName: ( + nativeElementReference: NativeElementReference, + ) => string; /** * This is a React Native implementation of `Element.prototype.textContent` @@ -344,19 +348,19 @@ export interface RefinedSpec { * This is also used to access the text content of text nodes, which does not * need any traversal. */ - +getTextContent: (nativeNodeReference: NativeNodeReference) => string; + readonly getTextContent: (nativeNodeReference: NativeNodeReference) => string; - +hasPointerCapture: ( + readonly hasPointerCapture: ( nativeElementReference: NativeElementReference, pointerId: number, ) => boolean; - +releasePointerCapture: ( + readonly releasePointerCapture: ( nativeElementReference: NativeElementReference, pointerId: number, ) => void; - +setPointerCapture: ( + readonly setPointerCapture: ( nativeElementReference: NativeElementReference, pointerId: number, ) => void; @@ -375,7 +379,7 @@ export interface RefinedSpec { * React Native are currently "positioned") and its offset relative to its * parent. */ - +getOffset: ( + readonly getOffset: ( nativeElementReference: NativeElementReference, ) => Readonly< [ @@ -403,7 +407,7 @@ export interface RefinedSpec { * * Returns a shadow node representing the root node if it is still mounted. */ - +linkRootNode: ( + readonly linkRootNode: ( rootTag: RootTag, instanceHandle: InstanceHandle, ) => ?NativeElementReference; @@ -412,17 +416,17 @@ export interface RefinedSpec { * Legacy layout APIs */ - +measure: ( + readonly measure: ( nativeElementReference: NativeElementReference, callback: MeasureOnSuccessCallback, ) => void; - +measureInWindow: ( + readonly measureInWindow: ( nativeElementReference: NativeElementReference, callback: MeasureInWindowOnSuccessCallback, ) => void; - +measureLayout: ( + readonly measureLayout: ( nativeElementReference: NativeElementReference, relativeNode: NativeElementReference, onFail: () => void, @@ -432,7 +436,7 @@ export interface RefinedSpec { /** * Legacy direct manipulation APIs */ - +setNativeProps: ( + readonly setNativeProps: ( nativeElementReference: NativeElementReference, updatePayload: {...}, ) => void; diff --git a/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js.flow b/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js.flow index 45715ab40884..409e61757f71 100644 --- a/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js.flow +++ b/packages/react-native/src/private/webapis/dom/oldstylecollections/HTMLCollection.js.flow @@ -18,7 +18,7 @@ declare export default class HTMLCollection // read-only indexers correctly (thinks reads are writes and fails). // $FlowFixMe[incompatible-variance] [index: number]: T; - +length: number; + readonly length: number; item(index: number): T | null; namedItem(name: string): T | null; @@iterator(): Iterator; diff --git a/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js.flow b/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js.flow index 91e4bd877ef4..48195f45fa34 100644 --- a/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js.flow +++ b/packages/react-native/src/private/webapis/dom/oldstylecollections/NodeList.js.flow @@ -18,7 +18,7 @@ declare export default class NodeList // read-only indexers correctly (thinks reads are writes and fails). // $FlowFixMe[incompatible-variance] [index: number]: T; - +length: number; + readonly length: number; item(index: number): T | null; // $FlowFixMe[incompatible-variance] entries(): Iterator<[number, T]>; diff --git a/packages/react-native/src/private/webapis/errors/DOMException.js b/packages/react-native/src/private/webapis/errors/DOMException.js index b759632d0a9e..e2b6d37b998c 100644 --- a/packages/react-native/src/private/webapis/errors/DOMException.js +++ b/packages/react-native/src/private/webapis/errors/DOMException.js @@ -73,57 +73,57 @@ const ERROR_CODES: {[string]: number} = { /* eslint-disable @react-native/monorepo/require-extends-error */ // $FlowExpectedError[incompatible-variance] name is writable in Error but not in DOMException, but this is how it works on Web. export default class DOMException extends Error { - static +INDEX_SIZE_ERR: 1; - static +DOMSTRING_SIZE_ERR: 2; - static +HIERARCHY_REQUEST_ERR: 3; - static +WRONG_DOCUMENT_ERR: 4; - static +INVALID_CHARACTER_ERR: 5; - static +NO_DATA_ALLOWED_ERR: 6; - static +NO_MODIFICATION_ALLOWED_ERR: 7; - static +NOT_FOUND_ERR: 8; - static +NOT_SUPPORTED_ERR: 9; - static +INUSE_ATTRIBUTE_ERR: 10; - static +INVALID_STATE_ERR: 11; - static +SYNTAX_ERR: 12; - static +INVALID_MODIFICATION_ERR: 13; - static +NAMESPACE_ERR: 14; - static +INVALID_ACCESS_ERR: 15; - static +VALIDATION_ERR: 16; - static +TYPE_MISMATCH_ERR: 17; - static +SECURITY_ERR: 18; - static +NETWORK_ERR: 19; - static +ABORT_ERR: 20; - static +URL_MISMATCH_ERR: 21; - static +QUOTA_EXCEEDED_ERR: 22; - static +TIMEOUT_ERR: 23; - static +INVALID_NODE_TYPE_ERR: 24; - static +DATA_CLONE_ERR: 25; + static readonly INDEX_SIZE_ERR: 1; + static readonly DOMSTRING_SIZE_ERR: 2; + static readonly HIERARCHY_REQUEST_ERR: 3; + static readonly WRONG_DOCUMENT_ERR: 4; + static readonly INVALID_CHARACTER_ERR: 5; + static readonly NO_DATA_ALLOWED_ERR: 6; + static readonly NO_MODIFICATION_ALLOWED_ERR: 7; + static readonly NOT_FOUND_ERR: 8; + static readonly NOT_SUPPORTED_ERR: 9; + static readonly INUSE_ATTRIBUTE_ERR: 10; + static readonly INVALID_STATE_ERR: 11; + static readonly SYNTAX_ERR: 12; + static readonly INVALID_MODIFICATION_ERR: 13; + static readonly NAMESPACE_ERR: 14; + static readonly INVALID_ACCESS_ERR: 15; + static readonly VALIDATION_ERR: 16; + static readonly TYPE_MISMATCH_ERR: 17; + static readonly SECURITY_ERR: 18; + static readonly NETWORK_ERR: 19; + static readonly ABORT_ERR: 20; + static readonly URL_MISMATCH_ERR: 21; + static readonly QUOTA_EXCEEDED_ERR: 22; + static readonly TIMEOUT_ERR: 23; + static readonly INVALID_NODE_TYPE_ERR: 24; + static readonly DATA_CLONE_ERR: 25; - +INDEX_SIZE_ERR: 1; - +DOMSTRING_SIZE_ERR: 2; - +HIERARCHY_REQUEST_ERR: 3; - +WRONG_DOCUMENT_ERR: 4; - +INVALID_CHARACTER_ERR: 5; - +NO_DATA_ALLOWED_ERR: 6; - +NO_MODIFICATION_ALLOWED_ERR: 7; - +NOT_FOUND_ERR: 8; - +NOT_SUPPORTED_ERR: 9; - +INUSE_ATTRIBUTE_ERR: 10; - +INVALID_STATE_ERR: 11; - +SYNTAX_ERR: 12; - +INVALID_MODIFICATION_ERR: 13; - +NAMESPACE_ERR: 14; - +INVALID_ACCESS_ERR: 15; - +VALIDATION_ERR: 16; - +TYPE_MISMATCH_ERR: 17; - +SECURITY_ERR: 18; - +NETWORK_ERR: 19; - +ABORT_ERR: 20; - +URL_MISMATCH_ERR: 21; - +QUOTA_EXCEEDED_ERR: 22; - +TIMEOUT_ERR: 23; - +INVALID_NODE_TYPE_ERR: 24; - +DATA_CLONE_ERR: 25; + readonly INDEX_SIZE_ERR: 1; + readonly DOMSTRING_SIZE_ERR: 2; + readonly HIERARCHY_REQUEST_ERR: 3; + readonly WRONG_DOCUMENT_ERR: 4; + readonly INVALID_CHARACTER_ERR: 5; + readonly NO_DATA_ALLOWED_ERR: 6; + readonly NO_MODIFICATION_ALLOWED_ERR: 7; + readonly NOT_FOUND_ERR: 8; + readonly NOT_SUPPORTED_ERR: 9; + readonly INUSE_ATTRIBUTE_ERR: 10; + readonly INVALID_STATE_ERR: 11; + readonly SYNTAX_ERR: 12; + readonly INVALID_MODIFICATION_ERR: 13; + readonly NAMESPACE_ERR: 14; + readonly INVALID_ACCESS_ERR: 15; + readonly VALIDATION_ERR: 16; + readonly TYPE_MISMATCH_ERR: 17; + readonly SECURITY_ERR: 18; + readonly NETWORK_ERR: 19; + readonly ABORT_ERR: 20; + readonly URL_MISMATCH_ERR: 21; + readonly QUOTA_EXCEEDED_ERR: 22; + readonly TIMEOUT_ERR: 23; + readonly INVALID_NODE_TYPE_ERR: 24; + readonly DATA_CLONE_ERR: 25; #name: string; #code: number; diff --git a/packages/react-native/src/private/webapis/geometry/DOMRectList.js.flow b/packages/react-native/src/private/webapis/geometry/DOMRectList.js.flow index 1e31dc9093c8..82fb2528d913 100644 --- a/packages/react-native/src/private/webapis/geometry/DOMRectList.js.flow +++ b/packages/react-native/src/private/webapis/geometry/DOMRectList.js.flow @@ -17,7 +17,7 @@ declare export default class DOMRectList // This property should've been read-only as well, but Flow doesn't handle // read-only indexers correctly (thinks reads are writes and fails). [index: number]: DOMRectReadOnly; - +length: number; + readonly length: number; item(index: number): DOMRectReadOnly | null; @@iterator(): Iterator; } diff --git a/packages/react-native/src/private/webapis/html/events/MessageEvent.js b/packages/react-native/src/private/webapis/html/events/MessageEvent.js index 57bca029b842..45407b217f52 100644 --- a/packages/react-native/src/private/webapis/html/events/MessageEvent.js +++ b/packages/react-native/src/private/webapis/html/events/MessageEvent.js @@ -20,9 +20,9 @@ import type {EventInit} from '../../dom/events/Event'; import Event from '../../dom/events/Event'; export interface MessageEventInit extends EventInit { - +data?: unknown; - +origin?: string; - +lastEventId?: string; + readonly data?: unknown; + readonly origin?: string; + readonly lastEventId?: string; // Unsupported // +source?: MessageEventSource, // Unsupported diff --git a/packages/react-native/src/private/webapis/idlecallbacks/__tests__/requestIdleCallback-itest.js b/packages/react-native/src/private/webapis/idlecallbacks/__tests__/requestIdleCallback-itest.js index 091277662082..df557af3b7a1 100644 --- a/packages/react-native/src/private/webapis/idlecallbacks/__tests__/requestIdleCallback-itest.js +++ b/packages/react-native/src/private/webapis/idlecallbacks/__tests__/requestIdleCallback-itest.js @@ -13,8 +13,8 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; import * as Fantom from '@react-native/fantom'; interface IdleDeadline { - +didTimeout: boolean; - +timeRemaining: () => number; + readonly didTimeout: boolean; + readonly timeRemaining: () => number; } function activeSleep(timeMs: number): void { diff --git a/packages/react-native/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js b/packages/react-native/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js index 84b36e88ab6c..6ebf580b5438 100644 --- a/packages/react-native/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +++ b/packages/react-native/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js @@ -24,11 +24,11 @@ export type IdleDeadline = { }; export interface Spec extends TurboModule { - +requestIdleCallback: ( + readonly requestIdleCallback: ( callback: (idleDeadline: IdleDeadline) => unknown, options?: RequestIdleCallbackOptions, ) => IdleCallbackID; - +cancelIdleCallback: (handle: IdleCallbackID) => void; + readonly cancelIdleCallback: (handle: IdleCallbackID) => void; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js b/packages/react-native/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js index f2fd6f171a5a..56931369a35e 100644 --- a/packages/react-native/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +++ b/packages/react-native/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js @@ -35,16 +35,16 @@ export type NativeIntersectionObserverObserveOptions = { export opaque type NativeIntersectionObserverToken = unknown; export interface Spec extends TurboModule { - +observeV2?: ( + readonly observeV2?: ( options: NativeIntersectionObserverObserveOptions, ) => NativeIntersectionObserverToken; - +unobserveV2?: ( + readonly unobserveV2?: ( intersectionObserverId: number, token: NativeIntersectionObserverToken, ) => void; - +connect: (notifyIntersectionObserversCallback: () => void) => void; - +disconnect: () => void; - +takeRecords: () => ReadonlyArray; + readonly connect: (notifyIntersectionObserversCallback: () => void) => void; + readonly disconnect: () => void; + readonly takeRecords: () => ReadonlyArray; } export default TurboModuleRegistry.get( diff --git a/packages/react-native/src/private/webapis/microtasks/specs/NativeMicrotasks.js b/packages/react-native/src/private/webapis/microtasks/specs/NativeMicrotasks.js index 1f742d3053c5..2c37b1513567 100644 --- a/packages/react-native/src/private/webapis/microtasks/specs/NativeMicrotasks.js +++ b/packages/react-native/src/private/webapis/microtasks/specs/NativeMicrotasks.js @@ -13,7 +13,7 @@ import type {TurboModule} from '../../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../../Libraries/TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { - +queueMicrotask: (callback: () => unknown) => void; + readonly queueMicrotask: (callback: () => unknown) => void; } export default TurboModuleRegistry.getEnforcing( diff --git a/packages/react-native/src/private/webapis/mutationobserver/MutationObserver.js b/packages/react-native/src/private/webapis/mutationobserver/MutationObserver.js index 9917c88a7a98..a076b838251b 100644 --- a/packages/react-native/src/private/webapis/mutationobserver/MutationObserver.js +++ b/packages/react-native/src/private/webapis/mutationobserver/MutationObserver.js @@ -23,16 +23,16 @@ export type MutationObserverCallback = ( ) => unknown; export interface MutationObserverInit { - +subtree?: boolean; + readonly subtree?: boolean; // This is the only supported option so it's required to be `true`. - +childList: true; + readonly childList: true; // Unsupported: - +attributes?: boolean; - +attributeFilter?: ReadonlyArray; - +attributeOldValue?: boolean; - +characterData?: boolean; - +characterDataOldValue?: boolean; + readonly attributes?: boolean; + readonly attributeFilter?: ReadonlyArray; + readonly attributeOldValue?: boolean; + readonly characterData?: boolean; + readonly characterDataOldValue?: boolean; } /** diff --git a/packages/react-native/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js b/packages/react-native/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js index 62c92ba5aed2..5ac754252c15 100644 --- a/packages/react-native/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +++ b/packages/react-native/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js @@ -35,9 +35,9 @@ export type NativeMutationObserverObserveOptions = { }; export interface Spec extends TurboModule { - +observe: (options: NativeMutationObserverObserveOptions) => void; - +unobserveAll: (mutationObserverId: number) => void; - +connect: ( + readonly observe: (options: NativeMutationObserverObserveOptions) => void; + readonly unobserveAll: (mutationObserverId: number) => void; + readonly connect: ( notifyMutationObservers: () => void, // We need this to retain the public instance before React removes the // reference to it (which happen in mutations that remove nodes, or when @@ -46,8 +46,8 @@ export interface Spec extends TurboModule { instanceHandle: InstanceHandle, ) => ReadOnlyNode, ) => void; - +disconnect: () => void; - +takeRecords: () => ReadonlyArray; + readonly disconnect: () => void; + readonly takeRecords: () => ReadonlyArray; } export default TurboModuleRegistry.get( diff --git a/packages/react-native/src/private/webapis/performance/EventTiming.js b/packages/react-native/src/private/webapis/performance/EventTiming.js index 0748ef6f6b23..c175f8592f18 100644 --- a/packages/react-native/src/private/webapis/performance/EventTiming.js +++ b/packages/react-native/src/private/webapis/performance/EventTiming.js @@ -30,9 +30,9 @@ export type PerformanceEventTimingJSON = { }; export interface PerformanceEventTimingInit extends PerformanceEntryInit { - +processingStart?: DOMHighResTimeStamp; - +processingEnd?: DOMHighResTimeStamp; - +interactionId?: number; + readonly processingStart?: DOMHighResTimeStamp; + readonly processingEnd?: DOMHighResTimeStamp; + readonly interactionId?: number; } export class PerformanceEventTiming extends PerformanceEntry { diff --git a/packages/react-native/src/private/webapis/performance/PerformanceEntry.js b/packages/react-native/src/private/webapis/performance/PerformanceEntry.js index 550f6b8ff8bd..9e4fa32fe455 100644 --- a/packages/react-native/src/private/webapis/performance/PerformanceEntry.js +++ b/packages/react-native/src/private/webapis/performance/PerformanceEntry.js @@ -29,9 +29,9 @@ export type PerformanceEntryJSON = { }; export interface PerformanceEntryInit { - +name: string; - +startTime: DOMHighResTimeStamp; - +duration: DOMHighResTimeStamp; + readonly name: string; + readonly startTime: DOMHighResTimeStamp; + readonly duration: DOMHighResTimeStamp; } export class PerformanceEntry { diff --git a/packages/react-native/src/private/webapis/performance/PerformanceObserver.js b/packages/react-native/src/private/webapis/performance/PerformanceObserver.js index c1b2a47a0ba9..b66e7f406614 100644 --- a/packages/react-native/src/private/webapis/performance/PerformanceObserver.js +++ b/packages/react-native/src/private/webapis/performance/PerformanceObserver.js @@ -82,10 +82,10 @@ export type PerformanceObserverCallback = ( ) => void; export interface PerformanceObserverInit { - +entryTypes?: Array; - +type?: PerformanceEntryType; - +buffered?: boolean; - +durationThreshold?: DOMHighResTimeStamp; + readonly entryTypes?: Array; + readonly type?: PerformanceEntryType; + readonly buffered?: boolean; + readonly durationThreshold?: DOMHighResTimeStamp; } function getSupportedPerformanceEntryTypes(): ReadonlyArray { diff --git a/packages/react-native/src/private/webapis/performance/ResourceTiming.js b/packages/react-native/src/private/webapis/performance/ResourceTiming.js index 4154ca155b4d..08a282666244 100644 --- a/packages/react-native/src/private/webapis/performance/ResourceTiming.js +++ b/packages/react-native/src/private/webapis/performance/ResourceTiming.js @@ -33,19 +33,19 @@ export type PerformanceResourceTimingJSON = { }; export interface PerformanceResourceTimingInit { - +name: string; - +startTime: DOMHighResTimeStamp; - +duration: DOMHighResTimeStamp; - +fetchStart: DOMHighResTimeStamp; - +requestStart: DOMHighResTimeStamp; - +connectStart: DOMHighResTimeStamp; - +connectEnd: DOMHighResTimeStamp; - +responseStart: DOMHighResTimeStamp; - +responseEnd: DOMHighResTimeStamp; - +responseStatus: number; - +contentType: string; - +encodedBodySize: number; - +decodedBodySize: number; + readonly name: string; + readonly startTime: DOMHighResTimeStamp; + readonly duration: DOMHighResTimeStamp; + readonly fetchStart: DOMHighResTimeStamp; + readonly requestStart: DOMHighResTimeStamp; + readonly connectStart: DOMHighResTimeStamp; + readonly connectEnd: DOMHighResTimeStamp; + readonly responseStart: DOMHighResTimeStamp; + readonly responseEnd: DOMHighResTimeStamp; + readonly responseStatus: number; + readonly contentType: string; + readonly encodedBodySize: number; + readonly decodedBodySize: number; } export class PerformanceResourceTiming extends PerformanceEntry { diff --git a/packages/react-native/src/private/webapis/performance/UserTiming.js b/packages/react-native/src/private/webapis/performance/UserTiming.js index f7c8c7e359e1..ff8786083194 100644 --- a/packages/react-native/src/private/webapis/performance/UserTiming.js +++ b/packages/react-native/src/private/webapis/performance/UserTiming.js @@ -28,14 +28,14 @@ export type DetailType = | {devtools?: ExtensionMarkerPayload | ExtensionTrackEntryPayload, ...}; export interface PerformanceMarkOptions { - +detail?: DetailType; - +startTime?: DOMHighResTimeStamp; + readonly detail?: DetailType; + readonly startTime?: DOMHighResTimeStamp; } export type TimeStampOrName = DOMHighResTimeStamp | string; export interface PerformanceMeasureInit extends PerformanceEntryInit { - +detail?: DetailType; + readonly detail?: DetailType; } class PerformanceMarkTemplate extends PerformanceEntry { diff --git a/packages/react-native/src/private/webapis/performance/internals/Utilities.js b/packages/react-native/src/private/webapis/performance/internals/Utilities.js index 9ee6ba1573f4..929afbe51282 100644 --- a/packages/react-native/src/private/webapis/performance/internals/Utilities.js +++ b/packages/react-native/src/private/webapis/performance/internals/Utilities.js @@ -20,7 +20,7 @@ export function warnNoNativePerformance() { declare var global: { // This value is defined directly via JSI, if available. - +nativePerformanceNow?: ?() => number, + readonly nativePerformanceNow?: ?() => number, }; export const getCurrentTimeStamp: () => DOMHighResTimeStamp = diff --git a/packages/react-native/src/private/webapis/performance/specs/NativePerformance.js b/packages/react-native/src/private/webapis/performance/specs/NativePerformance.js index ccbb4c0e58a3..11e73d19d531 100644 --- a/packages/react-native/src/private/webapis/performance/specs/NativePerformance.js +++ b/packages/react-native/src/private/webapis/performance/specs/NativePerformance.js @@ -56,49 +56,55 @@ export type PerformanceObserverInit = { }; export interface Spec extends TurboModule { - +now: () => number; - +timeOrigin?: () => number; + readonly now: () => number; + readonly timeOrigin?: () => number; - +reportMark: (name: string, startTime: number, entry: unknown) => void; - +reportMeasure: ( + readonly reportMark: ( + name: string, + startTime: number, + entry: unknown, + ) => void; + readonly reportMeasure: ( name: string, startTime: number, duration: number, entry: unknown, ) => void; - +getMarkTime: (name: string) => ?number; - +clearMarks: (entryName?: string) => void; - +clearMeasures: (entryName?: string) => void; - +getEntries: () => ReadonlyArray; - +getEntriesByName: ( + readonly getMarkTime: (name: string) => ?number; + readonly clearMarks: (entryName?: string) => void; + readonly clearMeasures: (entryName?: string) => void; + readonly getEntries: () => ReadonlyArray; + readonly getEntriesByName: ( entryName: string, entryType?: ?RawPerformanceEntryType, ) => ReadonlyArray; - +getEntriesByType: ( + readonly getEntriesByType: ( entryType: RawPerformanceEntryType, ) => ReadonlyArray; - +getEventCounts: () => ReadonlyArray<[string, number]>; - +getSimpleMemoryInfo: () => NativeMemoryInfo; - +getReactNativeStartupTiming: () => ReactNativeStartupTiming; + readonly getEventCounts: () => ReadonlyArray<[string, number]>; + readonly getSimpleMemoryInfo: () => NativeMemoryInfo; + readonly getReactNativeStartupTiming: () => ReactNativeStartupTiming; - +createObserver: ( + readonly createObserver: ( callback: NativeBatchedObserverCallback, ) => OpaqueNativeObserverHandle; - +getDroppedEntriesCount: (observer: OpaqueNativeObserverHandle) => number; + readonly getDroppedEntriesCount: ( + observer: OpaqueNativeObserverHandle, + ) => number; - +observe: ( + readonly observe: ( observer: OpaqueNativeObserverHandle, options: PerformanceObserverInit, ) => void; - +disconnect: (observer: OpaqueNativeObserverHandle) => void; - +takeRecords: ( + readonly disconnect: (observer: OpaqueNativeObserverHandle) => void; + readonly takeRecords: ( observer: OpaqueNativeObserverHandle, sort: boolean, ) => ReadonlyArray; - +getSupportedPerformanceEntryTypes: () => ReadonlyArray; + readonly getSupportedPerformanceEntryTypes: () => ReadonlyArray; - +clearEventCountsForTesting: () => void; + readonly clearEventCountsForTesting: () => void; } export default TurboModuleRegistry.get('NativePerformanceCxx') as ?Spec; diff --git a/packages/react-native/src/private/webapis/utils/ArrayLikeUtils.js b/packages/react-native/src/private/webapis/utils/ArrayLikeUtils.js index fc34a1bf6189..d4e08726dd1e 100644 --- a/packages/react-native/src/private/webapis/utils/ArrayLikeUtils.js +++ b/packages/react-native/src/private/webapis/utils/ArrayLikeUtils.js @@ -20,7 +20,7 @@ export interface ArrayLike extends Iterable { // This property should've been read-only as well, but Flow doesn't handle // read-only indexers correctly (thinks reads are writes and fails). [indexer: number]: T; - +length: number; + readonly length: number; } export function* createValueIterator(arrayLike: ArrayLike): Iterator { diff --git a/packages/react-native/src/private/webapis/websockets/events/CloseEvent.js b/packages/react-native/src/private/webapis/websockets/events/CloseEvent.js index 2cbd6b4d4667..150127f3255f 100644 --- a/packages/react-native/src/private/webapis/websockets/events/CloseEvent.js +++ b/packages/react-native/src/private/webapis/websockets/events/CloseEvent.js @@ -20,9 +20,9 @@ import type {EventInit} from '../../dom/events/Event'; import Event from '../../dom/events/Event'; export interface CloseEventInit extends EventInit { - +wasClean?: boolean; - +code?: number; - +reason?: string; + readonly wasClean?: boolean; + readonly code?: number; + readonly reason?: string; } export default class CloseEvent extends Event { diff --git a/packages/react-native/src/private/webapis/xhr/events/ProgressEvent.js b/packages/react-native/src/private/webapis/xhr/events/ProgressEvent.js index 1fe4ffb9b382..aa85eb28e262 100644 --- a/packages/react-native/src/private/webapis/xhr/events/ProgressEvent.js +++ b/packages/react-native/src/private/webapis/xhr/events/ProgressEvent.js @@ -20,9 +20,9 @@ import type {EventInit} from '../../dom/events/Event'; import Event from '../../dom/events/Event'; export interface ProgressEventInit extends EventInit { - +lengthComputable: boolean; - +loaded: number; - +total: number; + readonly lengthComputable: boolean; + readonly loaded: number; + readonly total: number; } export default class ProgressEvent extends Event { diff --git a/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js b/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js index b5fbf11f8e4f..dc2026366e7a 100644 --- a/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js +++ b/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js @@ -44,21 +44,23 @@ type NativeProps = Readonly<{ export type MyNativeViewType = HostComponent; interface NativeCommands { - +callNativeMethodToChangeBackgroundColor: ( + readonly callNativeMethodToChangeBackgroundColor: ( viewRef: React.ElementRef, color: string, ) => void; - +callNativeMethodToAddOverlays: ( + readonly callNativeMethodToAddOverlays: ( viewRef: React.ElementRef, overlayColors: ReadonlyArray, ) => void; - +callNativeMethodToRemoveOverlays: ( + readonly callNativeMethodToRemoveOverlays: ( viewRef: React.ElementRef, ) => void; - +fireLagacyStyleEvent: (viewRef: React.ElementRef) => void; + readonly fireLagacyStyleEvent: ( + viewRef: React.ElementRef, + ) => void; } export const Commands: NativeCommands = codegenNativeCommands({ diff --git a/packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.js b/packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.js index 98871660f361..4524a1b3e2b4 100644 --- a/packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.js +++ b/packages/rn-tester/NativeCxxModuleExample/NativeCxxModuleExample.js @@ -76,48 +76,52 @@ export type CustomDeviceEvent = { }; export interface Spec extends TurboModule { - +onPress: CodegenTypes.EventEmitter; - +onClick: CodegenTypes.EventEmitter; - +onChange: CodegenTypes.EventEmitter; - +onSubmit: CodegenTypes.EventEmitter; - +onEvent: CodegenTypes.EventEmitter; - +getArray: (arg: Array) => Array; - +getArrayBuffer: (payload: ArrayBuffer) => ArrayBuffer; - +createNativeBuffer: (size: number) => ArrayBuffer; - +processAsyncBuffer: (payload: ArrayBuffer) => Promise; - +getAsyncBuffer: (size: number) => Promise; - +getBool: (arg: boolean) => boolean; - +getConstants: () => ConstantsStruct; - +getCustomEnum: (arg: EnumInt) => EnumInt; - +getCustomHostObject: () => CustomHostObject; - +consumeCustomHostObject: (customHostObject: CustomHostObject) => string; - +getBinaryTreeNode: (arg: BinaryTreeNode) => BinaryTreeNode; - +getGraphNode: (arg: GraphNode) => GraphNode; - +getNumEnum: (arg: EnumInt) => EnumInt; - +getStrEnum: (arg: EnumNone) => EnumStr; - +getMap: (arg: {[key: string]: ?number}) => {[key: string]: ?number}; - +getNumber: (arg: number) => number; - +getObject: (arg: ObjectStruct) => ObjectStruct; - +getSet: (arg: Array) => Array; - +getString: (arg: string) => string; - +getUnion: (x: UnionFloat, y: UnionString, z: UnionObject) => string; - +getValue: (x: number, y: string, z: ObjectStruct) => ValueStruct; - +getValueWithCallback: (callback: (value: string) => void) => void; - +setValueCallbackWithSubscription: ( + readonly onPress: CodegenTypes.EventEmitter; + readonly onClick: CodegenTypes.EventEmitter; + readonly onChange: CodegenTypes.EventEmitter; + readonly onSubmit: CodegenTypes.EventEmitter; + readonly onEvent: CodegenTypes.EventEmitter; + readonly getArray: ( + arg: Array, + ) => Array; + readonly getArrayBuffer: (payload: ArrayBuffer) => ArrayBuffer; + readonly createNativeBuffer: (size: number) => ArrayBuffer; + readonly processAsyncBuffer: (payload: ArrayBuffer) => Promise; + readonly getAsyncBuffer: (size: number) => Promise; + readonly getBool: (arg: boolean) => boolean; + readonly getConstants: () => ConstantsStruct; + readonly getCustomEnum: (arg: EnumInt) => EnumInt; + readonly getCustomHostObject: () => CustomHostObject; + readonly consumeCustomHostObject: ( + customHostObject: CustomHostObject, + ) => string; + readonly getBinaryTreeNode: (arg: BinaryTreeNode) => BinaryTreeNode; + readonly getGraphNode: (arg: GraphNode) => GraphNode; + readonly getNumEnum: (arg: EnumInt) => EnumInt; + readonly getStrEnum: (arg: EnumNone) => EnumStr; + readonly getMap: (arg: {[key: string]: ?number}) => {[key: string]: ?number}; + readonly getNumber: (arg: number) => number; + readonly getObject: (arg: ObjectStruct) => ObjectStruct; + readonly getSet: (arg: Array) => Array; + readonly getString: (arg: string) => string; + readonly getUnion: (x: UnionFloat, y: UnionString, z: UnionObject) => string; + readonly getValue: (x: number, y: string, z: ObjectStruct) => ValueStruct; + readonly getValueWithCallback: (callback: (value: string) => void) => void; + readonly setValueCallbackWithSubscription: ( callback: (value: string) => void, ) => () => void; - +getValueWithPromise: (error: boolean) => Promise; - +getWithWithOptionalArgs: (optionalArg?: boolean) => ?boolean; - +voidFunc: () => void; - +voidPromise: () => Promise; - +setMenu: (menuItem: MenuItem) => void; - +emitCustomDeviceEvent: (eventName: string) => void; - +voidFuncThrows: () => void; - +getObjectThrows: (arg: ObjectStruct) => ObjectStruct; - +promiseThrows: () => Promise; - +voidFuncAssert: () => void; - +getObjectAssert: (arg: ObjectStruct) => ObjectStruct; - +promiseAssert: () => Promise; + readonly getValueWithPromise: (error: boolean) => Promise; + readonly getWithWithOptionalArgs: (optionalArg?: boolean) => ?boolean; + readonly voidFunc: () => void; + readonly voidPromise: () => Promise; + readonly setMenu: (menuItem: MenuItem) => void; + readonly emitCustomDeviceEvent: (eventName: string) => void; + readonly voidFuncThrows: () => void; + readonly getObjectThrows: (arg: ObjectStruct) => ObjectStruct; + readonly promiseThrows: () => Promise; + readonly voidFuncAssert: () => void; + readonly getObjectAssert: (arg: ObjectStruct) => ObjectStruct; + readonly promiseAssert: () => Promise; } export default TurboModuleRegistry.get( diff --git a/packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js b/packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js index 0f6b0682777a..518bd7bdf604 100644 --- a/packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js +++ b/packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js @@ -15,7 +15,7 @@ import {TurboModuleRegistry} from 'react-native'; export type ScreenshotManagerOptions = CodegenTypes.UnsafeObject; export interface Spec extends TurboModule { - +getConstants: () => {}; + readonly getConstants: () => {}; takeScreenshot( id: string, options: ScreenshotManagerOptions, diff --git a/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestTypes.js b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestTypes.js index a17182b7e4d0..de5ee16441f4 100644 --- a/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestTypes.js +++ b/packages/rn-tester/js/examples/Experimental/PlatformTest/RNTesterPlatformTestTypes.js @@ -66,6 +66,6 @@ export type PlatformTestHarness = Readonly<{ }>; export type PlatformTestComponentBaseProps = { - +harness: PlatformTestHarness, + readonly harness: PlatformTestHarness, ... }; diff --git a/packages/rn-tester/scripts/utils.js b/packages/rn-tester/scripts/utils.js index 331ab247413e..61e194dfdf5f 100644 --- a/packages/rn-tester/scripts/utils.js +++ b/packages/rn-tester/scripts/utils.js @@ -75,7 +75,7 @@ export function observe(result: ExecaPromiseMetaized): TaskResult<{}, string> { type MixedTasks = Task | Task; type Tasks = { - +[label: string]: MixedTasks, + readonly [label: string]: MixedTasks, }; export function run( diff --git a/private/helloworld/lib/cli.js b/private/helloworld/lib/cli.js index 331ab247413e..61e194dfdf5f 100644 --- a/private/helloworld/lib/cli.js +++ b/private/helloworld/lib/cli.js @@ -75,7 +75,7 @@ export function observe(result: ExecaPromiseMetaized): TaskResult<{}, string> { type MixedTasks = Task | Task; type Tasks = { - +[label: string]: MixedTasks, + readonly [label: string]: MixedTasks, }; export function run( diff --git a/private/react-native-fantom/src/Benchmark.js b/private/react-native-fantom/src/Benchmark.js index f93912bc967e..37a8b297ff73 100644 --- a/private/react-native-fantom/src/Benchmark.js +++ b/private/react-native-fantom/src/Benchmark.js @@ -87,7 +87,7 @@ interface TestFunction { } interface SuiteAPI { - +test: TestFunction; + readonly test: TestFunction; verify(fn: (results: SuiteResults) => void): SuiteAPI; } diff --git a/scripts/js-api/build-types/transforms/typescript/simplifyTypes/gatherTypeAliasesVisitor.js b/scripts/js-api/build-types/transforms/typescript/simplifyTypes/gatherTypeAliasesVisitor.js index 1a4fc64c7415..62926f404d5f 100644 --- a/scripts/js-api/build-types/transforms/typescript/simplifyTypes/gatherTypeAliasesVisitor.js +++ b/scripts/js-api/build-types/transforms/typescript/simplifyTypes/gatherTypeAliasesVisitor.js @@ -14,8 +14,8 @@ import type {NodePath, Visitor} from '@babel/traverse'; const t = require('@babel/types'); export type GatherTypeAliasesVisitorState = { - +aliasToPathMap: Map>, - +interfaceToPathMap?: Map>, + readonly aliasToPathMap: Map>, + readonly interfaceToPathMap?: Map>, }; /** diff --git a/scripts/js-api/build-types/transforms/typescript/simplifyTypes/resolveBuiltinType.js b/scripts/js-api/build-types/transforms/typescript/simplifyTypes/resolveBuiltinType.js index b03a8f72e043..032a39992fb5 100644 --- a/scripts/js-api/build-types/transforms/typescript/simplifyTypes/resolveBuiltinType.js +++ b/scripts/js-api/build-types/transforms/typescript/simplifyTypes/resolveBuiltinType.js @@ -21,7 +21,7 @@ const debug = require('debug')('build-types:transforms:inlineTypes'); // TODO: Handle more builtin TS types const builtinTypeResolvers: { - +[K: string]: ( + readonly [K: string]: ( path: NodePath, state: BaseVisitorState, tsTypeResolver?: TSTypeResolver, diff --git a/scripts/js-api/build-types/transforms/typescript/simplifyTypes/resolveTypeOperator.js b/scripts/js-api/build-types/transforms/typescript/simplifyTypes/resolveTypeOperator.js index a048d3ad54b8..129b18bcf83a 100644 --- a/scripts/js-api/build-types/transforms/typescript/simplifyTypes/resolveTypeOperator.js +++ b/scripts/js-api/build-types/transforms/typescript/simplifyTypes/resolveTypeOperator.js @@ -18,7 +18,7 @@ const t = require('@babel/types'); const debug = require('debug')('build-types:transforms:inlineTypes'); const typeOperatorResolvers: { - +[K: string]: ( + readonly [K: string]: ( path: NodePath, state: BaseVisitorState, ) => void, diff --git a/scripts/releases/utils/octokit-utils.js b/scripts/releases/utils/octokit-utils.js index 74794523b310..228699d99189 100644 --- a/scripts/releases/utils/octokit-utils.js +++ b/scripts/releases/utils/octokit-utils.js @@ -13,7 +13,7 @@ // An interface shaped like a subset of the Octokit class from `@octokit/rest`. // Used to allow mocking in tests. export interface IOctokit { - +repos: Readonly<{ + readonly repos: Readonly<{ listReleaseAssets: ( params: Readonly<{ owner: string,