From e19466fe0c17b56e7e00dad4c0f3c23eb4681c99 Mon Sep 17 00:00:00 2001 From: Sam Zhou Date: Sat, 7 Nov 2026 10:18:14 -0500 Subject: [PATCH] [flow] Name function type params in published Flow types Flow's `experimental.require_function_type_param_name` option requires every function type param to be named, as TypeScript does: ```js type T = (string) => void; // error type T = (v: string) => void; // ok ``` This names the two unnamed params that end up in the package's published `.js.flow` files: `useElementCallback`'s `callback` and `ReactRef`. Param names don't affect type checking. ## Test plan `flow full-check` with Flow 0.338.0, using a copy of `.flowconfig` updated for 0.338 with the option turned on: the two `missing-function-type-param-name` errors in `useElementCallback.js` and `Utilities.js` are gone, and no other errors change. --- packages/react-strict-dom/src/shared/useElementCallback.js | 2 +- packages/react-strict-dom/src/types/Utilities.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-strict-dom/src/shared/useElementCallback.js b/packages/react-strict-dom/src/shared/useElementCallback.js index 09f7f2d1..56d76314 100644 --- a/packages/react-strict-dom/src/shared/useElementCallback.js +++ b/packages/react-strict-dom/src/shared/useElementCallback.js @@ -23,7 +23,7 @@ type OptionalCleanup = (() => void) | void; * WARNING: The callback should be stable (e.g. using `useCallback`). */ export function useElementCallback( - callback: (T) => OptionalCleanup + callback: (v: T) => OptionalCleanup ): CallbackRef { const cleanupRef = useRef(undefined); return useCallback( diff --git a/packages/react-strict-dom/src/types/Utilities.js b/packages/react-strict-dom/src/types/Utilities.js index 3b3df59a..1cb88171 100644 --- a/packages/react-strict-dom/src/types/Utilities.js +++ b/packages/react-strict-dom/src/types/Utilities.js @@ -9,4 +9,4 @@ export type ReactRef = | { writeonly current: T | null, ... } - | ((T | null) => unknown); + | ((v: T | null) => unknown);