HomePhabricator
Diffusion Comm 24c433462306

[Flow202][lib][skip-ci] [11/23] Fix Flow issues with referencing this in object…

Description

[Flow202][lib][skip-ci] [11/23] Fix Flow issues with referencing this in object methods

Summary:
The new version of Flow is showing a bunch of errors that look like this:

Error ---------------------------------------------------------------- shared/messages/add-members-message-spec.js:45:12

Cannot reference this from within method messageContentForClientDB [1]. For safety, Flow restricts access to this inside
object methods since these methods may be unbound and rebound. Consider replacing the reference to this with the name of
the object, or rewriting the object as a class. [object-this-reference]

     42|   },
     43|
 [1] 44|   messageContentForClientDB(data: RawAddMembersMessageInfo): string {
     45|     return this.messageContentForServerDB(data);
     46|   },
     47|
     48|   rawMessageInfoFromServerDBRow(row: Object): RawAddMembersMessageInfo {

This diff addresses them by "replacing the reference to this with the name of the object" as suggested. That change initially introduced another type issue since messageContentForServerDB is optional in MessageSpec, so I had to also explicitly type each MessageSpec so that messageContentForServerDB is non-optional.

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 D9702

Test Plan: Confirm the Flow errors go away

Reviewers: tomek

Reviewed By: tomek

Subscribers: wyilio

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