Page MenuHomePhabricator

[Flow202][keyserver][skip-ci] [9/x] Fix Flow issues with types of variables that get mutated
ClosedPublic

Authored by ashoat on Nov 13 2023, 3:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 26, 5:43 PM
Unknown Object (File)
Tue, Nov 26, 11:59 AM
Unknown Object (File)
Sat, Nov 23, 10:35 PM
Unknown Object (File)
Fri, Nov 22, 10:20 PM
Unknown Object (File)
Fri, Nov 22, 10:09 PM
Unknown Object (File)
Fri, Nov 22, 6:18 PM
Unknown Object (File)
Fri, Nov 8, 3:27 AM
Unknown Object (File)
Oct 27 2024, 8:54 PM
Subscribers

Details

Summary

This the keyserver counterpart of D9774 (web) and D9706 / D9692 (lib).

There are two main categories of changes here, and both pertain to variables getting mutated:

  1. let declarations where the variable is reassigned later
  2. const declarations of mutable collections that are mutated later

In both of these cases, Flow now wants us to annotate the declaration to cover both the type of the data that's initialized, and also the mutations that later occur.

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 o f 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 D9857

Test Plan

Confirm the Flow errors go away

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Nov 13 2023, 3:12 PM
Harbormaster failed remote builds in B24074: Diff 33172!
keyserver/src/push/rescind.js
194–215 ↗(On Diff #33172)

Oops – this should be in D9859

keyserver/src/updaters/thread-permission-updaters.js
644–646 ↗(On Diff #33172)

I had to make this change because Flow didn't want me passing null to JSON.parse. I can probably switch permissions_from_parent to ?string now... I was trying to type it more precisely in the hopes that Flow would be okay with JSON.parse(null). (In my experimentation with V8, JSON.parse(null) is okay (and returns null) but JSON.parse(undefined) is not)

648 ↗(On Diff #33172)

null > 0 (and undefined > 0) are true, but Flow doesn't like us relying on that

Pull out the promises stuff to D9859

keyserver/src/updaters/thread-permission-updaters.js
644–646 ↗(On Diff #33192)

I had to make this change because Flow didn't want me passing null to JSON.parse. I can probably switch permissions_from_parent to ?string now... I was trying to type it more precisely in the hopes that Flow would be okay with JSON.parse(null). (In my experimentation with V8, JSON.parse(null) is okay (and returns null) but JSON.parse(undefined) is not)

648 ↗(On Diff #33192)

null > 0 (and undefined > 0) are true, but Flow doesn't like us relying on that

Harbormaster returned this revision to the author for changes because remote builds failed.Nov 13 2023, 6:41 PM
Harbormaster failed remote builds in B24093: Diff 33192!
This revision is now accepted and ready to land.Nov 14 2023, 12:44 PM
ashoat retitled this revision from [Flow202][keyserver] [9/x] Fix Flow issues with types of variables that get mutated to [Flow202][keyserver][skip-ci] [9/x] Fix Flow issues with types of variables that get mutated.Nov 19 2023, 5:06 PM