@samitouri / QOS-React-2 / commits / 72593f008e

Flow upgrade to 0.176

This upgrade deprecated calling `new` on functions which introduced the majority of breakages and I suppressed those. ghstack-source-id: 545363f3c5b9f0327ac53fdea56a582d6cc29d72 Pull Request resolved: https://github.com/facebook/react/pull/25418

Jan Kassens committed Oct 4, 2022 at 13:25 UTC 72593f008ec2011104d78b460dd287e7dfcac838
12 files changed +36 -10
package.json
+1 -1
@@ -63,7 +63,7 @@
63 "eslint-plugin-react-internal": "link:./scripts/eslint-rules",
64 "fbjs-scripts": "1.2.0",
65 "filesize": "^6.0.1",
66 - "flow-bin": "^0.175.0",
66 + "flow-bin": "^0.176.0",
67 "glob": "^7.1.6",
68 "glob-stream": "^6.1.0",
69 "google-closure-compiler": "^20200517.0.0",
packages/react-devtools-shared/src/hooks/SourceMapConsumer.js
+1
@@ -242,6 +242,7 @@ function IndexedSourceMapConsumer(sourceMapJSON: IndexSourceMap) {
242
243 if (section.sourceMapConsumer === null) {
244 // Lazily parse the section only when it's needed.
245 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
246 section.sourceMapConsumer = new SourceMapConsumer(section.map);
247 }
248
packages/react-devtools-shared/src/inspectedElementCache.js
+7 -4
@@ -128,7 +128,10 @@ export function inspectElement(
128 path,
129 rendererID: ((rendererID: any): number),
130 }).then(
131 - ([inspectedElement: InspectedElementFrontend]) => {
131 + ([inspectedElement]: [
132 + InspectedElementFrontend,
133 + InspectedElementResponseType,
134 + ]) => {
135 const resolvedRecord = ((newRecord: any): ResolvedRecord<InspectedElementFrontend>);
136 resolvedRecord.status = Resolved;
137 resolvedRecord.value = inspectedElement;
@@ -183,9 +186,9 @@ export function checkForUpdate({
186 path: null,
187 rendererID: ((rendererID: any): number),
188 }).then(
186 - ([
187 - inspectedElement: InspectedElementFrontend,
188 - responseType: InspectedElementResponseType,
189 + ([inspectedElement, responseType]: [
190 + InspectedElementFrontend,
191 + InspectedElementResponseType,
192 ]) => {
193 if (responseType === 'full-data') {
194 startTransition(() => {
packages/react-dom-bindings/src/shared/DOMProperty.js
+15
@@ -260,6 +260,7 @@ if (enableCustomElementPropertySupport) {
260 }
261
262 reservedProps.forEach(name => {
263 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
264 properties[name] = new PropertyInfoRecord(
265 name,
266 RESERVED,
@@ -279,6 +280,7 @@ reservedProps.forEach(name => {
280 ['htmlFor', 'for'],
281 ['httpEquiv', 'http-equiv'],
282 ].forEach(([name, attributeName]) => {
283 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
284 properties[name] = new PropertyInfoRecord(
285 name,
286 STRING,
@@ -294,6 +296,7 @@ reservedProps.forEach(name => {
296 // In React, we let users pass `true` and `false` even though technically
297 // these aren't boolean attributes (they are coerced to strings).
298 ['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(name => {
299 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
300 properties[name] = new PropertyInfoRecord(
301 name,
302 BOOLEANISH_STRING,
@@ -315,6 +318,7 @@ reservedProps.forEach(name => {
318 'focusable',
319 'preserveAlpha',
320 ].forEach(name => {
321 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
322 properties[name] = new PropertyInfoRecord(
323 name,
324 BOOLEANISH_STRING,
@@ -355,6 +359,7 @@ reservedProps.forEach(name => {
359 // Microdata
360 'itemScope',
361 ].forEach(name => {
362 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
363 properties[name] = new PropertyInfoRecord(
364 name,
365 BOOLEAN,
@@ -380,6 +385,7 @@ reservedProps.forEach(name => {
385 // you'll need to set attributeName to name.toLowerCase()
386 // instead in the assignment below.
387 ].forEach(name => {
388 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
389 properties[name] = new PropertyInfoRecord(
390 name,
391 BOOLEAN,
@@ -401,6 +407,7 @@ reservedProps.forEach(name => {
407 // you'll need to set attributeName to name.toLowerCase()
408 // instead in the assignment below.
409 ].forEach(name => {
410 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
411 properties[name] = new PropertyInfoRecord(
412 name,
413 OVERLOADED_BOOLEAN,
@@ -423,6 +430,7 @@ reservedProps.forEach(name => {
430 // you'll need to set attributeName to name.toLowerCase()
431 // instead in the assignment below.
432 ].forEach(name => {
433 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
434 properties[name] = new PropertyInfoRecord(
435 name,
436 POSITIVE_NUMERIC,
@@ -436,6 +444,7 @@ reservedProps.forEach(name => {
444
445 // These are HTML attributes that must be numbers.
446 ['rowSpan', 'start'].forEach(name => {
447 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
448 properties[name] = new PropertyInfoRecord(
449 name,
450 NUMERIC,
@@ -535,6 +544,7 @@ const capitalize = token => token[1].toUpperCase();
544 // instead in the assignment below.
545 ].forEach(attributeName => {
546 const name = attributeName.replace(CAMELIZE, capitalize);
547 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
548 properties[name] = new PropertyInfoRecord(
549 name,
550 STRING,
@@ -560,6 +570,7 @@ const capitalize = token => token[1].toUpperCase();
570 // instead in the assignment below.
571 ].forEach(attributeName => {
572 const name = attributeName.replace(CAMELIZE, capitalize);
573 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
574 properties[name] = new PropertyInfoRecord(
575 name,
576 STRING,
@@ -582,6 +593,7 @@ const capitalize = token => token[1].toUpperCase();
593 // instead in the assignment below.
594 ].forEach(attributeName => {
595 const name = attributeName.replace(CAMELIZE, capitalize);
596 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
597 properties[name] = new PropertyInfoRecord(
598 name,
599 STRING,
@@ -597,6 +609,7 @@ const capitalize = token => token[1].toUpperCase();
609 // The attribute name is case-sensitive in SVG so we can't just use
610 // the React name like we do for attributes that exist only in HTML.
611 ['tabIndex', 'crossOrigin'].forEach(attributeName => {
612 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
613 properties[attributeName] = new PropertyInfoRecord(
614 attributeName,
615 STRING,
@@ -611,6 +624,7 @@ const capitalize = token => token[1].toUpperCase();
624 // These attributes accept URLs. These must not allow javascript: URLS.
625 // These will also need to accept Trusted Types object in the future.
626 const xlinkHref = 'xlinkHref';
627 +// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
628 properties[xlinkHref] = new PropertyInfoRecord(
629 'xlinkHref',
630 STRING,
@@ -622,6 +636,7 @@ properties[xlinkHref] = new PropertyInfoRecord(
636 );
637
638 ['src', 'href', 'action', 'formAction'].forEach(attributeName => {
639 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
640 properties[attributeName] = new PropertyInfoRecord(
641 attributeName,
642 STRING,
packages/react-dom/src/client/ReactDOMRoot.js
+2
@@ -248,6 +248,7 @@ export function createRoot(
248 : container;
249 listenToAllSupportedEvents(rootContainerElement);
250
251 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
252 return new ReactDOMRoot(root);
253 }
254
@@ -340,6 +341,7 @@ export function hydrateRoot(
341 }
342 }
343
344 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
345 return new ReactDOMHydrationRoot(root);
346 }
347
packages/react-fetch/src/ReactFetchBrowser.js
+1
@@ -163,6 +163,7 @@ export function fetch(url: string, options: mixed): Object {
163 if (nativeResponse._reactResponse) {
164 return nativeResponse._reactResponse;
165 } else {
166 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
167 return (nativeResponse._reactResponse = new Response(nativeResponse));
168 }
169 }
packages/react-fetch/src/ReactFetchNode.js
+1
@@ -46,6 +46,7 @@ function nodeFetch(
46 // $FlowFixMe: node flow type has `port` as a number
47 const request = nodeImpl.request(nodeOptions, response => {
48 // TODO: support redirects.
49 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
50 onResolve(new Response(response));
51 });
52 request.on('error', error => {
packages/react-pg/src/ReactPostgres.js
+1
@@ -67,6 +67,7 @@ function readRecordValue(record: Record) {
67 }
68
69 export function Pool(options: mixed) {
70 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
71 this.pool = new PostgresPool(options);
72 // Unique function per instance because it's used for cache identity.
73 this.createRecordMap = function() {
packages/react-reconciler/src/ReactFiberRoot.new.js
+1
@@ -144,6 +144,7 @@ export function createFiberRoot(
144 onRecoverableError: null | ((error: mixed) => void),
145 transitionCallbacks: null | TransitionTracingCallbacks,
146 ): FiberRoot {
147 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
148 const root: FiberRoot = (new FiberRootNode(
149 containerInfo,
150 tag,
packages/react-reconciler/src/ReactFiberRoot.old.js
+1
@@ -144,6 +144,7 @@ export function createFiberRoot(
144 onRecoverableError: null | ((error: mixed) => void),
145 transitionCallbacks: null | TransitionTracingCallbacks,
146 ): FiberRoot {
147 + // $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
148 const root: FiberRoot = (new FiberRootNode(
149 containerInfo,
150 tag,
scripts/flow/config/flowconfig
+1 -1
@@ -48,4 +48,4 @@ munge_underscores=false
48 %REACT_RENDERER_FLOW_OPTIONS%
49
50 [version]
51 -^0.175.0
51 +^0.176.0
yarn.lock
+4 -4
@@ -7912,10 +7912,10 @@ flatted@^2.0.0:
7912 resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
7913 integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==
7914
7915 -flow-bin@^0.175.0:
7916 - version "0.175.1"
7917 - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.175.1.tgz#72237070ba4f293f9e04113481e18929c1de50df"
7918 - integrity sha512-zMCP0BPa9BrfBSR7QTcyT/XBwzUbyLdNG0eXvBuNxfHCbMRkUzSceRoOaEZIw+R+GH0UHjVfUvPJ30hXxz1Nfw==
7915 +flow-bin@^0.176.0:
7916 + version "0.176.3"
7917 + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.176.3.tgz#d32de04e044ab474afe543b9fd245608bb6a6ac8"
7918 + integrity sha512-lbNqgjr2GlGLAEVp5+dhG4LdnFE7ekbvVNifAdlvTx58/nE8GrCOMiUwEQy4dLnfL2NIRMk2dbEVTrugeQJ3mA==
7919
7920 fluent-syntax@0.13.0:
7921 version "0.13.0"