Skip to content

Commit

Permalink
Flow upgrade to 0.176
Browse files Browse the repository at this point in the history
This upgrade deprecated calling `new` on functions which introduced
the majority of breakages and I suppressed those.

ghstack-source-id: 545363f3c5b9f0327ac53fdea56a582d6cc29d72
Pull Request resolved: #25418
  • Loading branch information
kassens committed Oct 4, 2022
1 parent 46d40f3 commit 72593f0
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
"fbjs-scripts": "1.2.0",
"filesize": "^6.0.1",
"flow-bin": "^0.175.0",
"flow-bin": "^0.176.0",
"glob": "^7.1.6",
"glob-stream": "^6.1.0",
"google-closure-compiler": "^20200517.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ function IndexedSourceMapConsumer(sourceMapJSON: IndexSourceMap) {

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

Expand Down
11 changes: 7 additions & 4 deletions packages/react-devtools-shared/src/inspectedElementCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ export function inspectElement(
path,
rendererID: ((rendererID: any): number),
}).then(
([inspectedElement: InspectedElementFrontend]) => {
([inspectedElement]: [
InspectedElementFrontend,
InspectedElementResponseType,
]) => {
const resolvedRecord = ((newRecord: any): ResolvedRecord<InspectedElementFrontend>);
resolvedRecord.status = Resolved;
resolvedRecord.value = inspectedElement;
Expand Down Expand Up @@ -183,9 +186,9 @@ export function checkForUpdate({
path: null,
rendererID: ((rendererID: any): number),
}).then(
([
inspectedElement: InspectedElementFrontend,
responseType: InspectedElementResponseType,
([inspectedElement, responseType]: [
InspectedElementFrontend,
InspectedElementResponseType,
]) => {
if (responseType === 'full-data') {
startTransition(() => {
Expand Down
15 changes: 15 additions & 0 deletions packages/react-dom-bindings/src/shared/DOMProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ if (enableCustomElementPropertySupport) {
}

reservedProps.forEach(name => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
RESERVED,
Expand All @@ -279,6 +280,7 @@ reservedProps.forEach(name => {
['htmlFor', 'for'],
['httpEquiv', 'http-equiv'],
].forEach(([name, attributeName]) => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
STRING,
Expand All @@ -294,6 +296,7 @@ reservedProps.forEach(name => {
// In React, we let users pass `true` and `false` even though technically
// these aren't boolean attributes (they are coerced to strings).
['contentEditable', 'draggable', 'spellCheck', 'value'].forEach(name => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
BOOLEANISH_STRING,
Expand All @@ -315,6 +318,7 @@ reservedProps.forEach(name => {
'focusable',
'preserveAlpha',
].forEach(name => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
BOOLEANISH_STRING,
Expand Down Expand Up @@ -355,6 +359,7 @@ reservedProps.forEach(name => {
// Microdata
'itemScope',
].forEach(name => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
BOOLEAN,
Expand All @@ -380,6 +385,7 @@ reservedProps.forEach(name => {
// you'll need to set attributeName to name.toLowerCase()
// instead in the assignment below.
].forEach(name => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
BOOLEAN,
Expand All @@ -401,6 +407,7 @@ reservedProps.forEach(name => {
// you'll need to set attributeName to name.toLowerCase()
// instead in the assignment below.
].forEach(name => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
OVERLOADED_BOOLEAN,
Expand All @@ -423,6 +430,7 @@ reservedProps.forEach(name => {
// you'll need to set attributeName to name.toLowerCase()
// instead in the assignment below.
].forEach(name => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
POSITIVE_NUMERIC,
Expand All @@ -436,6 +444,7 @@ reservedProps.forEach(name => {

// These are HTML attributes that must be numbers.
['rowSpan', 'start'].forEach(name => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
NUMERIC,
Expand Down Expand Up @@ -535,6 +544,7 @@ const capitalize = token => token[1].toUpperCase();
// instead in the assignment below.
].forEach(attributeName => {
const name = attributeName.replace(CAMELIZE, capitalize);
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
STRING,
Expand All @@ -560,6 +570,7 @@ const capitalize = token => token[1].toUpperCase();
// instead in the assignment below.
].forEach(attributeName => {
const name = attributeName.replace(CAMELIZE, capitalize);
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
STRING,
Expand All @@ -582,6 +593,7 @@ const capitalize = token => token[1].toUpperCase();
// instead in the assignment below.
].forEach(attributeName => {
const name = attributeName.replace(CAMELIZE, capitalize);
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[name] = new PropertyInfoRecord(
name,
STRING,
Expand All @@ -597,6 +609,7 @@ const capitalize = token => token[1].toUpperCase();
// The attribute name is case-sensitive in SVG so we can't just use
// the React name like we do for attributes that exist only in HTML.
['tabIndex', 'crossOrigin'].forEach(attributeName => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[attributeName] = new PropertyInfoRecord(
attributeName,
STRING,
Expand All @@ -611,6 +624,7 @@ const capitalize = token => token[1].toUpperCase();
// These attributes accept URLs. These must not allow javascript: URLS.
// These will also need to accept Trusted Types object in the future.
const xlinkHref = 'xlinkHref';
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[xlinkHref] = new PropertyInfoRecord(
'xlinkHref',
STRING,
Expand All @@ -622,6 +636,7 @@ properties[xlinkHref] = new PropertyInfoRecord(
);

['src', 'href', 'action', 'formAction'].forEach(attributeName => {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
properties[attributeName] = new PropertyInfoRecord(
attributeName,
STRING,
Expand Down
2 changes: 2 additions & 0 deletions packages/react-dom/src/client/ReactDOMRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export function createRoot(
: container;
listenToAllSupportedEvents(rootContainerElement);

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

Expand Down Expand Up @@ -340,6 +341,7 @@ export function hydrateRoot(
}
}

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

Expand Down
1 change: 1 addition & 0 deletions packages/react-fetch/src/ReactFetchBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export function fetch(url: string, options: mixed): Object {
if (nativeResponse._reactResponse) {
return nativeResponse._reactResponse;
} else {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
return (nativeResponse._reactResponse = new Response(nativeResponse));
}
}
1 change: 1 addition & 0 deletions packages/react-fetch/src/ReactFetchNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function nodeFetch(
// $FlowFixMe: node flow type has `port` as a number
const request = nodeImpl.request(nodeOptions, response => {
// TODO: support redirects.
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
onResolve(new Response(response));
});
request.on('error', error => {
Expand Down
1 change: 1 addition & 0 deletions packages/react-pg/src/ReactPostgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function readRecordValue(record: Record) {
}

export function Pool(options: mixed) {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
this.pool = new PostgresPool(options);
// Unique function per instance because it's used for cache identity.
this.createRecordMap = function() {
Expand Down
1 change: 1 addition & 0 deletions packages/react-reconciler/src/ReactFiberRoot.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function createFiberRoot(
onRecoverableError: null | ((error: mixed) => void),
transitionCallbacks: null | TransitionTracingCallbacks,
): FiberRoot {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
const root: FiberRoot = (new FiberRootNode(
containerInfo,
tag,
Expand Down
1 change: 1 addition & 0 deletions packages/react-reconciler/src/ReactFiberRoot.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function createFiberRoot(
onRecoverableError: null | ((error: mixed) => void),
transitionCallbacks: null | TransitionTracingCallbacks,
): FiberRoot {
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
const root: FiberRoot = (new FiberRootNode(
containerInfo,
tag,
Expand Down
2 changes: 1 addition & 1 deletion scripts/flow/config/flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ munge_underscores=false
%REACT_RENDERER_FLOW_OPTIONS%

[version]
^0.175.0
^0.176.0
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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.175.0:
version "0.175.1"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.175.1.tgz#72237070ba4f293f9e04113481e18929c1de50df"
integrity sha512-zMCP0BPa9BrfBSR7QTcyT/XBwzUbyLdNG0eXvBuNxfHCbMRkUzSceRoOaEZIw+R+GH0UHjVfUvPJ30hXxz1Nfw==
flow-bin@^0.176.0:
version "0.176.3"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.176.3.tgz#d32de04e044ab474afe543b9fd245608bb6a6ac8"
integrity sha512-lbNqgjr2GlGLAEVp5+dhG4LdnFE7ekbvVNifAdlvTx58/nE8GrCOMiUwEQy4dLnfL2NIRMk2dbEVTrugeQJ3mA==

[email protected]:
version "0.13.0"
Expand Down

0 comments on commit 72593f0

Please sign in to comment.