From 4bbac04cd3624962900bb7800ba4f9609d3a1fd3 Mon Sep 17 00:00:00 2001 From: Jan Kassens Date: Mon, 6 Mar 2023 10:33:22 -0500 Subject: [PATCH] Upgrade Flow to 0.201 (#26326) Small Flow upgrade to keep us current. --- package.json | 4 +-- .../react-devtools-extensions/src/backend.js | 2 +- .../react-devtools-shell/src/app/console.js | 2 +- .../src/ReactFiberClassUpdateQueue.js | 3 +- .../react-reconciler/src/ReactFiberHooks.js | 2 +- .../react-refresh/src/ReactFreshRuntime.js | 4 +-- .../src/ReactFlightServerConfigStream.js | 2 ++ scripts/flow/config/flowconfig | 2 +- yarn.lock | 32 +++++++++---------- 9 files changed, 27 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 55361cc6a51a3..e7401a613ab9f 100644 --- a/package.json +++ b/package.json @@ -65,8 +65,8 @@ "eslint-plugin-react-internal": "link:./scripts/eslint-rules", "fbjs-scripts": "^3.0.1", "filesize": "^6.0.1", - "flow-bin": "^0.199.1", - "flow-remove-types": "^2.198.2", + "flow-bin": "^0.201.0", + "flow-remove-types": "^2.201.0", "glob": "^7.1.6", "glob-stream": "^6.1.0", "google-closure-compiler": "^20230206.0.0", diff --git a/packages/react-devtools-extensions/src/backend.js b/packages/react-devtools-extensions/src/backend.js index cbd4600e9875f..4a0dc99a97c2c 100644 --- a/packages/react-devtools-extensions/src/backend.js +++ b/packages/react-devtools-extensions/src/backend.js @@ -54,7 +54,7 @@ function setup(hook: any) { const setupNativeStyleEditor = require('react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor').default; - const bridge = new Bridge({ + const bridge = new Bridge<$FlowFixMe, $FlowFixMe>({ listen(fn) { const listener = (event: $FlowFixMe) => { if ( diff --git a/packages/react-devtools-shell/src/app/console.js b/packages/react-devtools-shell/src/app/console.js index 6f0ee7f7cc75b..5fecc27c115a1 100644 --- a/packages/react-devtools-shell/src/app/console.js +++ b/packages/react-devtools-shell/src/app/console.js @@ -12,7 +12,7 @@ function ignoreStrings( stringsToIgnore: Array, ): void { // $FlowFixMe[prop-missing] index access only allowed for objects with index keys - console[methodName] = (...args) => { + console[methodName] = (...args: $ReadOnlyArray) => { const maybeString = args[0]; if (typeof maybeString === 'string') { for (let i = 0; i < stringsToIgnore.length; i++) { diff --git a/packages/react-reconciler/src/ReactFiberClassUpdateQueue.js b/packages/react-reconciler/src/ReactFiberClassUpdateQueue.js index a6148e0184198..2e88c982022d3 100644 --- a/packages/react-reconciler/src/ReactFiberClassUpdateQueue.js +++ b/packages/react-reconciler/src/ReactFiberClassUpdateQueue.js @@ -161,7 +161,7 @@ export const CaptureUpdate = 3; let hasForceUpdate = false; let didWarnUpdateInsideUpdate; -let currentlyProcessingQueue; +let currentlyProcessingQueue: ?SharedQueue<$FlowFixMe>; export let resetCurrentlyProcessingQueue: () => void; if (__DEV__) { didWarnUpdateInsideUpdate = false; @@ -475,7 +475,6 @@ export function processUpdateQueue( hasForceUpdate = false; if (__DEV__) { - // $FlowFixMe[escaped-generic] discovered when updating Flow currentlyProcessingQueue = queue.shared; } diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js index 6741a55e4b42f..e9763f9fe289f 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.js +++ b/packages/react-reconciler/src/ReactFiberHooks.js @@ -165,7 +165,7 @@ export type UpdateQueue = { }; let didWarnAboutMismatchedHooksForComponent; -let didWarnUncachedGetSnapshot; +let didWarnUncachedGetSnapshot: void | true; let didWarnAboutUseWrappedInTryCatch; if (__DEV__) { didWarnAboutMismatchedHooksForComponent = new Set(); diff --git a/packages/react-refresh/src/ReactFreshRuntime.js b/packages/react-refresh/src/ReactFreshRuntime.js index d81c1140cab95..c9706041ce1ff 100644 --- a/packages/react-refresh/src/ReactFreshRuntime.js +++ b/packages/react-refresh/src/ReactFreshRuntime.js @@ -642,8 +642,8 @@ export function createSignatureFunctionForTransform(): ( getCustomHooks?: () => Array, ) => T | void { if (__DEV__) { - let savedType; - let hasCustomHooks; + let savedType: mixed; + let hasCustomHooks: boolean; let didCollectHooks = false; return function ( type: T, diff --git a/packages/react-server/src/ReactFlightServerConfigStream.js b/packages/react-server/src/ReactFlightServerConfigStream.js index 889a856e49437..43a7f75c80681 100644 --- a/packages/react-server/src/ReactFlightServerConfigStream.js +++ b/packages/react-server/src/ReactFlightServerConfigStream.js @@ -126,6 +126,7 @@ export function processModelChunk( id: number, model: ReactModel, ): Chunk { + // $FlowFixMe[incompatible-type] stringify can return null const json: string = stringify(model, request.toJSON); const row = id.toString(16) + ':' + json + '\n'; return stringToChunk(row); @@ -146,6 +147,7 @@ export function processImportChunk( id: number, clientReferenceMetadata: ReactModel, ): Chunk { + // $FlowFixMe[incompatible-type] stringify can return null const json: string = stringify(clientReferenceMetadata); const row = serializeRowHeader('I', id) + json + '\n'; return stringToChunk(row); diff --git a/scripts/flow/config/flowconfig b/scripts/flow/config/flowconfig index a3422af8188e9..3aad591046642 100644 --- a/scripts/flow/config/flowconfig +++ b/scripts/flow/config/flowconfig @@ -44,4 +44,4 @@ inference_mode=experimental.lti %REACT_RENDERER_FLOW_OPTIONS% [version] -^0.199.1 +^0.201.0 diff --git a/yarn.lock b/yarn.lock index 2cd8fdcab456b..b21a5191d0c52 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8180,22 +8180,22 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== -flow-bin@^0.199.1: - version "0.199.1" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.199.1.tgz#678eac2303fa898227f4d103264b6ce49f4430c1" - integrity sha512-Ic0Mp9iZ2exbH0mNj/XhzUWPZa9JylHb6uQARZnnYCTRwumOpjNOP0qwyRTltWrbCpfHjnWngNO9VLaVKHz2aQ== - -flow-parser@^0.198.2: - version "0.198.2" - resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.198.2.tgz#4c225995896b6be75943e9358e606a4fd86c87d9" - integrity sha512-tCQzqXbRAz0ZadIhAXGwdp/xsusADo8IK9idgc/2qCK5RmazbKDGedyykfRtzWgy7Klt4f4NZxq0o/wFUg6plQ== - -flow-remove-types@^2.198.2: - version "2.198.2" - resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.198.2.tgz#1b9e0e32eead4554f0d325391bbeb0c7a2a2993f" - integrity sha512-l7ua9FnZwI0HUUUu2Khj3pYnGSlkY5vOE60bgG1ajPJ9P+KzRgXIjpCaS4iTbUEpu6olzRrAVJtJ5N8kxmvpiQ== - dependencies: - flow-parser "^0.198.2" +flow-bin@^0.201.0: + version "0.201.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.201.0.tgz#bc8d7c3687526313d7a24dd920873a0273148d81" + integrity sha512-fqx6CMOhX9Xm4mN+tq/c7sqcm8aHFV1ipbLz2ZCzoNcPuUNZPoSVYm4p0qZqH0HyzMMEP1OWlU7dIkuSJ02cpg== + +flow-parser@^0.201.0: + version "0.201.0" + resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.201.0.tgz#d2005d4dae6fddf60d30f9ae0fb49a13c9c51cfe" + integrity sha512-G4oeDNpNGyIrweF9EnoHatncAihMT0tQgV6NMdyM5I7fhrz9Pr13PJ2KLQ673O4wj9KooTdBpeeYHdDNAQoyyw== + +flow-remove-types@^2.201.0: + version "2.201.0" + resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.201.0.tgz#d02d8a3ff3cb17d23da35c9786b02cdccc0ef9b8" + integrity sha512-EaS6Q0ApEjFdwD/JtBC1Hm+0j6mMsHeV5FR6MP+UI1RdTeNMdadMITt0Vb3XPBANLXZufaNzs6EMwpGNPzwwoA== + dependencies: + flow-parser "^0.201.0" pirates "^3.0.2" vlq "^0.2.1"