Skip to content

Commit

Permalink
[flow] make Flow suppressions explicit on the error (#26487)
Browse files Browse the repository at this point in the history
Added an explicit type to all $FlowFixMe suppressions to reduce
over-suppressions of new errors that might be caused on the same lines.

Also removes suppressions that aren't used (e.g. in a `@noflow` file as
they're purely misleading)

Test Plan:
yarn flow-ci

DiffTrain build for commit afea1d0.
  • Loading branch information
kassens committed Mar 27, 2023
1 parent 7f1afb7 commit ae98316
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,7 @@ function setCurrentlyValidatingElement(element) {

function checkPropTypes(typeSpecs, values, location, componentName, element) {
{
// $FlowFixMe This is okay but Flow doesn't know it.
// $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it.
var has = Function.call.bind(hasOwnProperty);

for (var typeSpecName in typeSpecs) {
Expand Down Expand Up @@ -4114,19 +4114,19 @@ var ReactStrictModeWarnings = {
* problem. (Instead of a confusing exception thrown inside the implementation
* of the `value` object).
*/
// $FlowFixMe only called in DEV, so void return is not possible.
// $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
function typeName(value) {
{
// toStringTag is needed for namespaced types like Temporal.Instant
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
var type =
(hasToStringTag && value[Symbol.toStringTag]) ||
value.constructor.name ||
"Object"; // $FlowFixMe
"Object"; // $FlowFixMe[incompatible-return]

return type;
}
} // $FlowFixMe only called in DEV, so void return is not possible.
} // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.

function willCoercionThrow(value) {
{
Expand Down Expand Up @@ -4385,7 +4385,7 @@ var warnForMissingKey = function (child, returnFiber) {};
"React Component in warnForMissingKey should have a _store. " +
"This error is likely caused by a bug in React. Please file an issue."
);
} // $FlowFixMe unable to narrow type from mixed to writable object
} // $FlowFixMe[cannot-write] unable to narrow type from mixed to writable object

child._store.validated = true;
var componentName = getComponentNameFromFiber(returnFiber) || "Component";
Expand Down Expand Up @@ -5301,7 +5301,7 @@ function createChildReconciler(shouldTrackSideEffects) {
// We don't support rendering Generators because it's a mutation.
// See https://github.com/facebook/react/issues/12995
if (
typeof Symbol === "function" && // $FlowFixMe Flow doesn't know about toStringTag
typeof Symbol === "function" && // $FlowFixMe[prop-missing] Flow doesn't know about toStringTag
newChildrenIterable[Symbol.toStringTag] === "Generator"
) {
if (!didWarnAboutGenerators) {
Expand Down Expand Up @@ -6759,7 +6759,7 @@ function use(usable) {
}

function basicStateReducer(state, action) {
// $FlowFixMe: Flow doesn't like mixed types
// $FlowFixMe[incompatible-use]: Flow doesn't like mixed types
return typeof action === "function" ? action(state) : action;
}

Expand Down Expand Up @@ -7219,7 +7219,7 @@ function mountState(initialState) {
var hook = mountWorkInProgressHook();

if (typeof initialState === "function") {
// $FlowFixMe: Flow doesn't like mixed types
// $FlowFixMe[incompatible-use]: Flow doesn't like mixed types
initialState = initialState();
}

Expand Down Expand Up @@ -14871,7 +14871,7 @@ function completeDehydratedSuspenseBoundary(
var primaryChildFragment = workInProgress.child;

if (primaryChildFragment !== null) {
// $FlowFixMe Flow doesn't support type casting in combination with the -= operator
// $FlowFixMe[unsafe-arithmetic] Flow doesn't support type casting in combination with the -= operator
workInProgress.treeBaseDuration -=
primaryChildFragment.treeBaseDuration;
}
Expand Down Expand Up @@ -14902,7 +14902,7 @@ function completeDehydratedSuspenseBoundary(
var _primaryChildFragment = workInProgress.child;

if (_primaryChildFragment !== null) {
// $FlowFixMe Flow doesn't support type casting in combination with the -= operator
// $FlowFixMe[unsafe-arithmetic] Flow doesn't support type casting in combination with the -= operator
workInProgress.treeBaseDuration -=
_primaryChildFragment.treeBaseDuration;
}
Expand Down Expand Up @@ -15234,7 +15234,7 @@ function completeWork(current, workInProgress, renderLanes) {
var primaryChildFragment = workInProgress.child;

if (primaryChildFragment !== null) {
// $FlowFixMe Flow doesn't support type casting in combination with the -= operator
// $FlowFixMe[unsafe-arithmetic] Flow doesn't support type casting in combination with the -= operator
workInProgress.treeBaseDuration -=
primaryChildFragment.treeBaseDuration;
}
Expand Down Expand Up @@ -16162,7 +16162,7 @@ function safelyDetachRef(current, nearestMountedAncestor) {
}
}
} else {
// $FlowFixMe unable to narrow type to RefObject
// $FlowFixMe[incompatible-use] unable to narrow type to RefObject
ref.current = null;
}
}
Expand Down Expand Up @@ -17076,7 +17076,7 @@ function commitAttachRef(finishedWork) {
getComponentNameFromFiber(finishedWork)
);
}
} // $FlowFixMe unable to narrow type to the non-function case
} // $FlowFixMe[incompatible-use] unable to narrow type to the non-function case

ref.current = instanceToUse;
}
Expand Down Expand Up @@ -19487,7 +19487,7 @@ function isLegacyActEnvironment(fiber) {
var isReactActEnvironmentGlobal = // $FlowFixMe[cannot-resolve-name] Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global
typeof IS_REACT_ACT_ENVIRONMENT !== "undefined" // $FlowFixMe[cannot-resolve-name]
? IS_REACT_ACT_ENVIRONMENT
: undefined; // $FlowFixMe - Flow doesn't know about jest
: undefined; // $FlowFixMe[cannot-resolve-name] - Flow doesn't know about jest

var jestIsDefined = typeof jest !== "undefined";
return jestIsDefined && isReactActEnvironmentGlobal !== false;
Expand Down Expand Up @@ -20649,7 +20649,7 @@ function prepareFreshStack(root, lanes) {
if (timeoutHandle !== noTimeout) {
// The root previous suspended and scheduled a timeout to commit a fallback
// state. Now that we have additional work, cancel the timeout.
root.timeoutHandle = noTimeout; // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above
root.timeoutHandle = noTimeout; // $FlowFixMe[incompatible-call] Complains noTimeout is not a TimeoutID, despite the check above

cancelTimeout(timeoutHandle);
}
Expand Down Expand Up @@ -23149,7 +23149,7 @@ function FiberNode(tag, pendingProps, key, mode) {
// compatible.

function createFiber(tag, pendingProps, key, mode) {
// $FlowFixMe: the shapes are exact here but Flow doesn't like constructors
// $FlowFixMe[invalid-constructor]: the shapes are exact here but Flow doesn't like constructors
return new FiberNode(tag, pendingProps, key, mode);
}

Expand Down Expand Up @@ -23762,7 +23762,7 @@ function createFiberRoot(
return root;
}

var ReactVersion = "18.3.0-next-768f965de-20230326";
var ReactVersion = "18.3.0-next-afea1d0c5-20230327";

// Might add PROFILE later.

Expand Down Expand Up @@ -23932,7 +23932,7 @@ var setSuspenseHandler = null;
}

return updated;
} // $FlowFixMe number or string is fine here
} // $FlowFixMe[incompatible-use] number or string is fine here

updated[key] = copyWithDeleteImpl(obj[key], path, index + 1);
return updated;
Expand All @@ -23947,7 +23947,7 @@ var setSuspenseHandler = null;
var updated = isArray(obj) ? obj.slice() : assign({}, obj);

if (index + 1 === oldPath.length) {
var newKey = newPath[index]; // $FlowFixMe number or string is fine here
var newKey = newPath[index]; // $FlowFixMe[incompatible-use] number or string is fine here

updated[newKey] = updated[oldKey];

Expand All @@ -23957,9 +23957,9 @@ var setSuspenseHandler = null;
delete updated[oldKey];
}
} else {
// $FlowFixMe number or string is fine here
// $FlowFixMe[incompatible-use] number or string is fine here
updated[oldKey] = copyWithRenameImpl(
// $FlowFixMe number or string is fine here
// $FlowFixMe[incompatible-use] number or string is fine here
obj[oldKey],
oldPath,
newPath,
Expand Down Expand Up @@ -23996,7 +23996,7 @@ var setSuspenseHandler = null;
}

var key = path[index];
var updated = isArray(obj) ? obj.slice() : assign({}, obj); // $FlowFixMe number or string is fine here
var updated = isArray(obj) ? obj.slice() : assign({}, obj); // $FlowFixMe[incompatible-use] number or string is fine here

updated[key] = copyWithSetImpl(obj[key], path, index + 1, value);
return updated;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8640,7 +8640,7 @@ var devToolsConfig$jscomp$inline_1007 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-next-768f965de-20230326",
version: "18.3.0-next-afea1d0c5-20230327",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1198 = {
Expand Down Expand Up @@ -8671,7 +8671,7 @@ var internals$jscomp$inline_1198 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-768f965de-20230326"
reconcilerVersion: "18.3.0-next-afea1d0c5-20230327"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1199 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9065,7 +9065,7 @@ var devToolsConfig$jscomp$inline_1050 = {
throw Error("TestRenderer does not support findFiberByHostInstance()");
},
bundleType: 0,
version: "18.3.0-next-768f965de-20230326",
version: "18.3.0-next-afea1d0c5-20230327",
rendererPackageName: "react-test-renderer"
};
var internals$jscomp$inline_1239 = {
Expand Down Expand Up @@ -9096,7 +9096,7 @@ var internals$jscomp$inline_1239 = {
scheduleRoot: null,
setRefreshHandler: null,
getCurrentFiber: null,
reconcilerVersion: "18.3.0-next-768f965de-20230326"
reconcilerVersion: "18.3.0-next-afea1d0c5-20230327"
};
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
var hook$jscomp$inline_1240 = __REACT_DEVTOOLS_GLOBAL_HOOK__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ function setCurrentlyValidatingElement$1(element) {

function checkPropTypes(typeSpecs, values, location, componentName, element) {
{
// $FlowFixMe This is okay but Flow doesn't know it.
// $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it.
var has = Function.call.bind(hasOwnProperty);

for (var typeSpecName in typeSpecs) {
Expand Down Expand Up @@ -487,19 +487,19 @@ function isArray(a) {
* problem. (Instead of a confusing exception thrown inside the implementation
* of the `value` object).
*/
// $FlowFixMe only called in DEV, so void return is not possible.
// $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
function typeName(value) {
{
// toStringTag is needed for namespaced types like Temporal.Instant
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
var type =
(hasToStringTag && value[Symbol.toStringTag]) ||
value.constructor.name ||
"Object"; // $FlowFixMe
"Object"; // $FlowFixMe[incompatible-return]

return type;
}
} // $FlowFixMe only called in DEV, so void return is not possible.
} // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.

function willCoercionThrow(value) {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ function setCurrentlyValidatingElement$1(element) {

function checkPropTypes(typeSpecs, values, location, componentName, element) {
{
// $FlowFixMe This is okay but Flow doesn't know it.
// $FlowFixMe[incompatible-use] This is okay but Flow doesn't know it.
var has = Function.call.bind(hasOwnProperty);

for (var typeSpecName in typeSpecs) {
Expand Down Expand Up @@ -487,19 +487,19 @@ function isArray(a) {
* problem. (Instead of a confusing exception thrown inside the implementation
* of the `value` object).
*/
// $FlowFixMe only called in DEV, so void return is not possible.
// $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
function typeName(value) {
{
// toStringTag is needed for namespaced types like Temporal.Instant
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
var type =
(hasToStringTag && value[Symbol.toStringTag]) ||
value.constructor.name ||
"Object"; // $FlowFixMe
"Object"; // $FlowFixMe[incompatible-return]

return type;
}
} // $FlowFixMe only called in DEV, so void return is not possible.
} // $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.

function willCoercionThrow(value) {
{
Expand Down
Loading

0 comments on commit ae98316

Please sign in to comment.