-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Relaxed types for shouldForwardProp #1643
Relaxed types for shouldForwardProp #1643
Conversation
🦋 Changeset is good to goLatest commit: e229804 We got this. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e229804:
|
7f749ff
to
efe168e
Compare
This function needs to be able to filter a props for a generic argument of the resulting function.
efe168e
to
657b901
Compare
@@ -31,13 +31,13 @@ export interface FilteringStyledOptions< | |||
ForwardedProps extends keyof Props = keyof Props | |||
> { | |||
label?: string | |||
shouldForwardProp?(propName: keyof Props): propName is ForwardedProps | |||
shouldForwardProp?(propName: PropertyKey): propName is ForwardedProps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are not extracting anything based on this, couldnt we just use a simple string
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A type predicate's type must be assignable to its parameter's type.
Type 'ForwardedProps' is not assignable to type 'string'.
Type 'keyof Props' is not assignable to type 'string'.
Type 'string | number | symbol' is not assignable to type 'string'.
Type 'number' is not assignable to type 'string'.ts(2677)
is the error I get
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, so it has to match to ForwardedProps extends keyof Props
, interesting. Gonna give it a thought later, but probably we'll keep PropertyKey if that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can replace keyof Props
with Extract<keyof Props, string>
to only extract strings which works. It just makes everything look more complex.
Co-Authored-By: Mateusz Burzyński <[email protected]>
Co-Authored-By: Mateusz Burzyński <[email protected]>
Co-Authored-By: Mateusz Burzyński <[email protected]>
* Relaxed types for shouldForwardProp This function needs to be able to filter a props for a generic argument of the resulting function. * Update .changeset/dull-carrots-enjoy.md Co-Authored-By: Mateusz Burzyński <[email protected]> * Update .changeset/dull-carrots-enjoy.md Co-Authored-By: Mateusz Burzyński <[email protected]> * Update .changeset/cool-candles-lie.md Co-Authored-By: Mateusz Burzyński <[email protected]>
This function needs to be able to filter a props for a generic argument of the resulting function.
Fixes #1641
Checklist: