Skip to content

Commit 72593f0

Browse files
committed
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: 545363f Pull Request resolved: #25418
1 parent 46d40f3 commit 72593f0

File tree

12 files changed

+36
-10
lines changed

12 files changed

+36
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
6464
"fbjs-scripts": "1.2.0",
6565
"filesize": "^6.0.1",
66-
"flow-bin": "^0.175.0",
66+
"flow-bin": "^0.176.0",
6767
"glob": "^7.1.6",
6868
"glob-stream": "^6.1.0",
6969
"google-closure-compiler": "^20200517.0.0",

packages/react-devtools-shared/src/hooks/SourceMapConsumer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ function IndexedSourceMapConsumer(sourceMapJSON: IndexSourceMap) {
242242

243243
if (section.sourceMapConsumer === null) {
244244
// Lazily parse the section only when it's needed.
245+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
245246
section.sourceMapConsumer = new SourceMapConsumer(section.map);
246247
}
247248

packages/react-devtools-shared/src/inspectedElementCache.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ export function inspectElement(
128128
path,
129129
rendererID: ((rendererID: any): number),
130130
}).then(
131-
([inspectedElement: InspectedElementFrontend]) => {
131+
([inspectedElement]: [
132+
InspectedElementFrontend,
133+
InspectedElementResponseType,
134+
]) => {
132135
const resolvedRecord = ((newRecord: any): ResolvedRecord<InspectedElementFrontend>);
133136
resolvedRecord.status = Resolved;
134137
resolvedRecord.value = inspectedElement;
@@ -183,9 +186,9 @@ export function checkForUpdate({
183186
path: null,
184187
rendererID: ((rendererID: any): number),
185188
}).then(
186-
([
187-
inspectedElement: InspectedElementFrontend,
188-
responseType: InspectedElementResponseType,
189+
([inspectedElement, responseType]: [
190+
InspectedElementFrontend,
191+
InspectedElementResponseType,
189192
]) => {
190193
if (responseType === 'full-data') {
191194
startTransition(() => {

packages/react-dom-bindings/src/shared/DOMProperty.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ if (enableCustomElementPropertySupport) {
260260
}
261261

262262
reservedProps.forEach(name => {
263+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
263264
properties[name] = new PropertyInfoRecord(
264265
name,
265266
RESERVED,
@@ -279,6 +280,7 @@ reservedProps.forEach(name => {
279280
['htmlFor', 'for'],
280281
['httpEquiv', 'http-equiv'],
281282
].forEach(([name, attributeName]) => {
283+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
282284
properties[name] = new PropertyInfoRecord(
283285
name,
284286
STRING,
@@ -294,6 +296,7 @@ reservedProps.forEach(name => {
294296
// In React, we let users pass `true` and `false` even though technically
295297
// these aren't boolean attributes (they are coerced to strings).
296298
['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(name => {
299+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
297300
properties[name] = new PropertyInfoRecord(
298301
name,
299302
BOOLEANISH_STRING,
@@ -315,6 +318,7 @@ reservedProps.forEach(name => {
315318
'focusable',
316319
'preserveAlpha',
317320
].forEach(name => {
321+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
318322
properties[name] = new PropertyInfoRecord(
319323
name,
320324
BOOLEANISH_STRING,
@@ -355,6 +359,7 @@ reservedProps.forEach(name => {
355359
// Microdata
356360
'itemScope',
357361
].forEach(name => {
362+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
358363
properties[name] = new PropertyInfoRecord(
359364
name,
360365
BOOLEAN,
@@ -380,6 +385,7 @@ reservedProps.forEach(name => {
380385
// you'll need to set attributeName to name.toLowerCase()
381386
// instead in the assignment below.
382387
].forEach(name => {
388+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
383389
properties[name] = new PropertyInfoRecord(
384390
name,
385391
BOOLEAN,
@@ -401,6 +407,7 @@ reservedProps.forEach(name => {
401407
// you'll need to set attributeName to name.toLowerCase()
402408
// instead in the assignment below.
403409
].forEach(name => {
410+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
404411
properties[name] = new PropertyInfoRecord(
405412
name,
406413
OVERLOADED_BOOLEAN,
@@ -423,6 +430,7 @@ reservedProps.forEach(name => {
423430
// you'll need to set attributeName to name.toLowerCase()
424431
// instead in the assignment below.
425432
].forEach(name => {
433+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
426434
properties[name] = new PropertyInfoRecord(
427435
name,
428436
POSITIVE_NUMERIC,
@@ -436,6 +444,7 @@ reservedProps.forEach(name => {
436444

437445
// These are HTML attributes that must be numbers.
438446
['rowSpan', 'start'].forEach(name => {
447+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
439448
properties[name] = new PropertyInfoRecord(
440449
name,
441450
NUMERIC,
@@ -535,6 +544,7 @@ const capitalize = token => token[1].toUpperCase();
535544
// instead in the assignment below.
536545
].forEach(attributeName => {
537546
const name = attributeName.replace(CAMELIZE, capitalize);
547+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
538548
properties[name] = new PropertyInfoRecord(
539549
name,
540550
STRING,
@@ -560,6 +570,7 @@ const capitalize = token => token[1].toUpperCase();
560570
// instead in the assignment below.
561571
].forEach(attributeName => {
562572
const name = attributeName.replace(CAMELIZE, capitalize);
573+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
563574
properties[name] = new PropertyInfoRecord(
564575
name,
565576
STRING,
@@ -582,6 +593,7 @@ const capitalize = token => token[1].toUpperCase();
582593
// instead in the assignment below.
583594
].forEach(attributeName => {
584595
const name = attributeName.replace(CAMELIZE, capitalize);
596+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
585597
properties[name] = new PropertyInfoRecord(
586598
name,
587599
STRING,
@@ -597,6 +609,7 @@ const capitalize = token => token[1].toUpperCase();
597609
// The attribute name is case-sensitive in SVG so we can't just use
598610
// the React name like we do for attributes that exist only in HTML.
599611
['tabIndex', 'crossOrigin'].forEach(attributeName => {
612+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
600613
properties[attributeName] = new PropertyInfoRecord(
601614
attributeName,
602615
STRING,
@@ -611,6 +624,7 @@ const capitalize = token => token[1].toUpperCase();
611624
// These attributes accept URLs. These must not allow javascript: URLS.
612625
// These will also need to accept Trusted Types object in the future.
613626
const xlinkHref = 'xlinkHref';
627+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
614628
properties[xlinkHref] = new PropertyInfoRecord(
615629
'xlinkHref',
616630
STRING,
@@ -622,6 +636,7 @@ properties[xlinkHref] = new PropertyInfoRecord(
622636
);
623637

624638
['src', 'href', 'action', 'formAction'].forEach(attributeName => {
639+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
625640
properties[attributeName] = new PropertyInfoRecord(
626641
attributeName,
627642
STRING,

packages/react-dom/src/client/ReactDOMRoot.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ export function createRoot(
248248
: container;
249249
listenToAllSupportedEvents(rootContainerElement);
250250

251+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
251252
return new ReactDOMRoot(root);
252253
}
253254

@@ -340,6 +341,7 @@ export function hydrateRoot(
340341
}
341342
}
342343

344+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
343345
return new ReactDOMHydrationRoot(root);
344346
}
345347

packages/react-fetch/src/ReactFetchBrowser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export function fetch(url: string, options: mixed): Object {
163163
if (nativeResponse._reactResponse) {
164164
return nativeResponse._reactResponse;
165165
} else {
166+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
166167
return (nativeResponse._reactResponse = new Response(nativeResponse));
167168
}
168169
}

packages/react-fetch/src/ReactFetchNode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ function nodeFetch(
4646
// $FlowFixMe: node flow type has `port` as a number
4747
const request = nodeImpl.request(nodeOptions, response => {
4848
// TODO: support redirects.
49+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
4950
onResolve(new Response(response));
5051
});
5152
request.on('error', error => {

packages/react-pg/src/ReactPostgres.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function readRecordValue(record: Record) {
6767
}
6868

6969
export function Pool(options: mixed) {
70+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
7071
this.pool = new PostgresPool(options);
7172
// Unique function per instance because it's used for cache identity.
7273
this.createRecordMap = function() {

packages/react-reconciler/src/ReactFiberRoot.new.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export function createFiberRoot(
144144
onRecoverableError: null | ((error: mixed) => void),
145145
transitionCallbacks: null | TransitionTracingCallbacks,
146146
): FiberRoot {
147+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
147148
const root: FiberRoot = (new FiberRootNode(
148149
containerInfo,
149150
tag,

packages/react-reconciler/src/ReactFiberRoot.old.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export function createFiberRoot(
144144
onRecoverableError: null | ((error: mixed) => void),
145145
transitionCallbacks: null | TransitionTracingCallbacks,
146146
): FiberRoot {
147+
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
147148
const root: FiberRoot = (new FiberRootNode(
148149
containerInfo,
149150
tag,

scripts/flow/config/flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ munge_underscores=false
4848
%REACT_RENDERER_FLOW_OPTIONS%
4949

5050
[version]
51-
^0.175.0
51+
^0.176.0

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7912,10 +7912,10 @@ flatted@^2.0.0:
79127912
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
79137913
integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==
79147914

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==
79197919

79207920
79217921
version "0.13.0"

0 commit comments

Comments
 (0)