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
This commit is contained in:
Marco Wang authored and meta-codesync[bot] committed 2026-01-06 12:08:06 -08:00
1 parent d19efcfae2
commit 625d702fec
1 file changed
+8 -6
@@ -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<mixed>) {
fn = function promiseMethodWrapper(...args: Array<unknown>) {
// 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<mixed>) {
fn = function nonPromiseMethodWrapper(...args: Array<unknown>) {
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);