Skip to content

[styled-components]: Add withConfig method and 5.1 support - #43718

Merged
armanio123 merged 1 commit into
DefinitelyTyped:masterfrom
danilofuchs:styled-components/5.1
Apr 13, 2020
Merged

armanio123 merged 1 commit into
DefinitelyTyped:masterfrom
danilofuchs:styled-components/5.1

Conversation

@danilofuchs

@danilofuchs danilofuchs commented Apr 7, 2020 •

Copy link
Copy Markdown
Contributor

Closes #43693

Adds types for styled("div").withConfig({}) and the shouldForwardProp config.
I made this method generic, so the user can provide correct prop types before filtering (but this may be confusing).

I realized withConfig is a valid styled-components prop for a while now, and https://github.com/styled-components/styled-components/pull/3006/files#diff-b97c58d0b5d2df2981674fb8779b99bbR72 has all the flow type definitions for this function's parameters. A further PR is needed to provide these parameter types.


  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Add or edit tests to reflect the change. (Run with npm test.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If changing an existing definition:

@typescript-bot typescript-bot added Popular package This PR affects a popular package (as counted by NPM download counts). Awaiting reviewer feedback labels Apr 7, 2020
@typescript-bot

typescript-bot commented Apr 7, 2020 •

Copy link
Copy Markdown
Contributor

@danilofuchs Thank you for submitting this PR!

🔔 @Igorbek @Igmat @lavoaster @Jessidhia @jkillian @eps1lon @flavordaaave @wagerfield @Lazyuki @mgoszcz2 - please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

If no reviewer appears after a week, a DefinitelyTyped maintainer will review the PR instead.

@resir014

resir014 commented Apr 8, 2020

Copy link
Copy Markdown
Contributor

CMIIW, but I think the defaultValidatorFn parameter is optional. From what I know other libraries like @styled-system/should-forward-prop also only uses the first parameter.

@danilofuchs

danilofuchs commented Apr 8, 2020 •

Copy link
Copy Markdown
Contributor Author

CMIIW, but I think the defaultValidatorFn parameter is optional. From what I know other libraries like @styled-system/should-forward-prop also only uses the first parameter.

It is optional on the consumer end. The library always provides the second argument. As you can see in this test, the client can omit defaultValidatorFn when consuming the API.

If I changed it to be optional, every time someone might want to use defaultValidatorFn, it would be necessary to check if the function is not undefined, which it never is:

shouldForwardProp: (prop, defaultValidatorFn) => defaultValidatorFn && defaultValidatorFn(prop)
// OR
shouldForwardProp: (prop, defaultValidatorFn) => defaultValidatorFn?.(prop)

@danilofuchs
danilofuchs force-pushed the styled-components/5.1 branch from ff38490 to 5e96304 Compare April 8, 2020 13:25
@resir014

resir014 commented Apr 9, 2020

Copy link
Copy Markdown
Contributor

@danilofuchs Ah, I didn't see that test. All is good on my end, then.

@typescript-bot typescript-bot added the Unmerged The author did not merge the PR when it was ready. label Apr 13, 2020
@typescript-bot

Copy link
Copy Markdown
Contributor

After 5 days, no one has reviewed the PR 😞. A maintainer will be reviewing the PR in the next few days and will either merge it or request revisions. Thank you for your patience!

@armanio123
armanio123 merged commit 2763762 into DefinitelyTyped:master Apr 13, 2020
@typescript-bot

Copy link
Copy Markdown
Contributor

I just published @types/[email protected] to npm.

@danilofuchs
danilofuchs deleted the styled-components/5.1 branch December 26, 2023 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Popular package This PR affects a popular package (as counted by NPM download counts). Unmerged The author did not merge the PR when it was ready.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[styled-components] Support shouldForwardProp option

4 participants