Skip to content

Commit 625d702

Browse files
marcoww6meta-codesync[bot]
authored andcommitted
Transform mixed to unknown in xplat/js (#55048)
Summary: Pull Request resolved: #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
1 parent d19efcf commit 625d702

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

packages/react-native/Libraries/BatchedBridge/NativeModules.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function genModule(
5050
return {name: moduleName};
5151
}
5252

53-
const module: {[string]: mixed} = {};
53+
const module: {[string]: unknown} = {};
5454
methods &&
5555
methods.forEach((methodName, methodID) => {
5656
const isPromise =
@@ -99,7 +99,7 @@ function loadModule(name: string, moduleID: number): ?{...} {
9999
function genMethod(moduleID: number, methodID: number, type: MethodType) {
100100
let fn = null;
101101
if (type === 'promise') {
102-
fn = function promiseMethodWrapper(...args: Array<mixed>) {
102+
fn = function promiseMethodWrapper(...args: Array<unknown>) {
103103
// In case we reject, capture a useful stack trace here.
104104
/* $FlowFixMe[class-object-subtyping] added when improving typing for
105105
* this parameters */
@@ -122,7 +122,7 @@ function genMethod(moduleID: number, methodID: number, type: MethodType) {
122122
});
123123
};
124124
} else {
125-
fn = function nonPromiseMethodWrapper(...args: Array<mixed>) {
125+
fn = function nonPromiseMethodWrapper(...args: Array<unknown>) {
126126
const lastArg = args.length > 0 ? args[args.length - 1] : null;
127127
const secondLastArg = args.length > 1 ? args[args.length - 2] : null;
128128
const hasSuccessCallback = typeof lastArg === 'function';
@@ -133,9 +133,11 @@ function genMethod(moduleID: number, methodID: number, type: MethodType) {
133133
'Cannot have a non-function arg after a function arg.',
134134
);
135135
// $FlowFixMe[incompatible-type]
136-
const onSuccess: ?(mixed) => void = hasSuccessCallback ? lastArg : null;
137-
// $FlowFixMe[incompatible-type]
138-
const onFail: ?(mixed) => void = hasErrorCallback ? secondLastArg : null;
136+
const onSuccess: ?(unknown) => void = hasSuccessCallback ? lastArg : null;
137+
const onFail: ?(unknown) => void = hasErrorCallback
138+
? // $FlowFixMe[incompatible-type]
139+
secondLastArg
140+
: null;
139141
// $FlowFixMe[unsafe-addition]
140142
const callbackCount = hasSuccessCallback + hasErrorCallback;
141143
const newArgs = args.slice(0, args.length - callbackCount);

0 commit comments

Comments
 (0)