Types: `props.theme` should not be optional in Emotion 11
See original GitHub issueCurrent behavior:
The props.theme
is Theme | undefined
instead of Theme
, 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 -> https://github.com/emotion-js/emotion/pull/1501#issuecomment-553489241
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 that Theme
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
is Theme | undefined
instead of Theme
Expected behavior:
I was expecting props.theme
to be Theme
, so the migration to emotion 11 is way less painful 😬
Environment information:
react
version: 16.8.4emotion
version: 11.0.0-next.10
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
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.
Has been fixed by https://github.com/emotion-js/emotion/pull/1708 . Still need to resolve
@emotion/serialize
problem in https://github.com/emotion-js/emotion/pull/1710 , but expect a new release soon-ish.