Flow: enable unsafe-addition error (#25242)
Jan Kassens committed
Sep 12, 2022 at 16:22 UTC
6aa38e74c7960465db4cf4377e26abb3a205f5d9
10 files changed
+18
-5
packages/react-devtools-shared/src/devtools/store.js
+1
@@ -681,6 +681,7 @@ export default class Store extends EventEmitter<{
681
let depth = 0;
682
while (parentID > 0) {
683
if (parentID === ownerID || unsortedIDs.has(parentID)) {
684
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
685
depth = depthMap.get(parentID) + 1;
686
depthMap.set(id, depth);
687
break;
packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js
+1
@@ -505,6 +505,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
505
if (numPrevSearchResults > 0) {
506
didRequestSearch = true;
507
searchIndex =
508
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
509
searchIndex + 1 < numPrevSearchResults ? searchIndex + 1 : 0;
510
}
511
break;
packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js
+4
-1
@@ -126,7 +126,10 @@ export default function SnapshotSelector(_: Props) {
126
type="text"
127
inputMode="numeric"
128
pattern="[0-9]*"
129
- value={selectedFilteredCommitIndex + 1}
129
+ value={
130
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
131
+ selectedFilteredCommitIndex + 1
132
+ }
133
size={`${numFilteredCommits}`.length}
134
onChange={handleCommitInputChange}
135
onClick={handleClick}
packages/react-reconciler/src/ReactFiberCompleteWork.new.js
+3
@@ -662,8 +662,10 @@ function bubbleProperties(completedWork: Fiber) {
662
// this value will reflect the amount of time spent working on a previous
663
// render. In that case it should not bubble. We determine whether it was
664
// cloned by comparing the child pointer.
665
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
666
actualDuration += child.actualDuration;
667
668
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
669
treeBaseDuration += child.treeBaseDuration;
670
child = child.sibling;
671
}
@@ -712,6 +714,7 @@ function bubbleProperties(completedWork: Fiber) {
714
subtreeFlags |= child.subtreeFlags & StaticMask;
715
subtreeFlags |= child.flags & StaticMask;
716
717
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
718
treeBaseDuration += child.treeBaseDuration;
719
child = child.sibling;
720
}
packages/react-reconciler/src/ReactFiberCompleteWork.old.js
+3
@@ -662,8 +662,10 @@ function bubbleProperties(completedWork: Fiber) {
662
// this value will reflect the amount of time spent working on a previous
663
// render. In that case it should not bubble. We determine whether it was
664
// cloned by comparing the child pointer.
665
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
666
actualDuration += child.actualDuration;
667
668
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
669
treeBaseDuration += child.treeBaseDuration;
670
child = child.sibling;
671
}
@@ -712,6 +714,7 @@ function bubbleProperties(completedWork: Fiber) {
714
subtreeFlags |= child.subtreeFlags & StaticMask;
715
subtreeFlags |= child.flags & StaticMask;
716
717
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
718
treeBaseDuration += child.treeBaseDuration;
719
child = child.sibling;
720
}
packages/react-reconciler/src/ReactFiberWorkLoop.new.js
+1
@@ -2217,6 +2217,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
2217
let actualDuration = completedWork.actualDuration;
2218
let child = completedWork.child;
2219
while (child !== null) {
2220
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
2221
actualDuration += child.actualDuration;
2222
child = child.sibling;
2223
}
packages/react-reconciler/src/ReactFiberWorkLoop.old.js
+1
@@ -2217,6 +2217,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
2217
let actualDuration = completedWork.actualDuration;
2218
let child = completedWork.child;
2219
while (child !== null) {
2220
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
2221
actualDuration += child.actualDuration;
2222
child = child.sibling;
2223
}
packages/react-reconciler/src/ReactProfilerTimer.new.js
+2
@@ -122,6 +122,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(
122
123
if (profilerStartTime >= 0) {
124
const elapsedTime = now() - profilerStartTime;
125
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
126
fiber.actualDuration += elapsedTime;
127
if (overrideBaseTime) {
128
fiber.selfBaseDuration = elapsedTime;
@@ -215,6 +216,7 @@ function transferActualDuration(fiber: Fiber): void {
216
// where we should count the work of multiple passes.
217
let child = fiber.child;
218
while (child) {
219
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
220
fiber.actualDuration += child.actualDuration;
221
child = child.sibling;
222
}
packages/react-reconciler/src/ReactProfilerTimer.old.js
+2
@@ -122,6 +122,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(
122
123
if (profilerStartTime >= 0) {
124
const elapsedTime = now() - profilerStartTime;
125
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
126
fiber.actualDuration += elapsedTime;
127
if (overrideBaseTime) {
128
fiber.selfBaseDuration = elapsedTime;
@@ -215,6 +216,7 @@ function transferActualDuration(fiber: Fiber): void {
216
// where we should count the work of multiple passes.
217
let child = fiber.child;
218
while (child) {
219
+ // $FlowFixMe[unsafe-addition] addition with possible null/undefined value
220
fiber.actualDuration += child.actualDuration;
221
child = child.sibling;
222
}
scripts/flow/config/flowconfig
-4
@@ -38,10 +38,6 @@
38
[lints]
39
untyped-type-import=error
40
41
-# TODO: We might want to enable this this as a error (the default), it
42
-# disallows adding undefined and numbers.
43
-unsafe-addition=off
44
-
41
[options]
42
server.max_workers=4
43
esproposal.class_static_fields=enable