From 625d702fec0d0aa29953a8152219f9651f490dcd Mon Sep 17 00:00:00 2001 From: Marco Wang Date: Tue, 6 Jan 2026 12:08:06 -0800 Subject: [PATCH] Transform `mixed` to `unknown` in xplat/js (#55048) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55048 Transform leftovers dropped by conflicts Command: ``` js1 flow-runner codemod flow/transformUtilityType --legacy-type='mixed' --format-files=false xplat/js ``` drop-conflicts Reviewed By: SamChou19815 Differential Revision: D90131601 fbshipit-source-id: 6497ce36dfed3b3ebe2706cf90909447b36e397a --- .../Libraries/BatchedBridge/NativeModules.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/react-native/Libraries/BatchedBridge/NativeModules.js b/packages/react-native/Libraries/BatchedBridge/NativeModules.js index ce6e939cfbb..876d5ed1f14 100644 --- a/packages/react-native/Libraries/BatchedBridge/NativeModules.js +++ b/packages/react-native/Libraries/BatchedBridge/NativeModules.js @@ -50,7 +50,7 @@ function genModule( return {name: moduleName}; } - const module: {[string]: mixed} = {}; + const module: {[string]: unknown} = {}; methods && methods.forEach((methodName, methodID) => { const isPromise = @@ -99,7 +99,7 @@ function loadModule(name: string, moduleID: number): ?{...} { function genMethod(moduleID: number, methodID: number, type: MethodType) { let fn = null; if (type === 'promise') { - fn = function promiseMethodWrapper(...args: Array) { + fn = function promiseMethodWrapper(...args: Array) { // In case we reject, capture a useful stack trace here. /* $FlowFixMe[class-object-subtyping] added when improving typing for * this parameters */ @@ -122,7 +122,7 @@ function genMethod(moduleID: number, methodID: number, type: MethodType) { }); }; } else { - fn = function nonPromiseMethodWrapper(...args: Array) { + fn = function nonPromiseMethodWrapper(...args: Array) { const lastArg = args.length > 0 ? args[args.length - 1] : null; const secondLastArg = args.length > 1 ? args[args.length - 2] : null; const hasSuccessCallback = typeof lastArg === 'function'; @@ -133,9 +133,11 @@ function genMethod(moduleID: number, methodID: number, type: MethodType) { 'Cannot have a non-function arg after a function arg.', ); // $FlowFixMe[incompatible-type] - const onSuccess: ?(mixed) => void = hasSuccessCallback ? lastArg : null; - // $FlowFixMe[incompatible-type] - const onFail: ?(mixed) => void = hasErrorCallback ? secondLastArg : null; + const onSuccess: ?(unknown) => void = hasSuccessCallback ? lastArg : null; + const onFail: ?(unknown) => void = hasErrorCallback + ? // $FlowFixMe[incompatible-type] + secondLastArg + : null; // $FlowFixMe[unsafe-addition] const callbackCount = hasSuccessCallback + hasErrorCallback; const newArgs = args.slice(0, args.length - callbackCount);