HomePhabricator
Diffusion Comm 1a4517949bf2

[Flow202][lib][skip-ci] [23/23] Fix Flow issues in lib/utils/action-logger.js

Description

[Flow202][lib][skip-ci] [23/23] Fix Flow issues in lib/utils/action-logger.js

Summary:
Flow was printing this type error:

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ utils/action-logger.js:143:13

Cannot assign this.currentOtherStates[stateKey] to state[stateKey] because an index signature declaring the expected key
/ value type is missing in object literal [1]. [prop-missing]

     140│   get currentState(): Object {
 [1] 141│     const state = this.currentReduxState ? { ...this.currentReduxState } : {};
     142│     for (const stateKey in this.currentOtherStates) {
     143│       state[stateKey] = this.currentOtherStates[stateKey];
     144│     }
     145│     return state;
     146│   }

This was solved by adding a typehint to the declaration of the local variable state. While I was here, I also replaced the Object type (which is an alias to any in modern versions of Flow) with something better: { +[string]: mixed }.

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 D9714

Test Plan: Confirm the Flow errors go away

Reviewers: atul

Reviewed By: atul

Subscribers: tomek, wyilio

Differential Revision: https://phab.comm.dev/D9715

Details