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 [afea1d0](afea1d0)
  • Loading branch information
kassens committed Mar 27, 2023
1 parent 49e6dee commit 2a33a65
Show file tree
Hide file tree
Showing 25 changed files with 470 additions and 508 deletions.
16 changes: 8 additions & 8 deletions compiled/facebook-www/JSXDEVRuntime-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function disableLogs() {
enumerable: true,
value: disabledLog,
writable: true
}; // $FlowFixMe Flow thinks console is immutable.
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.

Object.defineProperties(console, {
info: props,
Expand All @@ -332,7 +332,7 @@ function reenableLogs() {
configurable: true,
enumerable: true,
writable: true
}; // $FlowFixMe Flow thinks console is immutable.
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.

Object.defineProperties(console, {
log: assign({}, props, {
Expand Down Expand Up @@ -413,7 +413,7 @@ function describeNativeComponentFrame(fn, construct) {

var control;
reentry = true;
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined.

Error.prepareStackTrace = undefined;
var previousDispatcher;
Expand All @@ -432,7 +432,7 @@ function describeNativeComponentFrame(fn, construct) {
// Something should be setting the props in the constructor.
var Fake = function () {
throw Error();
}; // $FlowFixMe
}; // $FlowFixMe[prop-missing]

Object.defineProperty(Fake.prototype, "props", {
set: function () {
Expand Down Expand Up @@ -641,7 +641,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 @@ -735,19 +735,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
16 changes: 8 additions & 8 deletions compiled/facebook-www/JSXDEVRuntime-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function disableLogs() {
enumerable: true,
value: disabledLog,
writable: true
}; // $FlowFixMe Flow thinks console is immutable.
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.

Object.defineProperties(console, {
info: props,
Expand All @@ -332,7 +332,7 @@ function reenableLogs() {
configurable: true,
enumerable: true,
writable: true
}; // $FlowFixMe Flow thinks console is immutable.
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.

Object.defineProperties(console, {
log: assign({}, props, {
Expand Down Expand Up @@ -413,7 +413,7 @@ function describeNativeComponentFrame(fn, construct) {

var control;
reentry = true;
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined.

Error.prepareStackTrace = undefined;
var previousDispatcher;
Expand All @@ -432,7 +432,7 @@ function describeNativeComponentFrame(fn, construct) {
// Something should be setting the props in the constructor.
var Fake = function () {
throw Error();
}; // $FlowFixMe
}; // $FlowFixMe[prop-missing]

Object.defineProperty(Fake.prototype, "props", {
set: function () {
Expand Down Expand Up @@ -641,7 +641,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 @@ -735,19 +735,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
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
768f965de2d4c6be7f688562ef02382478c82e5b
afea1d0c536e0336735b0ea5c74f635527b65785
38 changes: 19 additions & 19 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-1745b9a1";
var ReactVersion = "18.3.0-www-classic-d1164e5e";

// ATTENTION
// When adding new symbols to this file,
Expand Down Expand Up @@ -408,19 +408,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 Expand Up @@ -1126,7 +1126,7 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
{
// The `if` statement here prevents auto-disabling of the safe
// coercion ESLint rule, so we must manually disable it below.
// $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
// $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key
if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
checkKeyStringCoercion(mappedChild.key);
}
Expand All @@ -1135,7 +1135,7 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
mappedChild = cloneAndReplaceKey(
mappedChild, // Keep both the (mapped) and old keys if they differ, just as
// traverseAllChildren used to do for objects as children
escapedPrefix + // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
escapedPrefix + // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key
(mappedChild.key && (!_child || _child.key !== mappedChild.key)
? escapeUserProvidedKey(
// $FlowFixMe[unsafe-addition]
Expand Down Expand Up @@ -1192,7 +1192,7 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {

var iterator = iteratorFn.call(iterableChildren);
var step;
var ii = 0; // $FlowFixMe `iteratorFn` might return null according to typing.
var ii = 0; // $FlowFixMe[incompatible-use] `iteratorFn` might return null according to typing.

while (!(step = iterator.next()).done) {
child = step.value;
Expand Down Expand Up @@ -1363,7 +1363,7 @@ function createContext(defaultValue) {
var Consumer = {
$$typeof: REACT_CONTEXT_TYPE,
_context: context
}; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
}; // $FlowFixMe[prop-missing]: Flow complains about not setting a value, which is intentional here

Object.defineProperties(Consumer, {
Provider: {
Expand Down Expand Up @@ -1437,7 +1437,7 @@ function createContext(defaultValue) {
}
}
}
}); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
}); // $FlowFixMe[prop-missing]: Flow complains about missing properties because it doesn't understand defineProperty

context.Consumer = Consumer;
}
Expand Down Expand Up @@ -1543,7 +1543,7 @@ function lazy(ctor) {
{
// In production, this would just set it on the object.
var defaultProps;
var propTypes; // $FlowFixMe
var propTypes; // $FlowFixMe[prop-missing]

Object.defineProperties(lazyType, {
defaultProps: {
Expand All @@ -1560,7 +1560,7 @@ function lazy(ctor) {
);

defaultProps = newDefaultProps; // Match production behavior more closely:
// $FlowFixMe
// $FlowFixMe[prop-missing]

Object.defineProperty(lazyType, "defaultProps", {
enumerable: true
Expand All @@ -1581,7 +1581,7 @@ function lazy(ctor) {
);

propTypes = newPropTypes; // Match production behavior more closely:
// $FlowFixMe
// $FlowFixMe[prop-missing]

Object.defineProperty(lazyType, "propTypes", {
enumerable: true
Expand Down Expand Up @@ -1779,7 +1779,7 @@ function cache(fn) {

if (!dispatcher) {
// If there is no dispatcher, then we treat this as not being cached.
// $FlowFixMe: We don't want to use rest arguments since we transpile the code.
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
return fn.apply(null, arguments);
}

Expand Down Expand Up @@ -1844,7 +1844,7 @@ function cache(fn) {
}

try {
// $FlowFixMe: We don't want to use rest arguments since we transpile the code.
// $FlowFixMe[incompatible-call]: We don't want to use rest arguments since we transpile the code.
var result = fn.apply(null, arguments);
var terminatedNode = cacheNode;
terminatedNode.s = TERMINATED;
Expand Down Expand Up @@ -2064,7 +2064,7 @@ function disableLogs() {
enumerable: true,
value: disabledLog,
writable: true
}; // $FlowFixMe Flow thinks console is immutable.
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.

Object.defineProperties(console, {
info: props,
Expand All @@ -2091,7 +2091,7 @@ function reenableLogs() {
configurable: true,
enumerable: true,
writable: true
}; // $FlowFixMe Flow thinks console is immutable.
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.

Object.defineProperties(console, {
log: assign({}, props, {
Expand Down Expand Up @@ -2240,7 +2240,7 @@ function describeNativeComponentFrame(fn, construct) {

var control;
reentry = true;
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe[incompatible-type] It does accept undefined.

Error.prepareStackTrace = undefined;
var previousDispatcher;
Expand All @@ -2259,7 +2259,7 @@ function describeNativeComponentFrame(fn, construct) {
// Something should be setting the props in the constructor.
var Fake = function () {
throw Error();
}; // $FlowFixMe
}; // $FlowFixMe[prop-missing]

Object.defineProperty(Fake.prototype, "props", {
set: function () {
Expand Down Expand Up @@ -2465,7 +2465,7 @@ function setCurrentlyValidatingElement$2(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
Loading

0 comments on commit 2a33a65

Please sign in to comment.