Skip to content

Commit 6aa38e7

Browse files
authored
Flow: enable unsafe-addition error (#25242)
1 parent ba7b6f4 commit 6aa38e7

File tree

10 files changed

+18
-5
lines changed

10 files changed

+18
-5
lines changed

packages/react-devtools-shared/src/devtools/store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ export default class Store extends EventEmitter<{
681681
let depth = 0;
682682
while (parentID > 0) {
683683
if (parentID === ownerID || unsortedIDs.has(parentID)) {
684+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
684685
depth = depthMap.get(parentID) + 1;
685686
depthMap.set(id, depth);
686687
break;

packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
505505
if (numPrevSearchResults > 0) {
506506
didRequestSearch = true;
507507
searchIndex =
508+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
508509
searchIndex + 1 < numPrevSearchResults ? searchIndex + 1 : 0;
509510
}
510511
break;

packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ export default function SnapshotSelector(_: Props) {
126126
type="text"
127127
inputMode="numeric"
128128
pattern="[0-9]*"
129-
value={selectedFilteredCommitIndex + 1}
129+
value={
130+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
131+
selectedFilteredCommitIndex + 1
132+
}
130133
size={`${numFilteredCommits}`.length}
131134
onChange={handleCommitInputChange}
132135
onClick={handleClick}

packages/react-reconciler/src/ReactFiberCompleteWork.new.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,10 @@ function bubbleProperties(completedWork: Fiber) {
662662
// this value will reflect the amount of time spent working on a previous
663663
// render. In that case it should not bubble. We determine whether it was
664664
// cloned by comparing the child pointer.
665+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
665666
actualDuration += child.actualDuration;
666667

668+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
667669
treeBaseDuration += child.treeBaseDuration;
668670
child = child.sibling;
669671
}
@@ -712,6 +714,7 @@ function bubbleProperties(completedWork: Fiber) {
712714
subtreeFlags |= child.subtreeFlags & StaticMask;
713715
subtreeFlags |= child.flags & StaticMask;
714716

717+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
715718
treeBaseDuration += child.treeBaseDuration;
716719
child = child.sibling;
717720
}

packages/react-reconciler/src/ReactFiberCompleteWork.old.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,10 @@ function bubbleProperties(completedWork: Fiber) {
662662
// this value will reflect the amount of time spent working on a previous
663663
// render. In that case it should not bubble. We determine whether it was
664664
// cloned by comparing the child pointer.
665+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
665666
actualDuration += child.actualDuration;
666667

668+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
667669
treeBaseDuration += child.treeBaseDuration;
668670
child = child.sibling;
669671
}
@@ -712,6 +714,7 @@ function bubbleProperties(completedWork: Fiber) {
712714
subtreeFlags |= child.subtreeFlags & StaticMask;
713715
subtreeFlags |= child.flags & StaticMask;
714716

717+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
715718
treeBaseDuration += child.treeBaseDuration;
716719
child = child.sibling;
717720
}

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
22172217
let actualDuration = completedWork.actualDuration;
22182218
let child = completedWork.child;
22192219
while (child !== null) {
2220+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
22202221
actualDuration += child.actualDuration;
22212222
child = child.sibling;
22222223
}

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
22172217
let actualDuration = completedWork.actualDuration;
22182218
let child = completedWork.child;
22192219
while (child !== null) {
2220+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
22202221
actualDuration += child.actualDuration;
22212222
child = child.sibling;
22222223
}

packages/react-reconciler/src/ReactProfilerTimer.new.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(
122122

123123
if (profilerStartTime >= 0) {
124124
const elapsedTime = now() - profilerStartTime;
125+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
125126
fiber.actualDuration += elapsedTime;
126127
if (overrideBaseTime) {
127128
fiber.selfBaseDuration = elapsedTime;
@@ -215,6 +216,7 @@ function transferActualDuration(fiber: Fiber): void {
215216
// where we should count the work of multiple passes.
216217
let child = fiber.child;
217218
while (child) {
219+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
218220
fiber.actualDuration += child.actualDuration;
219221
child = child.sibling;
220222
}

packages/react-reconciler/src/ReactProfilerTimer.old.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(
122122

123123
if (profilerStartTime >= 0) {
124124
const elapsedTime = now() - profilerStartTime;
125+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
125126
fiber.actualDuration += elapsedTime;
126127
if (overrideBaseTime) {
127128
fiber.selfBaseDuration = elapsedTime;
@@ -215,6 +216,7 @@ function transferActualDuration(fiber: Fiber): void {
215216
// where we should count the work of multiple passes.
216217
let child = fiber.child;
217218
while (child) {
219+
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
218220
fiber.actualDuration += child.actualDuration;
219221
child = child.sibling;
220222
}

scripts/flow/config/flowconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
[lints]
3939
untyped-type-import=error
4040

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-
4541
[options]
4642
server.max_workers=4
4743
esproposal.class_static_fields=enable

0 commit comments

Comments
 (0)