From 734730df75b3bdddeb5dbe65f4151cc92b988303 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Wed, 4 Dec 2024 11:03:03 -0800 Subject: [PATCH] Re-introduce the deprecated constructor on ReactModuleInfo (#48090) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48090 This alleviates a breaking change on `ReactModuleInfo` constructor. While the ctor was deprecated, we realized that there are more than 250 usages in OSS. We'll need to properly communicate this removal before we do it. Changelog: [Android] [Fixed] - Re-introduce the deprecated constructor on ReactModuleInfo Reviewed By: cipolleschi Differential Revision: D66755541 fbshipit-source-id: 3673d8f2af278d55491cea89f1594d368513e3d8 --- .../ReactAndroid/api/ReactAndroid.api | 1 + .../react/module/model/ReactModuleInfo.kt | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index cf22abbd61213e..a87602943a0b11 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -2956,6 +2956,7 @@ public abstract interface annotation class com/facebook/react/module/annotations public final class com/facebook/react/module/model/ReactModuleInfo { public static final field Companion Lcom/facebook/react/module/model/ReactModuleInfo$Companion; public fun (Ljava/lang/String;Ljava/lang/String;ZZZZ)V + public fun (Ljava/lang/String;Ljava/lang/String;ZZZZZ)V public final fun canOverrideExistingModule ()Z public static final fun classIsTurboModule (Ljava/lang/Class;)Z public final fun className ()Ljava/lang/String; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/module/model/ReactModuleInfo.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/module/model/ReactModuleInfo.kt index 246b2adb68397d..b6cc0d0905eaf3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/module/model/ReactModuleInfo.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/module/model/ReactModuleInfo.kt @@ -21,6 +21,24 @@ public class ReactModuleInfo( public val isCxxModule: Boolean, public val isTurboModule: Boolean ) { + + @Deprecated( + "This constructor is deprecated and will be removed in the future. Use ReactModuleInfo(String, String, boolean, boolean, boolean, boolean)]", + replaceWith = + ReplaceWith( + expression = + "ReactModuleInfo(name, className, canOverrideExistingModule, needsEagerInit, isCxxModule, isTurboModule)"), + level = DeprecationLevel.WARNING) + public constructor( + name: String, + className: String, + canOverrideExistingModule: Boolean, + needsEagerInit: Boolean, + @Suppress("UNUSED_PARAMETER") hasConstants: Boolean, + isCxxModule: Boolean, + isTurboModule: Boolean + ) : this(name, className, canOverrideExistingModule, needsEagerInit, isCxxModule, isTurboModule) + public companion object { /** * Checks if the passed class is a TurboModule. Useful to populate the parameter [isTurboModule]