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

Relaxed types for shouldForwardProp #1643

Merged
merged 4 commits into from
Nov 19, 2019

Conversation

JakeGinnivan
Copy link
Contributor

This function needs to be able to filter a props for a generic argument of the resulting function.

Fixes #1641

Checklist:

  • Tests
  • Code complete
  • Changeset

@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2019

🦋 Changeset is good to go

Latest 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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 18, 2019

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:

Sandbox Source
Emotion Configuration

@JakeGinnivan JakeGinnivan force-pushed the fix/shouldForwardPropsTypes branch from 7f749ff to efe168e Compare November 18, 2019 12:47
This function needs to be able to filter a props for a generic argument of the resulting function.
@JakeGinnivan JakeGinnivan force-pushed the fix/shouldForwardPropsTypes branch from efe168e to 657b901 Compare November 18, 2019 12:48
@@ -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
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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.

JakeGinnivan and others added 3 commits November 19, 2019 08:35
@Andarist Andarist merged commit 923ded0 into emotion-js:next Nov 19, 2019
louisgv pushed a commit to louisgv/emotion that referenced this pull request Sep 6, 2020
* 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]>
@github-actions github-actions bot mentioned this pull request Nov 10, 2020
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