There are some type issues in the state sync specs that can't be resolved with Flow. The new version of Flow is properly detecting these type issues, but there's no easy resolution.
Instead, I apply precise any-types throughout that get immediately re-cast to the proper narrowed type.
I also snuck in some type fixes in keyserver/src/socket/socket.js – will annotate them inline.
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 D9854