From 575d1d5fd24d1170e4edb1e7e44641aa858b87c1 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Fri, 20 Nov 2026 21:32:34 -0800 Subject: [PATCH] Fix Flow types that use `void` for a missing value Summary: X-link: https://github.com/react/react-native/pull/60206 Under Flow's `experimental.ts_void`, `void` is TypeScript's `void`, which flows only into `void`, `any` and `unknown`, so a value typed `void` can't be passed where an optional value or `undefined` is expected. This updates React Native's Flow types for projects that check React Native's sources with that option: - Library definitions say `undefined` where the TypeScript definitions do: `babel/traverse`'s `Scope#getBinding()` and `child_process.spawnSync()`'s `error`. execa's `env` is read-only, so it accepts both `process.env` and objects with `void` values. - `BackHandler` handlers and the RN tester's stall handler may return nothing. - `EventTarget`'s listener maps and codegen's `bubblingType` use maybe types instead of `void`, `componentDidMount()` in `TouchableNativeFeedback` returns `void`, and two RN tester components that render nothing return `undefined`. - Where the only fix needs the `undefined` type, which this repository's Flow config doesn't enable, the error is suppressed. Without that option, `void` and `undefined` are the same type, so nothing changes. Changelog: [General][Changed] - Allow `BackHandler` event listeners to return nothing [General][Changed] - Type `TouchableNativeFeedback`'s `componentDidMount()` as returning `void` Differential Revision: D133660807 --- flow-typed/environment/node.js | 2 +- flow-typed/npm/babel-traverse_v7.x.x.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flow-typed/environment/node.js b/flow-typed/environment/node.js index 295853ae60..6351206249 100644 --- a/flow-typed/environment/node.js +++ b/flow-typed/environment/node.js @@ -426,7 +426,7 @@ type child_process$spawnSyncRet = Readonly<{ // TODO: subprocess.status may be null in case of error or signal status: number, signal: string | null, - error: Error | void, + error: Error | undefined, }>; type child_process$spawnSyncOpts = Readonly<{ diff --git a/flow-typed/npm/babel-traverse_v7.x.x.js b/flow-typed/npm/babel-traverse_v7.x.x.js index c5988473f3..ba55c17b8a 100644 --- a/flow-typed/npm/babel-traverse_v7.x.x.js +++ b/flow-typed/npm/babel-traverse_v7.x.x.js @@ -533,7 +533,7 @@ declare module '@babel/traverse' { bindingIdentifierEquals(name: string, node: BabelNode): boolean; - getBinding(name: string): Binding | void; + getBinding(name: string): Binding | undefined; getOwnBinding(name: string): Binding | void;