-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 types and tests for the emotion package. #379
Conversation
d7b73e0
to
789431a
Compare
I have added using object literals in the form: css({
height: 100,
width: '100%',
':hover': {
display: 'block'
}
}); and const cssObject = {
height: 100,
width: '100%',
':hover': {
display: 'block'
}
};
css`
font-size: 2rem;
${cssObject}
`; to the definitions. |
789431a
to
b65e910
Compare
Ah I must also add arrays of CSS objects. Is there anything else that I've missed? |
@cameron-martin The value of the expression can be a function. #381 (comment) I just want to make sure you had that one as well. |
Ah yeah thanks. I'm guessing only zero-arity functions? I also missed arrays and calling the css function directly with null as well. Are the same types valid for interpolations, calling the css function directly with, as values in arrays, and as object values? |
Also, what is the meaning of |
Yep
That's just a test to make sure that properties with boolean values get removed. |
95615ba
to
3f5d93a
Compare
I updated them, hopefully they are correct now. |
|
||
export function flush(): void; | ||
|
||
export function values(cls: string, vars: Interpolation[]): string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This export doesn't exist anymore, I'm guessing this is from the other TypeScript PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, I removed it.
(): Interpolation; | ||
} | ||
|
||
export type CreateStyles<TRet> = ((value: Interpolation) => TRet) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with TypeScript but I think this means that it can only have something as the first argument. createStyles
accepts an arbitrary length of arguments, so maybe something like this?
(...values: Interpolation[])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
3f5d93a
to
7935e85
Compare
7935e85
to
6e83975
Compare
In In |
Are you ready to merge this @cameron-martin? I wasn't sure if you wanted to add anything else. |
Yeah I'm ready. Seems good to me and I'll send types for react-emotion separately :) |
Thanks! |
What:
Added TypeScript types for the emotion package.
Why:
Because users of TypeScript will want these.
How:
tsc --noEmit
.Checklist:
Comments:
emotion
package, and not for thereact-emotion
package. The main thing that is blocking me from implementing the typings forreact-emotion
is getting the declaration merging working correctly for adding thecss
prop to all elements. I will send a PR if I get these to work.