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

Preserve existing options passed to styled calls #584

Merged

Conversation

Andarist
Copy link
Member

@Andarist Andarist commented Mar 2, 2018

fixes #582

What:

Preserving existing options passed to styled calls when using emotion's babel plugin

Why:

It would ease creating custom emotion wrappers.

How:

Checklist:

  • Documentation
  • Tests
  • Code complete

TODO:

  • fix flow typings - I'd appreciate help with this, dunno why they are not compatible atm
  • handle more cases (like buildStyledObjectCallExpression)
  • decide what about rest of the arguments, they are lost at the moment too, should we preserve them?

@emmatown
Copy link
Member

emmatown commented Mar 3, 2018

Let's preserve the rest of the arguments and for the flow errors, just add // $FlowFixMe comments for now.

@Andarist
Copy link
Member Author

Andarist commented Mar 3, 2018

So I think this is code-complete, you can make a code review of this. I'd appreciate hints on how to fix those flow types, I always struggle with a little bit more complicated cases :s

@codecov
Copy link

codecov bot commented Mar 3, 2018

Codecov Report

Merging #584 into master will decrease coverage by 0.06%.
The diff coverage is 95%.

Impacted Files Coverage Δ
packages/babel-plugin-emotion/src/macro-styled.js 100% <ø> (ø) ⬆️
packages/babel-plugin-emotion/src/index.js 96.69% <95%> (-0.23%) ⬇️

Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 Typing this well with flow is hard since flow doesn't know how the isSomeNodeTypeHere stuff works and etc. It's basically more effort than it's worth, we just use flow here for more basic stuff, i.e. functions are called with the correct number of arguments, things that are being imported actually exist and etc.

@emmatown emmatown changed the title [WIP] Preserve existing options passed to styled calls Preserve existing options passed to styled calls Mar 4, 2018
@emmatown emmatown merged commit f689508 into emotion-js:master Mar 4, 2018
@Andarist Andarist deleted the babel-custom/preserve-custom-options branch March 5, 2018 11:34
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.

[enhancement - babel plugin] Respect custom options in styled calls
2 participants