This is just a copy/paste step so making it a separate diff.
I tried a lot of different ways to "parameterize" existing getRelativeMemberInfos based on Legacy or MinimallyEncoded RawThreadInfo that was being passed in.
Some approaches I looked at:
- $PropertyType<T, 'k'> which I'd previously seen used in dispatchActionPromise. Unfortunately, that didn't work because T.members would give us $ReadOnlyArray<*MemberInfo> instead of $ReadOnlyArray<*RelativeMemberInfo> because the list of *RelativeMemberInfos is in ThreadInfo not RawThreadInfo. I basically couldn't find a way to "map" RawT to T.members (eg RawThreadInfo -> ThreadInfo["members"]). The newer indexed access syntax (https://flow.org/en/docs/types/indexed-access/) also wasn't useful.
- Tried using minimallyEncoded checks within, but flow wasn't able to narrow from *ThreadInfo.minimallyEncoded to *MemberInfo.minimallyEncoded to a *RelativeMemberInfo.minimallyEncoded return type.
- Tried annotating types within function body to see if that would "help" flow in some way?
It looks like what we'd really want is to use Conditional Types which were introduced in Flow 208: https://flow.org/en/docs/types/conditional/
For now I'm going to start by completely duplicating the function, which I know works... and then recursively try to break it down into reusable pieces while preserving the type narrowing.
Updating this diff with the version of getRelativeMemberInfos that @ashoat wrote in the comments here: https://phab.comm.dev/D10235#297963
Depends on D10233