stitches: stitches component "Types of property 'css' are incompatible." error occurred when storybook is installed
Bug report
Describe the bug
To Reproduce
I copied this Link to src/components/Button.tsx file.
and enter npx sb init command to terminal for install storybook. below packages are installed.
@babel/core, @storybook/addon-actions, @storybook/addon-essentials, @storybook/addon-links, @storybook/react
then, Button Component type error occurred.
for remove error, remove those packages from devDependencies.
Expected behavior
No Type Error.
Screenshots

System information
- OS: macOS, sandbox
- Version of Stitches: 1.2.6, 1.2.6
- Version of Node.js: 14.18.2, ?
- Version of Typescript: 4.4.2
- Version of Next.js: 12.0.1
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 17 (4 by maintainers)
AFAIK Storybook has defined global type definitions for Emotion’s
cssprop which clash with Stitches’cssprop. A work around is to point the Emotion package at an empty types definition file. Here is a gist someone made of this: https://gist.github.com/sseagull/e2e7fe58f7f236897d342e776bb549a2Perhaps this gist need to be referenced in an FAQ section of some sort as a lot of people encounter this.
Guys,
As of Storybook version 6.5.0-alpha.31, the solutions mentioned above no longer work.
This is because this PR changed the way the storybook generates typing definitions and the Emotion typing is now built into the Storybook theming package.
So, there were two ways to solve the problem:
Thanks! Here’s what worked:
Create a
.d.tsfile in the root of your project, or wherever convienant. I usedtypes.d.ts.Add the following to your tsconfig.json.
For more detailed instructions, check out the gist hwhmeikle provided above.
Folks,
I updated my project to version
6.5.0-alpha.59of the storybook and this problem was fixedCan you see details here https://github.com/storybookjs/storybook/pull/17640
Thanks @ndelangen
We’re in the process of upgrading storybook to Emotion 11, and we have also removed the webpack alias, and removed the dependency on emotion from storybook in the storybook 6.4 alpha release.
If you use yarn, an even easier way to fix this would be adding a
.yarncleanin the root of your repo with just the line@emotion/core/types.Closing since this issue is not originating from stitches
Confirming this mix of solutions from @drianoaz and @iambrennanwalsh solved the issue for me:
I needed to ensure my file was existing and properly managed by my build config
@drianoaz - I haven’t use this in a while, but you’d need to use https://www.npmjs.com/package/patch-package I believe