From 00a2f81508cccd59556e1bea0208726f9dbfbfa9 Mon Sep 17 00:00:00 2001 From: Jan Kassens Date: Tue, 4 Oct 2022 10:50:28 -0400 Subject: [PATCH] Flow upgrade to 0.143 This was a large upgrade that removed "classic mode" and made "types first" the only option. Most of the needed changes have been done in previous PRs, this just fixes up the last few instances. ghstack-source-id: 9612d95ba4b32edeb73fee8be9f3d67c43e86b80 Pull Request resolved: https://github.com/facebook/react/pull/25408 --- package.json | 2 +- .../src/server/ReactDOMFizzServerBrowser.js | 4 ++-- .../src/server/ReactDOMFizzStaticBrowser.js | 2 +- .../src/ReactStrictModeWarnings.new.js | 10 +++++----- .../src/ReactStrictModeWarnings.old.js | 10 +++++----- packages/react-refresh/src/ReactFreshRuntime.js | 12 +++++------- .../src/ReactFlightDOMServerBrowser.js | 6 +++--- scripts/flow/config/flowconfig | 4 +--- yarn.lock | 8 ++++---- 9 files changed, 27 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index 5066427dc5f5b..f34cce9415e38 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.142.0", + "flow-bin": "^0.143.0", "glob": "^7.1.6", "glob-stream": "^6.1.0", "google-closure-compiler": "^20200517.0.0", diff --git a/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js b/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js index c9cf4b81b5301..2394f656c53a7 100644 --- a/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js +++ b/packages/react-dom/src/server/ReactDOMFizzServerBrowser.js @@ -57,10 +57,10 @@ function renderToReadableStream( const stream: ReactDOMServerReadableStream = (new ReadableStream( { type: 'bytes', - pull(controller): ?Promise { + pull: (controller): ?Promise => { startFlowing(request, controller); }, - cancel(reason): ?Promise { + cancel: (reason): ?Promise => { abort(request); }, }, diff --git a/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js b/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js index 2036b078b760d..743e807a0594f 100644 --- a/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js +++ b/packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js @@ -50,7 +50,7 @@ function prerender( const stream = new ReadableStream( { type: 'bytes', - pull(controller): ?Promise { + pull: (controller): ?Promise => { startFlowing(request, controller); }, }, diff --git a/packages/react-reconciler/src/ReactStrictModeWarnings.new.js b/packages/react-reconciler/src/ReactStrictModeWarnings.new.js index 4de90a15869a8..c9e5ffce85cfb 100644 --- a/packages/react-reconciler/src/ReactStrictModeWarnings.new.js +++ b/packages/react-reconciler/src/ReactStrictModeWarnings.new.js @@ -20,11 +20,11 @@ type FiberArray = Array; type FiberToFiberComponentsMap = Map; const ReactStrictModeWarnings = { - recordUnsafeLifecycleWarnings(fiber: Fiber, instance: any): void {}, - flushPendingUnsafeLifecycleWarnings(): void {}, - recordLegacyContextWarning(fiber: Fiber, instance: any): void {}, - flushLegacyContextWarning(): void {}, - discardPendingWarnings(): void {}, + recordUnsafeLifecycleWarnings: (fiber: Fiber, instance: any): void => {}, + flushPendingUnsafeLifecycleWarnings: (): void => {}, + recordLegacyContextWarning: (fiber: Fiber, instance: any): void => {}, + flushLegacyContextWarning: (): void => {}, + discardPendingWarnings: (): void => {}, }; if (__DEV__) { diff --git a/packages/react-reconciler/src/ReactStrictModeWarnings.old.js b/packages/react-reconciler/src/ReactStrictModeWarnings.old.js index 4de90a15869a8..c9e5ffce85cfb 100644 --- a/packages/react-reconciler/src/ReactStrictModeWarnings.old.js +++ b/packages/react-reconciler/src/ReactStrictModeWarnings.old.js @@ -20,11 +20,11 @@ type FiberArray = Array; type FiberToFiberComponentsMap = Map; const ReactStrictModeWarnings = { - recordUnsafeLifecycleWarnings(fiber: Fiber, instance: any): void {}, - flushPendingUnsafeLifecycleWarnings(): void {}, - recordLegacyContextWarning(fiber: Fiber, instance: any): void {}, - flushLegacyContextWarning(): void {}, - discardPendingWarnings(): void {}, + recordUnsafeLifecycleWarnings: (fiber: Fiber, instance: any): void => {}, + flushPendingUnsafeLifecycleWarnings: (): void => {}, + recordLegacyContextWarning: (fiber: Fiber, instance: any): void => {}, + flushLegacyContextWarning: (): void => {}, + discardPendingWarnings: (): void => {}, }; if (__DEV__) { diff --git a/packages/react-refresh/src/ReactFreshRuntime.js b/packages/react-refresh/src/ReactFreshRuntime.js index 00e7932ec401e..2a971185f337a 100644 --- a/packages/react-refresh/src/ReactFreshRuntime.js +++ b/packages/react-refresh/src/ReactFreshRuntime.js @@ -460,20 +460,18 @@ export function injectIntoGlobalHook(globalObject: any): void { globalObject.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook = { renderers: new Map(), supportsFiber: true, - inject(injected) { - return nextID++; - }, - onScheduleFiberRoot( + inject: injected => nextID++, + onScheduleFiberRoot: ( id: number, root: FiberRoot, children: ReactNodeList, - ) {}, - onCommitFiberRoot( + ) => {}, + onCommitFiberRoot: ( id: number, root: FiberRoot, maybePriorityLevel: mixed, didError: boolean, - ) {}, + ) => {}, onCommitFiberUnmount() {}, }; } diff --git a/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js b/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js index 2cbd609b473f2..243040ab36131 100644 --- a/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js +++ b/packages/react-server-dom-webpack/src/ReactFlightDOMServerBrowser.js @@ -52,13 +52,13 @@ function renderToReadableStream( const stream = new ReadableStream( { type: 'bytes', - start(controller): ?Promise { + start: (controller): ?Promise => { startWork(request); }, - pull(controller): ?Promise { + pull: (controller): ?Promise => { startFlowing(request, controller); }, - cancel(reason): ?Promise {}, + cancel: (reason): ?Promise => {}, }, // $FlowFixMe size() methods are not allowed on byte streams. {highWaterMark: 0}, diff --git a/scripts/flow/config/flowconfig b/scripts/flow/config/flowconfig index 0299da6337508..03ebe986a168a 100644 --- a/scripts/flow/config/flowconfig +++ b/scripts/flow/config/flowconfig @@ -45,11 +45,9 @@ esproposal.class_instance_fields=enable esproposal.optional_chaining=enable exact_by_default=true munge_underscores=false -types_first=true -well_formed_exports=true # Substituted by createFlowConfig.js: %REACT_RENDERER_FLOW_OPTIONS% [version] -^0.142.0 +^0.143.0 diff --git a/yarn.lock b/yarn.lock index 88c7fbc092c39..33cc0aafa251a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7911,10 +7911,10 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== -flow-bin@^0.142.0: - version "0.142.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.142.0.tgz#b46b69de1123cf7c5a50917402968e07291df054" - integrity sha512-YgiapK/wrJjcgSgOWfoncbZ4vZrZWdHs+p7V9duI9zo4ehW2nM/VRrpSaWoZ+CWu3t+duGyAvupJvC6MM2l07w== +flow-bin@^0.143.0: + version "0.143.1" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.143.1.tgz#2ff825dfd85e84531b0ae780842cb1c2a9743cd2" + integrity sha512-6S6bgZ/pghBzEUELXkwFH/bsHT+GBMo8ftHDYs0SSJ+1e6NRdFfqxcYhaTvAK8zteSfQLZBIoec6G4WPPp4qQg== fluent-syntax@0.13.0: version "0.13.0"