From de7e643aa30b4e87376898b74037bd9712e9d4d6 Mon Sep 17 00:00:00 2001 From: JC Perez Chavez Date: Thu, 12 Nov 2026 12:35:24 -0500 Subject: [PATCH] Remove $FlowFixMe[sketchy-null-string] (errors.js) (#59976) Summary: Replace the optional original error stack's `||` fallback with an explicit null-or-empty ternary. Read the stack getter once in the Error branch and preserve the direct string branch, including `''`. Null/undefined/empty stacks still evaluate the existing `''.split('\n').slice(0, 2).join('\n')` fallback; nonempty stacks are unchanged. Do not alter the fallback's existing behavior. Changelog: [Internal] Differential Revision: D129900981 Pull Request resolved: https://github.com/react/react-native/pull/59976 --- packages/community-cli-plugin/src/utils/errors.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/community-cli-plugin/src/utils/errors.js b/packages/community-cli-plugin/src/utils/errors.js index 195f42f2ab7..4d44b8222b1 100644 --- a/packages/community-cli-plugin/src/utils/errors.js +++ b/packages/community-cli-plugin/src/utils/errors.js @@ -16,11 +16,15 @@ export class CLIError extends Error { constructor(msg: string, originalError?: Error | string) { super(inlineString(msg)); if (originalError != null) { - this.stack = - typeof originalError === 'string' - ? originalError - : // $FlowFixMe[sketchy-null-string] - originalError.stack || ''.split('\n').slice(0, 2).join('\n'); + if (typeof originalError === 'string') { + this.stack = originalError; + } else { + const originalStack = originalError.stack; + this.stack = + originalStack == null || originalStack === '' + ? ''.split('\n').slice(0, 2).join('\n') + : originalStack; + } } 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