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

impr(typing): infer automatically the typing of the generators used inside of the compose #358

Merged

Conversation

kamalbennani
Copy link
Contributor

Summary

As the title states, the goal of this MR is to infer automatically the return type of the compose method and also support the existing type in order not to create a breaking change in that area.

Before, in order to have the correct return type, you'd have to explicitly provide the "computed" return type:

interface GridItemProps extends GridAreaProps, GridColumnProps, GridRowProps {}
const gridItem = compose<GridItemProps>(gridArea, gridColumn, gridRow);

With this new change, you'd still be able to do that (like we do internally on xstyled) or you could just write the following:

const gridItem = compose(gridArea, gridColumn, gridRow);
// generated return type
// StyleGenerator<GridAreaProps<Theme> & GridColumnProps<Theme> & GridRowProps<Theme>>

@kamalbennani
Copy link
Contributor Author

Hi @gregberge, would you kindly consider my contribution? thanks.

@gregberge gregberge merged commit ecbae73 into styled-components:main Apr 2, 2022
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.

3 participants