-
-
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
Types: props.theme
should not be optional in Emotion 11
#1707
Comments
|
Thanks, but I like my typesafety, this was not So I guess you suggest that we need to check if theme is there everytime? 😕 |
For the record, this was considered like a bug two months ago and fixed -> #1501 (comment) |
Also, this is not consistant with the object notation, import styled from "@emotion/styled";
export default styled.h2(({ theme }) => ({
color: theme.color // `theme` is `Theme` here
})); |
Ok, so I've actually misunderstood your original report here. I've focused myself on that error reported in french - and for that my advice still holds, you should augment builtin interface. But you have also found an issue with our typings 👍 probably a result of different PRs being merged in a roughly the same time and caused a mergeable conflict. |
Current behavior:
The
props.theme
isTheme | undefined
instead ofTheme
, so it's very hard to migrate to emotion 11 since we need to make sure that the theme is there on every usage.This was previously discussed and fixed here -> #1501 (comment)
I also follow the project to migrate to the new way, as describe here -> https://github.com/emotion-js/emotion/blob/next/docs/typescript.mdx
Note: Since the theme is a runtime variable inject by the
ThemeProvider
, I totally get thatTheme
is actually in reality optional and the current implementation is more typesafe, but in another hand, this will be very painful to use if we need to check everytime if the theme is there before consuming it…To reproduce:
https://codesandbox.io/s/brave-tereshkova-lx8sn
=>
props.theme
isTheme | undefined
instead ofTheme
Expected behavior:
I was expecting
props.theme
to beTheme
, so the migration to emotion 11 is way less painful 😬Environment information:
react
version: 16.8.4emotion
version: 11.0.0-next.10The text was updated successfully, but these errors were encountered: