Skip to content

Conversation

@rekmarks
Copy link
Member

@rekmarks rekmarks commented Jan 29, 2021

Rather than just typing the store state as Record<string, unknown> everywhere (not very helpful, we were just lazy), we now type it as T extends Record<string, unknown>. This will be really neat to use in practice.

To preserve existing behavior, we cheat in a three places by continuing to default the state to {}, regardless of the generic type. Excepting LocalStorageStore (which should really be rewritten to solve this problem), type safety still cannot be violated by the consumer if TypeScript is used.

NiranjanaBinoy
NiranjanaBinoy previously approved these changes Feb 5, 2021
Copy link

@NiranjanaBinoy NiranjanaBinoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rekmarks rekmarks marked this pull request as draft February 5, 2021 18:33
@rekmarks rekmarks marked this pull request as ready for review February 5, 2021 18:43
Copy link

@NiranjanaBinoy NiranjanaBinoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rekmarks rekmarks merged commit 5f7e102 into main Feb 5, 2021
@rekmarks rekmarks deleted the genericize branch February 5, 2021 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants