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)
Mar 5 2024, 7:43 AM
Unknown Object (File)
Mar 5 2024, 7:43 AM
Unknown Object (File)
Mar 5 2024, 7:43 AM
Unknown Object (File)
Mar 5 2024, 7:42 AM
Unknown Object (File)
Dec 18 2023, 1:49 AM
Unknown Object (File)
Dec 16 2023, 4:41 PM
Unknown Object (File)
Dec 16 2023, 4:03 AM
Unknown Object (File)
Dec 13 2023, 7:13 PM
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