Skip to content

Commit 2a33a65

Browse files
committed
[flow] make Flow suppressions explicit on the error (#26487)
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)
1 parent 49e6dee commit 2a33a65

25 files changed

+470
-508
lines changed

compiled/facebook-www/JSXDEVRuntime-dev.classic.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ function disableLogs() {
305305
enumerable: true,
306306
value: disabledLog,
307307
writable: true
308-
}; // $FlowFixMe Flow thinks console is immutable.
308+
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.
309309

310310
Object.defineProperties(console, {
311311
info: props,
@@ -332,7 +332,7 @@ function reenableLogs() {
332332
configurable: true,
333333
enumerable: true,
334334
writable: true
335-
}; // $FlowFixMe Flow thinks console is immutable.
335+
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.
336336

337337
Object.defineProperties(console, {
338338
log: assign({}, props, {
@@ -413,7 +413,7 @@ function describeNativeComponentFrame(fn, construct) {
413413

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

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

437437
Object.defineProperty(Fake.prototype, "props", {
438438
set: function () {
@@ -641,7 +641,7 @@ function setCurrentlyValidatingElement$1(element) {
641641

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

647647
for (var typeSpecName in typeSpecs) {
@@ -735,19 +735,19 @@ function isArray(a) {
735735
* problem. (Instead of a confusing exception thrown inside the implementation
736736
* of the `value` object).
737737
*/
738-
// $FlowFixMe only called in DEV, so void return is not possible.
738+
// $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
739739
function typeName(value) {
740740
{
741741
// toStringTag is needed for namespaced types like Temporal.Instant
742742
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
743743
var type =
744744
(hasToStringTag && value[Symbol.toStringTag]) ||
745745
value.constructor.name ||
746-
"Object"; // $FlowFixMe
746+
"Object"; // $FlowFixMe[incompatible-return]
747747

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

752752
function willCoercionThrow(value) {
753753
{

compiled/facebook-www/JSXDEVRuntime-dev.modern.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ function disableLogs() {
305305
enumerable: true,
306306
value: disabledLog,
307307
writable: true
308-
}; // $FlowFixMe Flow thinks console is immutable.
308+
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.
309309

310310
Object.defineProperties(console, {
311311
info: props,
@@ -332,7 +332,7 @@ function reenableLogs() {
332332
configurable: true,
333333
enumerable: true,
334334
writable: true
335-
}; // $FlowFixMe Flow thinks console is immutable.
335+
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.
336336

337337
Object.defineProperties(console, {
338338
log: assign({}, props, {
@@ -413,7 +413,7 @@ function describeNativeComponentFrame(fn, construct) {
413413

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

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

437437
Object.defineProperty(Fake.prototype, "props", {
438438
set: function () {
@@ -641,7 +641,7 @@ function setCurrentlyValidatingElement$1(element) {
641641

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

647647
for (var typeSpecName in typeSpecs) {
@@ -735,19 +735,19 @@ function isArray(a) {
735735
* problem. (Instead of a confusing exception thrown inside the implementation
736736
* of the `value` object).
737737
*/
738-
// $FlowFixMe only called in DEV, so void return is not possible.
738+
// $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
739739
function typeName(value) {
740740
{
741741
// toStringTag is needed for namespaced types like Temporal.Instant
742742
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
743743
var type =
744744
(hasToStringTag && value[Symbol.toStringTag]) ||
745745
value.constructor.name ||
746-
"Object"; // $FlowFixMe
746+
"Object"; // $FlowFixMe[incompatible-return]
747747

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

752752
function willCoercionThrow(value) {
753753
{

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
768f965de2d4c6be7f688562ef02382478c82e5b
1+
afea1d0c536e0336735b0ea5c74f635527b65785

compiled/facebook-www/React-dev.classic.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-www-classic-1745b9a1";
30+
var ReactVersion = "18.3.0-www-classic-d1164e5e";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,
@@ -408,19 +408,19 @@ function isArray(a) {
408408
* problem. (Instead of a confusing exception thrown inside the implementation
409409
* of the `value` object).
410410
*/
411-
// $FlowFixMe only called in DEV, so void return is not possible.
411+
// $FlowFixMe[incompatible-return] only called in DEV, so void return is not possible.
412412
function typeName(value) {
413413
{
414414
// toStringTag is needed for namespaced types like Temporal.Instant
415415
var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
416416
var type =
417417
(hasToStringTag && value[Symbol.toStringTag]) ||
418418
value.constructor.name ||
419-
"Object"; // $FlowFixMe
419+
"Object"; // $FlowFixMe[incompatible-return]
420420

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

425425
function willCoercionThrow(value) {
426426
{
@@ -1126,7 +1126,7 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
11261126
{
11271127
// The `if` statement here prevents auto-disabling of the safe
11281128
// coercion ESLint rule, so we must manually disable it below.
1129-
// $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
1129+
// $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key
11301130
if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {
11311131
checkKeyStringCoercion(mappedChild.key);
11321132
}
@@ -1135,7 +1135,7 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
11351135
mappedChild = cloneAndReplaceKey(
11361136
mappedChild, // Keep both the (mapped) and old keys if they differ, just as
11371137
// traverseAllChildren used to do for objects as children
1138-
escapedPrefix + // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key
1138+
escapedPrefix + // $FlowFixMe[incompatible-type] Flow incorrectly thinks React.Portal doesn't have a key
11391139
(mappedChild.key && (!_child || _child.key !== mappedChild.key)
11401140
? escapeUserProvidedKey(
11411141
// $FlowFixMe[unsafe-addition]
@@ -1192,7 +1192,7 @@ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
11921192

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

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

13681368
Object.defineProperties(Consumer, {
13691369
Provider: {
@@ -1437,7 +1437,7 @@ function createContext(defaultValue) {
14371437
}
14381438
}
14391439
}
1440-
}); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
1440+
}); // $FlowFixMe[prop-missing]: Flow complains about missing properties because it doesn't understand defineProperty
14411441

14421442
context.Consumer = Consumer;
14431443
}
@@ -1543,7 +1543,7 @@ function lazy(ctor) {
15431543
{
15441544
// In production, this would just set it on the object.
15451545
var defaultProps;
1546-
var propTypes; // $FlowFixMe
1546+
var propTypes; // $FlowFixMe[prop-missing]
15471547

15481548
Object.defineProperties(lazyType, {
15491549
defaultProps: {
@@ -1560,7 +1560,7 @@ function lazy(ctor) {
15601560
);
15611561

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

15651565
Object.defineProperty(lazyType, "defaultProps", {
15661566
enumerable: true
@@ -1581,7 +1581,7 @@ function lazy(ctor) {
15811581
);
15821582

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

15861586
Object.defineProperty(lazyType, "propTypes", {
15871587
enumerable: true
@@ -1779,7 +1779,7 @@ function cache(fn) {
17791779

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

@@ -1844,7 +1844,7 @@ function cache(fn) {
18441844
}
18451845

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

20692069
Object.defineProperties(console, {
20702070
info: props,
@@ -2091,7 +2091,7 @@ function reenableLogs() {
20912091
configurable: true,
20922092
enumerable: true,
20932093
writable: true
2094-
}; // $FlowFixMe Flow thinks console is immutable.
2094+
}; // $FlowFixMe[cannot-write] Flow thinks console is immutable.
20952095

20962096
Object.defineProperties(console, {
20972097
log: assign({}, props, {
@@ -2240,7 +2240,7 @@ function describeNativeComponentFrame(fn, construct) {
22402240

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

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

22642264
Object.defineProperty(Fake.prototype, "props", {
22652265
set: function () {
@@ -2465,7 +2465,7 @@ function setCurrentlyValidatingElement$2(element) {
24652465

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

24712471
for (var typeSpecName in typeSpecs) {

0 commit comments

Comments
 (0)