Skip to content

Commit

Permalink
Flow: enable unsafe-addition error (#25242)
Browse files Browse the repository at this point in the history
  • Loading branch information
kassens authored Sep 12, 2022
1 parent ba7b6f4 commit 6aa38e7
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/react-devtools-shared/src/devtools/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ export default class Store extends EventEmitter<{
let depth = 0;
while (parentID > 0) {
if (parentID === ownerID || unsortedIDs.has(parentID)) {
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
depth = depthMap.get(parentID) + 1;
depthMap.set(id, depth);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ function reduceSearchState(store: Store, state: State, action: Action): State {
if (numPrevSearchResults > 0) {
didRequestSearch = true;
searchIndex =
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
searchIndex + 1 < numPrevSearchResults ? searchIndex + 1 : 0;
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ export default function SnapshotSelector(_: Props) {
type="text"
inputMode="numeric"
pattern="[0-9]*"
value={selectedFilteredCommitIndex + 1}
value={
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
selectedFilteredCommitIndex + 1
}
size={`${numFilteredCommits}`.length}
onChange={handleCommitInputChange}
onClick={handleClick}
Expand Down
3 changes: 3 additions & 0 deletions packages/react-reconciler/src/ReactFiberCompleteWork.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,10 @@ function bubbleProperties(completedWork: Fiber) {
// this value will reflect the amount of time spent working on a previous
// render. In that case it should not bubble. We determine whether it was
// cloned by comparing the child pointer.
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
actualDuration += child.actualDuration;

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

// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
treeBaseDuration += child.treeBaseDuration;
child = child.sibling;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/react-reconciler/src/ReactFiberCompleteWork.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,10 @@ function bubbleProperties(completedWork: Fiber) {
// this value will reflect the amount of time spent working on a previous
// render. In that case it should not bubble. We determine whether it was
// cloned by comparing the child pointer.
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
actualDuration += child.actualDuration;

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

// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
treeBaseDuration += child.treeBaseDuration;
child = child.sibling;
}
Expand Down
1 change: 1 addition & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
let actualDuration = completedWork.actualDuration;
let child = completedWork.child;
while (child !== null) {
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
actualDuration += child.actualDuration;
child = child.sibling;
}
Expand Down
1 change: 1 addition & 0 deletions packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,7 @@ function completeUnitOfWork(unitOfWork: Fiber): void {
let actualDuration = completedWork.actualDuration;
let child = completedWork.child;
while (child !== null) {
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
actualDuration += child.actualDuration;
child = child.sibling;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/react-reconciler/src/ReactProfilerTimer.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(

if (profilerStartTime >= 0) {
const elapsedTime = now() - profilerStartTime;
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
fiber.actualDuration += elapsedTime;
if (overrideBaseTime) {
fiber.selfBaseDuration = elapsedTime;
Expand Down Expand Up @@ -215,6 +216,7 @@ function transferActualDuration(fiber: Fiber): void {
// where we should count the work of multiple passes.
let child = fiber.child;
while (child) {
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
fiber.actualDuration += child.actualDuration;
child = child.sibling;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/react-reconciler/src/ReactProfilerTimer.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(

if (profilerStartTime >= 0) {
const elapsedTime = now() - profilerStartTime;
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
fiber.actualDuration += elapsedTime;
if (overrideBaseTime) {
fiber.selfBaseDuration = elapsedTime;
Expand Down Expand Up @@ -215,6 +216,7 @@ function transferActualDuration(fiber: Fiber): void {
// where we should count the work of multiple passes.
let child = fiber.child;
while (child) {
// $FlowFixMe[unsafe-addition] addition with possible null/undefined value
fiber.actualDuration += child.actualDuration;
child = child.sibling;
}
Expand Down
4 changes: 0 additions & 4 deletions scripts/flow/config/flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
[lints]
untyped-type-import=error

# TODO: We might want to enable this this as a error (the default), it
# disallows adding undefined and numbers.
unsafe-addition=off

[options]
server.max_workers=4
esproposal.class_static_fields=enable
Expand Down

0 comments on commit 6aa38e7

Please sign in to comment.