fix: prevent mixing responsive viewport keys with T's keys in Responsive<T>#600
Open
te6-in wants to merge 1 commit intoreshaped-ui:canaryfrom
Open
fix: prevent mixing responsive viewport keys with T's keys in Responsive<T>#600te6-in wants to merge 1 commit intoreshaped-ui:canaryfrom
te6-in wants to merge 1 commit intoreshaped-ui:canaryfrom
Conversation
Contributor
|
Hey, thanks for the PR, do you have a reproduction of this on TS playground as well? Can't reproduce this issue locally or in the playground myself: |
Author
|
@blvdmitry Hey sure, Playground
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, first of all, congrats on and thanks for opensourcing reshaped, really enjoying digging the codebase.
I noticed a small type safety gap in
Responsive<T>and wanted to contribute a fix.Summary
Regarding
ResponsiveOnly<T>, currently whenTis an object likeButtonProps, it allows mixingT's keys with viewport keys without a type error.This PR adds an intersection to
ResponsiveOnly<T>so thatT's own keys would be mapped tonever.Related Issue
not found so far
Notes for Reviewers
While this makes codes like above make type error, IDE still suggests
T's keys in autocompletions. I guess this is a TypeScript limitation.