Skip to content

Commit

Permalink
[flow] enable enforce_local_inference_annotations (#25921)
Browse files Browse the repository at this point in the history
This setting is an incremental path to the next Flow version enforcing
type annotations on most functions (except some inline callbacks).

Used
```
node_modules/.bin/flow codemod annotate-functions-and-classes --write .
```
to add a majority of the types with some hand cleanup when for large
inferred objects that should just be `Fiber` or weird constructs
including `any`.

Suppressed the remaining issues.

Builds on #25918

DiffTrain build for [0b4f443](0b4f443)
[View git log for this commit](https:/facebook/react/commits/0b4f443020af386f2b48c47c074cb504ed672dc8)
  • Loading branch information
kassens committed Jan 9, 2023
1 parent 3131770 commit 3075524
Show file tree
Hide file tree
Showing 39 changed files with 227 additions and 126 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0b974418c9a56f6c560298560265dcf4b65784bc
0b4f443020af386f2b48c47c074cb504ed672dc8
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0b974418c9a56f6c560298560265dcf4b65784bc
0b4f443020af386f2b48c47c074cb504ed672dc8
6 changes: 4 additions & 2 deletions compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-classic-0b974418c-20230106";
var ReactVersion = "18.3.0-www-classic-0b4f44302-20230109";

// ATTENTION
// When adding new symbols to this file,
Expand Down Expand Up @@ -1311,7 +1311,7 @@ function countChildren(children) {

function forEachChildren(children, forEachFunc, forEachContext) {
mapChildren(
children,
children, // $FlowFixMe[missing-this-annot]
function() {
forEachFunc.apply(this, arguments); // Don't return anything.
},
Expand Down Expand Up @@ -1582,6 +1582,7 @@ function lazy(ctor) {
get: function() {
return defaultProps;
},
// $FlowFixMe[missing-local-annot]
set: function(newDefaultProps) {
error(
"React.lazy(...): It is not supported to assign `defaultProps` to " +
Expand All @@ -1602,6 +1603,7 @@ function lazy(ctor) {
get: function() {
return propTypes;
},
// $FlowFixMe[missing-local-annot]
set: function(newPropTypes) {
error(
"React.lazy(...): It is not supported to assign `propTypes` to " +
Expand Down
6 changes: 4 additions & 2 deletions compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-modern-0b974418c-20230106";
var ReactVersion = "18.3.0-www-modern-0b4f44302-20230109";

// ATTENTION
// When adding new symbols to this file,
Expand Down Expand Up @@ -1311,7 +1311,7 @@ function countChildren(children) {

function forEachChildren(children, forEachFunc, forEachContext) {
mapChildren(
children,
children, // $FlowFixMe[missing-this-annot]
function() {
forEachFunc.apply(this, arguments); // Don't return anything.
},
Expand Down Expand Up @@ -1582,6 +1582,7 @@ function lazy(ctor) {
get: function() {
return defaultProps;
},
// $FlowFixMe[missing-local-annot]
set: function(newDefaultProps) {
error(
"React.lazy(...): It is not supported to assign `defaultProps` to " +
Expand All @@ -1602,6 +1603,7 @@ function lazy(ctor) {
get: function() {
return propTypes;
},
// $FlowFixMe[missing-local-annot]
set: function(newPropTypes) {
error(
"React.lazy(...): It is not supported to assign `propTypes` to " +
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,4 @@ exports.useSyncExternalStore = function(
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-classic-0b974418c-20230106";
exports.version = "18.3.0-www-classic-0b4f44302-20230109";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,4 @@ exports.useSyncExternalStore = function(
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-modern-0b974418c-20230106";
exports.version = "18.3.0-www-modern-0b4f44302-20230109";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ exports.useSyncExternalStore = function(
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-classic-0b974418c-20230106";
exports.version = "18.3.0-www-classic-0b4f44302-20230109";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ exports.useSyncExternalStore = function(
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-modern-0b974418c-20230106";
exports.version = "18.3.0-www-modern-0b4f44302-20230109";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
15 changes: 9 additions & 6 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-classic-0b974418c-20230106";
var ReactVersion = "18.3.0-www-classic-0b4f44302-20230109";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -10963,6 +10963,7 @@ function applyDerivedStateFromProps(

var classComponentUpdater = {
isMounted: isMounted,
// $FlowFixMe[missing-local-annot]
enqueueSetState: function(inst, payload, callback) {
var fiber = get(inst);
var eventTime = requestEventTime();
Expand Down Expand Up @@ -11034,6 +11035,7 @@ var classComponentUpdater = {
markStateUpdateScheduled(fiber, lane);
}
},
// $FlowFixMe[missing-local-annot]
enqueueForceUpdate: function(inst, callback) {
var fiber = get(inst);
var eventTime = requestEventTime();
Expand Down Expand Up @@ -12176,6 +12178,7 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
var inst = fiber.stateNode;

if (inst !== null && typeof inst.componentDidCatch === "function") {
// $FlowFixMe[missing-this-annot]
update.callback = function callback() {
{
markFailedErrorBoundaryForHotReloading(fiber);
Expand Down Expand Up @@ -16971,7 +16974,7 @@ function readContext(context) {

var AbortControllerLocal =
typeof AbortController !== "undefined"
? AbortController
? AbortController // $FlowFixMe[missing-this-annot]
: function AbortControllerShim() {
var listeners = [];
var signal = (this.signal = {
Expand Down Expand Up @@ -24054,8 +24057,7 @@ function markRootSuspended$1(root, suspendedLanes) {
suspendedLanes = removeLanes(
suspendedLanes,
workInProgressRootInterleavedUpdatedLanes
); // $FlowFixMe[incompatible-call] found when upgrading Flow

);
markRootSuspended(root, suspendedLanes);
} // This is the entry point for synchronous tasks that don't go
// through Scheduler
Expand Down Expand Up @@ -24453,6 +24455,7 @@ function renderDidSuspendDelayIfPossible() {
// pinged or updated while we were rendering.
// TODO: Consider unwinding immediately, using the
// SuspendedOnHydration mechanism.
// $FlowFixMe[incompatible-call] need null check workInProgressRoot
markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
}
}
Expand Down Expand Up @@ -26212,7 +26215,7 @@ function restorePendingUpdaters(root, lanes) {
}
}
}
var fakeActCallbackNode = {};
var fakeActCallbackNode = {}; // $FlowFixMe[missing-local-annot]

function scheduleCallback$2(priorityLevel, callback) {
{
Expand Down Expand Up @@ -27479,7 +27482,7 @@ function assignFiberPropertiesInDEV(target, source) {
}

function FiberRootNode(
containerInfo,
containerInfo, // $FlowFixMe[missing-local-annot]
tag,
hydrate,
identifierPrefix,
Expand Down
15 changes: 9 additions & 6 deletions compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-modern-0b974418c-20230106";
var ReactVersion = "18.3.0-www-modern-0b4f44302-20230109";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -10723,6 +10723,7 @@ function applyDerivedStateFromProps(

var classComponentUpdater = {
isMounted: isMounted,
// $FlowFixMe[missing-local-annot]
enqueueSetState: function(inst, payload, callback) {
var fiber = get(inst);
var eventTime = requestEventTime();
Expand Down Expand Up @@ -10794,6 +10795,7 @@ var classComponentUpdater = {
markStateUpdateScheduled(fiber, lane);
}
},
// $FlowFixMe[missing-local-annot]
enqueueForceUpdate: function(inst, callback) {
var fiber = get(inst);
var eventTime = requestEventTime();
Expand Down Expand Up @@ -11904,6 +11906,7 @@ function createClassErrorUpdate(fiber, errorInfo, lane) {
var inst = fiber.stateNode;

if (inst !== null && typeof inst.componentDidCatch === "function") {
// $FlowFixMe[missing-this-annot]
update.callback = function callback() {
{
markFailedErrorBoundaryForHotReloading(fiber);
Expand Down Expand Up @@ -16679,7 +16682,7 @@ function readContext(context) {

var AbortControllerLocal =
typeof AbortController !== "undefined"
? AbortController
? AbortController // $FlowFixMe[missing-this-annot]
: function AbortControllerShim() {
var listeners = [];
var signal = (this.signal = {
Expand Down Expand Up @@ -23743,8 +23746,7 @@ function markRootSuspended$1(root, suspendedLanes) {
suspendedLanes = removeLanes(
suspendedLanes,
workInProgressRootInterleavedUpdatedLanes
); // $FlowFixMe[incompatible-call] found when upgrading Flow

);
markRootSuspended(root, suspendedLanes);
} // This is the entry point for synchronous tasks that don't go
// through Scheduler
Expand Down Expand Up @@ -24142,6 +24144,7 @@ function renderDidSuspendDelayIfPossible() {
// pinged or updated while we were rendering.
// TODO: Consider unwinding immediately, using the
// SuspendedOnHydration mechanism.
// $FlowFixMe[incompatible-call] need null check workInProgressRoot
markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
}
}
Expand Down Expand Up @@ -25901,7 +25904,7 @@ function restorePendingUpdaters(root, lanes) {
}
}
}
var fakeActCallbackNode = {};
var fakeActCallbackNode = {}; // $FlowFixMe[missing-local-annot]

function scheduleCallback$2(priorityLevel, callback) {
{
Expand Down Expand Up @@ -27168,7 +27171,7 @@ function assignFiberPropertiesInDEV(target, source) {
}

function FiberRootNode(
containerInfo,
containerInfo, // $FlowFixMe[missing-local-annot]
tag,
hydrate,
identifierPrefix,
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactART-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -9804,7 +9804,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "18.3.0-www-classic-0b974418c-20230106",
version: "18.3.0-www-classic-0b4f44302-20230109",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1319 = {
Expand Down Expand Up @@ -9835,7 +9835,7 @@ var internals$jscomp$inline_1319 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-0b974418c-20230106"
reconcilerVersion: "18.3.0-next-0b4f44302-20230109"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1320 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactART-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -9471,7 +9471,7 @@ var slice = Array.prototype.slice,
return null;
},
bundleType: 0,
version: "18.3.0-www-modern-0b974418c-20230106",
version: "18.3.0-www-modern-0b4f44302-20230109",
rendererPackageName: "react-art"
};
var internals$jscomp$inline_1310 = {
Expand Down Expand Up @@ -9502,7 +9502,7 @@ var internals$jscomp$inline_1310 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-0b974418c-20230106"
reconcilerVersion: "18.3.0-next-0b4f44302-20230109"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1311 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Loading

0 comments on commit 3075524

Please sign in to comment.