-
-
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
Augmenting the DOMAttributes interface with 'css' causes conflicts #1257
Comments
+1 Also ran into this via storybook |
The emotion css prop type coming with Storybook brought me here too. I've managed to fix this for myself by adding
|
Thanks @jvgreenaway! That fix works just fine. For those that are, like me, not using yarn. He's just deleting the file directly after install. So a pm
|
A fix for this has been just merged into v11 line: #1941 |
If you have errors with types "type" and "as" you should redefine this types before intert these in styled components. Perhaps, if you try to rewrite css-props, it will help. My example:
|
Hello all, I want to point out that this conflict still exist when trying to use a component styled with https://github.com/modulz/stitches in the context of storybook : The only solution right now is to add |
This has been fixed in v11 - |
You're right. Storybook v6 references @emotion/core v10 as dependency that has global css type yet, and it occurs type error if we pass css style of object. it conflicts with @emotion/react v11. If you use storybook v6, the only solution is to remove @emotion/core/types. |
I also had to add |
Causes conflict with stitches, This is fixed in later emotion but storybook currently still on v10. See emotion-js/emotion#1257
For those using Yarn V2 (Berry), there is no longer a Instead, I needed to create a patch-file, which applies automatically on install. I used the following method:
Hope this helps until the next major version! |
There is a known issue with storybook that the @emotion/core dependency augments the React `HTMLAttributes` with an additional `css` property. This causes the compiled types of react-bootstrap-typeahead to include that attribute as well, which in turns breaks Typescript compilation of projects using it. See: emotion-js/emotion#1257 (comment)
There is a known issue with storybook that the @emotion/core dependency augments the React `HTMLAttributes` with an additional `css` property. This causes the compiled types of react-bootstrap-typeahead to include that attribute as well, which in turns breaks Typescript compilation of projects using it. See: emotion-js/emotion#1257 (comment)
There is a known issue with storybook that the @emotion/core dependency augments the React `HTMLAttributes` with an additional `css` property. This causes the compiled types of react-bootstrap-typeahead to include that attribute as well, which in turns breaks Typescript compilation of projects using it. See: emotion-js/emotion#1257 (comment)
emotion
version: 10.0.7react
version: 16.8.3Relevant code:
What you did:
In a project that already used
styled-components
,@emotion/core
started being loaded as an indirect devDependency (@storybook/theming
, to be more specific).What happened:
The combination of an augmented
React.DOMAttributes
with a double-augmentedJSX.Attributes
is breaking pass-through of theprops
because theReact.DOMAttributes
makes the component think it can receivecss
as a prop.Reproduction:
CodeSandbox can't typecheck, even in typescript sandboxes :(
Problem description:
@emotion/core
unconditionally augments bothReact.DOMAttributes
andJSX.Attribute
, but ideally such augmentation should be optional to avoid this conflict.Suggested solution:
@types/styled-components
made it optional by splitting just the augmentation itself into a separate file, and you can request it by adding"styled-components/cssprop"
to yourtsconfig.json
'scompilerOptions.types
, using a triple-slash reference (only needed once, on any file that's in the project) as in the above sample, or using an empty import (also only needed once).The augmentation of
React.DOMAttributes
is technically unnecessary, augmentingReact.Attributes
is sufficient for all JSX use cases (JSX.Attributes
inherits fromReact.Attributes
). The only thing it makes possible is receivingcss
as a prop, which you can't, even with / especially with thejsx
pragma.The added advantage of making the augmentation optional is that it makes it possible for the user to augment it with a more specific type -- perhaps
InterpolationWithTheme<MyTheme>
, for example.EDIT: This also, of course, affects actual uses of
css
with thestyled-components
css
function, as it becomes impossible to fulfill the type. The only workarounds I can do until this is fixed is to locally augment thecss
prop in both interfaces withany
(!).The text was updated successfully, but these errors were encountered: