Page MenuHomePhabricator

[Flow202][native][skip-ci] [38/x] Fix exponential-spread issue in RootRouter
ClosedPublic

Authored by ashoat on Nov 27 2023, 1:19 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Dec 22, 8:58 AM
Unknown Object (File)
Sun, Dec 22, 8:58 AM
Unknown Object (File)
Sun, Dec 22, 8:57 AM
Unknown Object (File)
Sun, Dec 22, 8:56 AM
Unknown Object (File)
Sun, Dec 8, 10:54 PM
Unknown Object (File)
Fri, Dec 6, 9:58 AM
Unknown Object (File)
Fri, Dec 6, 2:15 AM
Unknown Object (File)
Wed, Dec 4, 5:42 AM
Subscribers
None

Details

Summary

Flow was printing this error:

Error ---------------------------------------------------------------------------------- navigation/root-router.js:102:8

Computing object literal [1] may lead to an exponentially large number of cases to reason about because inferred union
from object literal [1] | object type [2] and inferred union from object literal [1] | object type [2] are both unions.
Please use at most one union type per spread to simplify reasoning about the spread result. You may be able to get rid
of a union by specifying a more general type that captures all of the branches of the union. [exponential-spread]

 [2]  67|   +state?: { +routes: $ReadOnlyArray<ResetStateRoute>, ... },
        :
      99|
 [1] 100|   let newState = {
     101|     ...oldRoute.state,
     102|     ...newPartialRoute.state,
     103|     routes,
     104|   };
     105|   if (_isEqual(newState)(oldRoute.state)) {

I determined that I could solve the issue by assigning the states to their own local variable and extracting the routes property from them. Flow also needed some cajoling to accept that the states were non-null.

NOTE: CI will fail on this diff. I considered the possibility of fixing Flow errors BEFORE upgrading Flow, but it wasn't possible... in some cases, the fixes to support the new version of Flow caused errors in the old version. I could have hidden these type errors with $FlowFixMe lines and then later revert those, but that seemed like too much busy work.

Depends on D10021

Test Plan

Confirm the Flow errors go away

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable