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

Added TypeScript definitions for css prop. #416

Merged
merged 2 commits into from
Oct 20, 2017

Conversation

cameron-martin
Copy link
Contributor

What:
Added TypeScript definitions for the css prop which is compiled to className by the babel plugin.

Why:
Because otherwise TypeScript users will get type errors when using this feature.

How:
Used module augmentation/declaration merging to add the css property to the HTMLAttributes inferface.

Checklist:

  • Documentation
  • Tests
  • Code complete

@cameron-martin
Copy link
Contributor Author

On seconds thoughts, maybe this should go into the dts files in the emotion package instead, since the css prop can be used without using the react-emotion package. Or even in the types for the babel-plugin-emotion package - although I have no idea if this would work.

What do you think?

@tkh44
Copy link
Member

tkh44 commented Oct 19, 2017

It should go in the react-emotion package I think.

@@ -3,6 +3,12 @@ import { Interpolation as EmotionInterpolation } from 'emotion'

export * from 'emotion'

declare module 'react' {
interface HTMLAttributes<T> {
css?: string;
Copy link
Member

Choose a reason for hiding this comment

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

This can be any type of value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anything of type Interpolation?

Copy link
Member

Choose a reason for hiding this comment

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

Correct

@cameron-martin
Copy link
Contributor Author

I'm using react + emotion without react-emotion so it would be useful to be in the emotion package.

@tkh44
Copy link
Member

tkh44 commented Oct 19, 2017

I agree. @cameron-martin. I misread your original comment. Sorry about that.

@cameron-martin
Copy link
Contributor Author

I've made the css prop take anything of type Interpolation and moved it to the emotion package.

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