pixiebrix-extension icon indicating copy to clipboard operation
pixiebrix-extension copied to clipboard

DX: Simplify the `UserData` type, and cleanup other types in `src/auth/authTypes.ts`

Open BLoe opened this issue 1 year ago • 0 comments

  • This change means that we can now simplify the UserData type, it doesn't need to use Partial everywhere anymore, since we're no longer handling the "anonymous user" situation with the /api/me endpoint returning "empty" user data.
  • This simplification can be propagated into the user data storage/update logic
  • We should separate the types better between user info that can be updated, versus not, and we can get rid of this crazy type: type UserDataUpdate = Required<Except<UserData, "hostname" | "user">>;
  • Clean up/fix the type weirdness around OrganizationAuthState and AuthUserOrganization
    • Fix this factory: https://github.com/pixiebrix/pixiebrix-extension/blob/main/src/testUtils/factories/authFactories.ts#L92-L95
    • Should not be using the two org types interchangeably like this

BLoe avatar Feb 28 '24 19:02 BLoe