Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Genericize state wherever possible #33

Merged
merged 6 commits into from
Feb 5, 2021
Merged

Genericize state wherever possible #33

merged 6 commits into from
Feb 5, 2021

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.

2 participants