From 338e6a967ccbdde156559b00e17ffcc7319533fc Mon Sep 17 00:00:00 2001 From: Jan Kassens Date: Tue, 4 Oct 2022 11:39:26 -0400 Subject: [PATCH] Flow upgrade to 0.155 This version banned use of this in object functions. ghstack-source-id: f49fd5e1b7732cea1ec75e71f2611f0ffa19e80d Pull Request resolved: https://github.com/facebook/react/pull/25414 --- package.json | 2 +- .../react-devtools-shared/src/backend/legacy/renderer.js | 9 +++++++++ packages/react-fetch/src/ReactFetchBrowser.js | 9 +++++++++ packages/react-fetch/src/ReactFetchNode.js | 9 +++++++++ scripts/flow/config/flowconfig | 2 +- yarn.lock | 8 ++++---- 6 files changed, 33 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 3c61d53d123b6..ceeeb1ade3a02 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.154.0", + "flow-bin": "^0.155.0", "glob": "^7.1.6", "glob-stream": "^6.1.0", "google-closure-compiler": "^20200517.0.0", diff --git a/packages/react-devtools-shared/src/backend/legacy/renderer.js b/packages/react-devtools-shared/src/backend/legacy/renderer.js index a3b1a860b8acd..1f53b61d71e82 100644 --- a/packages/react-devtools-shared/src/backend/legacy/renderer.js +++ b/packages/react-devtools-shared/src/backend/legacy/renderer.js @@ -218,10 +218,12 @@ export function attach( const internalInstance = args[0]; const hostContainerInfo = args[3]; if (getElementType(internalInstance) === ElementTypeOtherOrUnknown) { + // $FlowFixMe[object-this-reference] found when upgrading Flow return fn.apply(this, args); } if (hostContainerInfo._topLevelWrapper === undefined) { // SSR + // $FlowFixMe[object-this-reference] found when upgrading Flow return fn.apply(this, args); } @@ -241,6 +243,7 @@ export function attach( ); try { + // $FlowFixMe[object-this-reference] found when upgrading Flow const result = fn.apply(this, args); parentIDStack.pop(); return result; @@ -260,6 +263,7 @@ export function attach( performUpdateIfNecessary(fn, args) { const internalInstance = args[0]; if (getElementType(internalInstance) === ElementTypeOtherOrUnknown) { + // $FlowFixMe[object-this-reference] found when upgrading Flow return fn.apply(this, args); } @@ -268,6 +272,7 @@ export function attach( const prevChildren = getChildren(internalInstance); try { + // $FlowFixMe[object-this-reference] found when upgrading Flow const result = fn.apply(this, args); const nextChildren = getChildren(internalInstance); @@ -294,6 +299,7 @@ export function attach( receiveComponent(fn, args) { const internalInstance = args[0]; if (getElementType(internalInstance) === ElementTypeOtherOrUnknown) { + // $FlowFixMe[object-this-reference] found when upgrading Flow return fn.apply(this, args); } @@ -302,6 +308,7 @@ export function attach( const prevChildren = getChildren(internalInstance); try { + // $FlowFixMe[object-this-reference] found when upgrading Flow const result = fn.apply(this, args); const nextChildren = getChildren(internalInstance); @@ -328,12 +335,14 @@ export function attach( unmountComponent(fn, args) { const internalInstance = args[0]; if (getElementType(internalInstance) === ElementTypeOtherOrUnknown) { + // $FlowFixMe[object-this-reference] found when upgrading Flow return fn.apply(this, args); } const id = getID(internalInstance); parentIDStack.push(id); try { + // $FlowFixMe[object-this-reference] found when upgrading Flow const result = fn.apply(this, args); parentIDStack.pop(); diff --git a/packages/react-fetch/src/ReactFetchBrowser.js b/packages/react-fetch/src/ReactFetchBrowser.js index 3bba1e31b6f95..62339227cc8e7 100644 --- a/packages/react-fetch/src/ReactFetchBrowser.js +++ b/packages/react-fetch/src/ReactFetchBrowser.js @@ -98,27 +98,36 @@ Response.prototype = { constructor: Response, arrayBuffer() { return readRecordValue( + // $FlowFixMe[object-this-reference] found when upgrading Flow this._arrayBuffer || + // $FlowFixMe[object-this-reference] found when upgrading Flow (this._arrayBuffer = createRecordFromThenable( + // $FlowFixMe[object-this-reference] found when upgrading Flow this._response.arrayBuffer(), )), ); }, blob() { return readRecordValue( + // $FlowFixMe[object-this-reference] found when upgrading Flow this._blob || + // $FlowFixMe[object-this-reference] found when upgrading Flow (this._blob = createRecordFromThenable(this._response.blob())), ); }, json() { return readRecordValue( + // $FlowFixMe[object-this-reference] found when upgrading Flow this._json || + // $FlowFixMe[object-this-reference] found when upgrading Flow (this._json = createRecordFromThenable(this._response.json())), ); }, text() { return readRecordValue( + // $FlowFixMe[object-this-reference] found when upgrading Flow this._text || + // $FlowFixMe[object-this-reference] found when upgrading Flow (this._text = createRecordFromThenable(this._response.text())), ); }, diff --git a/packages/react-fetch/src/ReactFetchNode.js b/packages/react-fetch/src/ReactFetchNode.js index c689c08a70d95..1aea85ff4e2b1 100644 --- a/packages/react-fetch/src/ReactFetchNode.js +++ b/packages/react-fetch/src/ReactFetchNode.js @@ -143,6 +143,7 @@ function Response(nativeResponse) { Response.prototype = { constructor: Response, arrayBuffer() { + // $FlowFixMe[object-this-reference] found when upgrading Flow const buffer = readRecordValue(this._bufferRecord); return buffer; }, @@ -151,20 +152,28 @@ Response.prototype = { throw new Error('Not implemented.'); }, json() { + // $FlowFixMe[object-this-reference] found when upgrading Flow if (this._json !== null) { + // $FlowFixMe[object-this-reference] found when upgrading Flow return this._json; } + // $FlowFixMe[object-this-reference] found when upgrading Flow const buffer = readRecordValue(this._bufferRecord); const json = JSON.parse(buffer.toString()); + // $FlowFixMe[object-this-reference] found when upgrading Flow this._json = json; return json; }, text() { + // $FlowFixMe[object-this-reference] found when upgrading Flow if (this._text !== null) { + // $FlowFixMe[object-this-reference] found when upgrading Flow return this._text; } + // $FlowFixMe[object-this-reference] found when upgrading Flow const buffer = readRecordValue(this._bufferRecord); const text = buffer.toString(); + // $FlowFixMe[object-this-reference] found when upgrading Flow this._text = text; return text; }, diff --git a/scripts/flow/config/flowconfig b/scripts/flow/config/flowconfig index 4dbf5dfa8e601..a8611db12c348 100644 --- a/scripts/flow/config/flowconfig +++ b/scripts/flow/config/flowconfig @@ -47,4 +47,4 @@ munge_underscores=false %REACT_RENDERER_FLOW_OPTIONS% [version] -^0.154.0 +^0.155.0 diff --git a/yarn.lock b/yarn.lock index 90312a8c30d4b..1dfbb00609bba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7912,10 +7912,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.154.0: - version "0.154.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.154.0.tgz#e086964398e671daa8f56ed8663d7876337f77e5" - integrity sha512-I6u2ETdkAyard+8C5na6bfZp4EM0zIMB7O5zH4GKzBLv9/y8/NYRTxEXQe5T0hvj9R9DxFBUoPsFK76ziweUFw== +flow-bin@^0.155.0: + version "0.155.1" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.155.1.tgz#1263ee3e0f42d11cb13ba56c3851a096213ce5f7" + integrity sha512-qy2eXkgngR6u+MYA1ydzPnclhos21BZlpkJ50Y9YOZ4eTMq6txswB3X+gUsg8XUyCteLoMeo7n30k7aY2no2Yw== fluent-syntax@0.13.0: version "0.13.0"