Page MenuHomePhabricator

[lib] Update `MinimallyEncoded*Info` types to be `$ReadOnly`
ClosedPublic

Authored by atul on Nov 8 2023, 2:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Dec 25, 1:26 PM
Unknown Object (File)
Mon, Dec 16, 4:37 PM
Unknown Object (File)
Mon, Dec 16, 4:37 PM
Unknown Object (File)
Mon, Dec 16, 4:37 PM
Unknown Object (File)
Mon, Dec 16, 4:36 PM
Unknown Object (File)
Mon, Dec 16, 4:31 PM
Unknown Object (File)
Sat, Nov 30, 8:23 AM
Unknown Object (File)
Fri, Nov 29, 6:52 PM
Subscribers

Details

Summary

Updated the MinimallyEncoded*Info types to be $ReadOnly since spreading the "base" types drops the "read only" property and makes them writable... which caused some Flow issues.

Also going ahead and adding minimallyEncoded discriminator property to all of the types as we did for MinimallyEncodedRawThreadInfo in D9766 to help Flow refine types.

Test Plan

Flow, updated unit tests

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul requested review of this revision.Nov 8 2023, 5:13 PM
tomek added inline comments.
lib/permissions/minimally-encoded-thread-permissions.js
224 ↗(On Diff #32979)

Not sure if it is likely that we will have some other encoding, but a more maintainable solution might be to have e.g. +encoding: 'plain' | 'minimal' instead of a boolean flag. We can also keep the current approach and change it in the future if needed.

224–226 ↗(On Diff #32979)

How about moving minimallyEncoded after spreading so that it won't get accidentally overridden?

This revision is now accepted and ready to land.Nov 9 2023, 3:39 AM
lib/permissions/minimally-encoded-thread-permissions.js
224 ↗(On Diff #32979)

Yeah figured boolean was simpler because we could do if (roleInfo.minimallyEncoded) instead of if (roleInfo.minimallyEncoded === 'minimal) for now.

Hopefully we won't have yet another encoding any time soon, but will switch to enum if that comes up

224–226 ↗(On Diff #32979)

Yeah seems reasonable, also might make the spread "less hidden"? Will update this diff

reposition spreads to top

This revision was landed with ongoing or failed builds.Nov 9 2023, 12:00 PM
This revision was automatically updated to reflect the committed changes.