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

Add type for as prop on styled components #1874

Merged
merged 5 commits into from
Jul 9, 2020
Merged

Add type for as prop on styled components #1874

merged 5 commits into from
Jul 9, 2020

Conversation

connor-baer
Copy link
Contributor

@connor-baer connor-baer commented May 19, 2020

Closes #1137.

What: Add basic type for the as prop on styled components.

Why: If I add as to my component's ExtraProps the TypeScript compiler complains about the as prop not existing on the styled component (see #1137 for a full reproduction).

How: Add the as prop to the CreateStyled instance in packages/styled/types/base.d.ts

Checklist:

  • Documentation
  • Tests
  • Code complete
  • Changeset

@changeset-bot
Copy link

changeset-bot bot commented May 19, 2020

🦋 Changeset is good to go

Latest commit: 1687cf3

We got this.

This PR includes changesets to release 6 packages
Name Type
@emotion/styled Major
@emotion/react Major
@emotion/jest Major
@emotion/primitives-core Major
@emotion/native Major
@emotion/primitives Major

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 May 19, 2020

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 1687cf3:

Sandbox Source
Emotion Configuration
ancient-shape-4kj9u Issue #1137

@connor-baer
Copy link
Contributor Author

connor-baer commented May 19, 2020

This is my first time contributing to Emotion. I have a couple of questions:

  1. How do I know which packages to include in the changeset? Do I only bump the package I changed (@emotion/styled) and changeset will bump the packages that depend on it as well?
  2. Would this change to the types be considered a breaking change? Can I backport it to v10?

@connor-baer
Copy link
Contributor Author

connor-baer commented May 19, 2020

Also not sure if I need to add the type on lines 109, 114, and 123 as well.

Edit: After looking at the code again, I've concluded that it needs to be added there as well.

@connor-baer connor-baer marked this pull request as ready for review May 20, 2020 08:29
@Andarist
Copy link
Member

How do I know which packages to include in the changeset? Do I only bump the package I changed (@emotion/styled) and changeset will bump the packages that depend on it as well?

Just think about for which packages your changes were relevant - this sometimes might include dependents of a package, but sometimes not. In the case of @emotion/styled there are no dependents so there is no problem with deciding that 😉

Would this change to the types be considered a breaking change? Can I backport it to v10?

Honestly, I would prefer not to touch v10 at all, and even more so its types as they are somewhat convoluted. I'm in the process of handling all open issues/PRs so we can ship v11 as soon as possible. V11 doesn't include many substantial breaking changes so I hope the migration should be pretty straightforward.

If you manage to backport it to v10 I will consider merging it though (if we decide to merge this one into v11).


Sorry for a late review, I'm quite busy and tired lately.

@JakeGinnivan this doesn't provide super strict typings for as prop, but I guess this is fine to merge. WDYT?

@connor-baer
Copy link
Contributor Author

Thanks for the notes @Andarist! I've added the changeset.

I'm okay to only include this in v11. Backporting to v10 doesn't look too difficult though based on @JakeGinnivan's comment, so if others are interested, I'd be happy to take care of that, too.

@Andarist
Copy link
Member

Andarist commented Jul 9, 2020

Sorry that it took so long to merge this. Thank you very much for doing preparing this PR @connor-baer ❤️

@Andarist Andarist merged commit 4d3b60d into emotion-js:next Jul 9, 2020
@github-actions github-actions bot mentioned this pull request Jul 9, 2020
@connor-baer connor-baer deleted the types/as-prop branch July 10, 2020 09:26
@Andarist
Copy link
Member

I've discovered one flaw of this approach - as became available within interpolations when most of the time it shouldn't. Any ideas on how to solve this? The only thing that comes to my mind is adding an additional overload for props that are not meant to be available in interpolations & are not meant to be forwarded by default. This complicates the API - so maybe it's not worth fixing at all? cc @JakeGinnivan

louisgv pushed a commit to louisgv/emotion that referenced this pull request Sep 6, 2020
…on-js#1874)

* Add type for as prop

* Add changeset

* Simplify type for `as` prop

* Tweak changeset

Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
@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.

None yet

2 participants