From ca4afe5d3027348bd9fd7e26507037404efb8a46 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Wed, 4 Nov 2026 18:34:52 -0500 Subject: [PATCH] Upgrade Flow in fbsource Summary: Changelog: [Internal] Reviewed By: panagosg7 Differential Revision: D129627765 Pull Request resolved: https://github.com/react/react-native/pull/59803 --- packages/community-cli-plugin/src/utils/errors.js | 3 ++- .../dev-middleware/src/inspector-proxy/DeviceEventReporter.js | 1 + packages/react-native/Libraries/Core/ExceptionsManager.js | 1 + packages/react-native/Libraries/Utilities/logError.js | 1 + private/react-native-fantom/runtime/expect.js | 3 +++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/community-cli-plugin/src/utils/errors.js b/packages/community-cli-plugin/src/utils/errors.js index b3fe0c1bfef..195f42f2ab7 100644 --- a/packages/community-cli-plugin/src/utils/errors.js +++ b/packages/community-cli-plugin/src/utils/errors.js @@ -19,7 +19,8 @@ export class CLIError extends Error { this.stack = typeof originalError === 'string' ? originalError - : originalError.stack || ''.split('\n').slice(0, 2).join('\n'); + : // $FlowFixMe[sketchy-null-string] + originalError.stack || ''.split('\n').slice(0, 2).join('\n'); } else { // When the "originalError" is not passed, it means that we know exactly // what went wrong and provide means to fix it. In such cases showing the diff --git a/packages/dev-middleware/src/inspector-proxy/DeviceEventReporter.js b/packages/dev-middleware/src/inspector-proxy/DeviceEventReporter.js index 43abb39df3e..ce3e72951e4 100644 --- a/packages/dev-middleware/src/inspector-proxy/DeviceEventReporter.js +++ b/packages/dev-middleware/src/inspector-proxy/DeviceEventReporter.js @@ -210,6 +210,7 @@ class DeviceEventReporter { error: Error, message: string, ): void { + // $FlowFixMe[incompatible-type] this.#eventReporter.logEvent({ type: 'proxy_error', status: 'error', diff --git a/packages/react-native/Libraries/Core/ExceptionsManager.js b/packages/react-native/Libraries/Core/ExceptionsManager.js index 4b7181eddb9..beb735273af 100644 --- a/packages/react-native/Libraries/Core/ExceptionsManager.js +++ b/packages/react-native/Libraries/Core/ExceptionsManager.js @@ -163,6 +163,7 @@ function handleException(e: unknown, isFatal: boolean) { // Unfortunately there is no way to figure out the stacktrace in this // case, so if you ended up here trying to trace an error, look for // `throw ''` somewhere in your codebase. + // $FlowFixMe[incompatible-type] error = new SyntheticError(e); } try { diff --git a/packages/react-native/Libraries/Utilities/logError.js b/packages/react-native/Libraries/Utilities/logError.js index 3e9bf1ad90f..937aff0076d 100644 --- a/packages/react-native/Libraries/Utilities/logError.js +++ b/packages/react-native/Libraries/Utilities/logError.js @@ -18,6 +18,7 @@ const logError = function (...args: ReadonlyArray) { if (args.length === 1 && args[0] instanceof Error) { const err = args[0]; + // $FlowFixMe[unsafe-addition] console.error('Error: "' + err.message + '". Stack:\n' + err.stack); } else { console.error.apply(console, args); diff --git a/private/react-native-fantom/runtime/expect.js b/private/react-native-fantom/runtime/expect.js index a786d89bc76..1623f0961e1 100644 --- a/private/react-native-fantom/runtime/expect.js +++ b/private/react-native-fantom/runtime/expect.js @@ -17,6 +17,7 @@ import {format, plugins} from 'pretty-format'; const stringify = (data: unknown): string => format(data, {min: true, plugins: [plugins.ReactElement]}); +// $FlowFixMe[incompatible-type] class ErrorWithCustomBlame extends Error { // Initially 5 to ignore all the frames from Babel helpers to instantiate this // custom error class. @@ -48,6 +49,7 @@ class ErrorWithCustomBlame extends Error { // $FlowExpectedError[incompatible-type] delete this.stack; + // $FlowFixMe[incompatible-use] const lines = originalStack.split('\n'); const index = lines.findIndex(line => /at (.*) \((.*):(\d+):(\d+)\)/.test(line), @@ -70,6 +72,7 @@ class ErrorWithCustomBlame extends Error { // In this case we're inheriting the error and we don't know if the stack // contains helpers that we need to ignore. errorWithCustomBlame.#ignoredFrameCount = 0; + // $FlowFixMe[incompatible-type] errorWithCustomBlame.stack = error.stack; return errorWithCustomBlame; }