HomePhabricator
Diffusion Comm acbc8579e94e

[native] Fix LogInPanelContainer type

Description

[native] Fix LogInPanelContainer type

Summary:
In D770 we discovered that React.ElementRef<typeof LogInPanelContainer> was not correctly capturing the result of React.forwardRef.

Curiously, Flow was able to correctly conclude that React.ElementRef<typeof LogInPanelContainer> resolved to BaseLogInPanelContainer, and was even able to identify errors where a function name was mistyped.

But outside of typos in function names, Flow wasn't able to identify errors in the function types. Investigating this, I found that Flow was reporting the type of the function as any:

ashoat@ashoatmbp2018 [~/src/comm/native]$ flow type-at-pos account/logged-out-modal.react.js 710 30
any (implicit)
/Users/ashoat/src/comm/native/account/logged-out-modal.react.js:710:30,710:50

This diff fixes the issue by explicitly exporting BaseLogInPanelContainer, and casting React.ElementRef<typeof LogInPanelContainer> to BaseLogInPanelContainer.

I think the issue has to do with recent performance improvements that the Flow team has been working on. I think that the implicitly-exported BaseLogInPanelContainer did not include full information (eg. had the names of members, but not their types), and that our now explicitly-exported BaseLogInPanelContainer includes the full types.

Test Plan: Make sure Flow gives an error when we call a function incorrectly

Reviewers: subnub, palys-swm

Reviewed By: palys-swm

Subscribers: KatPo, zrebcu411, Adrian, atul

Differential Revision: https://phabricator.ashoat.com/D812

Details

Provenance
ashoatAuthored on Feb 25 2021, 9:21 AM
Reviewer
tomek
Differential Revision
Restricted Differential Revision
Parents
rCOMMf239b577415f: Extract hook to get message list data
Branches
Unknown
Tags
Unknown

Event Timeline