From a473d08fcee187f957b844b53b2eee2d2714630b Mon Sep 17 00:00:00 2001 From: Jan Kassens Date: Thu, 8 Sep 2022 11:46:07 -0400 Subject: [PATCH] Update to Flow from 0.97 to 0.122 (#25204) * flow 0.122 * update ReactModel type --- package.json | 2 +- packages/jest-react/src/internalAct.js | 2 ++ .../react-debug-tools/src/ReactDebugHooks.js | 1 + .../src/backend/StyleX/utils.js | 2 ++ .../src/backend/renderer.js | 7 +++-- .../src/backend/types.js | 2 +- .../src/devtools/views/Button.js | 1 + .../NativeStyleEditor/AutoSizeInput.js | 1 + .../views/Components/reach-ui/menu-button.js | 1 + .../views/Components/reach-ui/tooltip.js | 1 + .../react-devtools-shared/src/hydration.js | 2 +- .../react-window/src/createGridComponent.js | 1 + .../react-window/src/createListComponent.js | 1 + .../src/registerDevToolsEventLogger.js | 4 ++- packages/react-devtools-shared/src/utils.js | 6 ++-- .../react-dom/src/events/SyntheticEvent.js | 31 ++++++++++++++----- .../src/server/ReactDOMFizzServerBrowser.js | 4 +-- .../src/server/ReactDOMFizzStaticBrowser.js | 2 +- packages/react-fetch/src/ReactFetchNode.js | 1 + .../src/legacy-events/accumulateInto.js | 2 ++ .../src/ReactNoopFlightServer.js | 2 +- .../src/ReactChildFiber.new.js | 1 + .../src/ReactChildFiber.old.js | 1 + .../src/ReactFiberCommitWork.new.js | 3 ++ .../src/ReactFiberCommitWork.old.js | 3 ++ .../src/ReactFiberHotReloading.new.js | 1 + .../src/ReactFiberHotReloading.old.js | 1 + .../src/ReactTestSelectors.js | 2 +- .../src/ReactFlightDOMServerBrowser.js | 6 ++-- .../ReactFlightServerWebpackBundlerConfig.js | 2 +- .../src/ReactFlightWebpackPlugin.js | 2 +- .../react-server/src/ReactFlightServer.js | 12 +++++-- .../src/ReactFlightServerConfigStream.js | 6 ++-- .../src/ReactTestRenderer.js | 2 +- packages/react/src/ReactChildren.js | 12 ++++--- packages/react/src/ReactLazy.js | 2 +- packages/shared/CheckStringCoercion.js | 1 + packages/shared/ReactServerContextRegistry.js | 1 + packages/shared/ReactSymbols.js | 2 +- packages/shared/ReactTypes.js | 12 +++---- packages/shared/isValidElementType.js | 2 +- scripts/flow/config/flowconfig | 2 +- yarn.lock | 8 ++--- 43 files changed, 109 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index 2e8445521b0a0..47514e3ec2d3a 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "eslint-plugin-react-internal": "link:./scripts/eslint-rules", "fbjs-scripts": "1.2.0", "filesize": "^6.0.1", - "flow-bin": "0.97", + "flow-bin": "^0.122", "glob": "^7.1.6", "glob-stream": "^6.1.0", "google-closure-compiler": "^20200517.0.0", diff --git a/packages/jest-react/src/internalAct.js b/packages/jest-react/src/internalAct.js index 4e41f6234c928..a5a398b7e2a0d 100644 --- a/packages/jest-react/src/internalAct.js +++ b/packages/jest-react/src/internalAct.js @@ -28,6 +28,8 @@ export function act(scope: () => Thenable | T): Thenable { 'This version of `act` requires a special mock build of Scheduler.', ); } + + // $FlowFixMe: _isMockFunction doesn't exist on function if (setTimeout._isMockFunction !== true) { throw Error( "This version of `act` requires Jest's timer mocks " + diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index 940873725cb2f..7cfb576fad378 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -683,6 +683,7 @@ function handleRenderFunctionError(error: any): void { // TODO: refactor this if we ever combine the devtools and debug tools packages wrapperError.name = 'ReactDebugToolsRenderError'; // this stage-4 proposal is not supported by all environments yet. + // $FlowFixMe Flow doesn't have this type yet. wrapperError.cause = error; throw wrapperError; } diff --git a/packages/react-devtools-shared/src/backend/StyleX/utils.js b/packages/react-devtools-shared/src/backend/StyleX/utils.js index 68bda23a2262c..2167321b0c84d 100644 --- a/packages/react-devtools-shared/src/backend/StyleX/utils.js +++ b/packages/react-devtools-shared/src/backend/StyleX/utils.js @@ -92,7 +92,9 @@ function getPropertyValueForStyleName(styleName: string): string | null { ]: any): CSSStyleSheet); // $FlowFixMe Flow doesn't konw about these properties const rules = styleSheet.rules || styleSheet.cssRules; + // $FlowFixMe `rules` is mixed for (let ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) { + // $FlowFixMe `rules` is mixed const rule = rules[ruleIndex]; // $FlowFixMe Flow doesn't konw about these properties const {cssText, selectorText, style} = rule; diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js index 3a893060da0ad..9802d4b8c03d9 100644 --- a/packages/react-devtools-shared/src/backend/renderer.js +++ b/packages/react-devtools-shared/src/backend/renderer.js @@ -124,7 +124,7 @@ import type { } from 'react-devtools-shared/src/types'; type getDisplayNameForFiberType = (fiber: Fiber) => string | null; -type getTypeSymbolType = (type: any) => Symbol | number; +type getTypeSymbolType = (type: any) => symbol | number; type ReactPriorityLevelsType = {| ImmediatePriority: number, @@ -382,13 +382,14 @@ export function getInternalReactConstants( // End of copied code. // ********************************************************** - function getTypeSymbol(type: any): Symbol | number { + function getTypeSymbol(type: any): symbol | number { const symbolOrNumber = typeof type === 'object' && type !== null ? type.$$typeof : type; // $FlowFixMe Flow doesn't know about typeof "symbol" return typeof symbolOrNumber === 'symbol' - ? symbolOrNumber.toString() + ? // $FlowFixMe `toString()` doesn't match the type signature? + symbolOrNumber.toString() : symbolOrNumber; } diff --git a/packages/react-devtools-shared/src/backend/types.js b/packages/react-devtools-shared/src/backend/types.js index 81ed15b04ae78..be71a816d6327 100644 --- a/packages/react-devtools-shared/src/backend/types.js +++ b/packages/react-devtools-shared/src/backend/types.js @@ -84,7 +84,7 @@ export type GetFiberIDForNative = ( export type FindNativeNodesForFiberID = (id: number) => ?Array; export type ReactProviderType = { - $$typeof: Symbol | number, + $$typeof: symbol | number, _context: ReactContext, ... }; diff --git a/packages/react-devtools-shared/src/devtools/views/Button.js b/packages/react-devtools-shared/src/devtools/views/Button.js index 82400bb8982a2..bdd84b57da431 100644 --- a/packages/react-devtools-shared/src/devtools/views/Button.js +++ b/packages/react-devtools-shared/src/devtools/views/Button.js @@ -28,6 +28,7 @@ export default function Button({ ...rest }: Props) { let button = ( + // $FlowFixMe unsafe spread