@storybook/theming causes type errors during tsc
See original GitHub issueDescribe the bug
Ok this is a fun one. Basically tsc complains about missing react typings, when trying to use create
of @storybook/theming
.
This is because:
@storybook/theming
imports@emotion/*
- which in turn imports
react
- which in turn requires
@types/react
- which would have to be installed manually
- which would then declare global
JSX
namespace - which would then conflict with the
JSX
namespace of Vue
To Reproduce
- create Vue project with TS support via Vue CLI 3
- Storybook via vue-cli-plugin-storybook (TS conversion and config must be done by hand)
- Vue JSX/TSX typings -> https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-typescript/generator/template/src/shims-tsx.d.ts
- Create theme:
import { create } from '@storybook/theming';
export default create({
base: 'light',
brandTitle: 'My Storybook',
});
npx tsc
Expected behavior
Use create
from @storybook/theming
without requiring react typings and therefore no JSX namespace conflicts.
System:
- OS: any
- Device: any
- Browser: any
- Framework: vue
- Version: 5
Additional context Workaround:
- dont use storybook theming
- or dont use vue jsx/tsx
- or run tsc with
--skipLibCheck
Solution:
- provide a
create
theme function/module that does not use@emotion/*
- the only stuff that
create
requires from@emotion/*
isimport { css, keyframes } from '@emotion/core';
inanimation.ts
) - where
css
type doesnt requirereact
typings (so no problem here), but is imported from@emotion/core
types, which importsreact
typings for other stuff (this is a problem) -> importcss
from@emotion/css
- where
keyframes
type doesnt requirereact
typings (so no problem here), but its type is declared in@emotion/core
type declaration file that importsreact
typings, but actually dont use react typings forkeyframes
itself (but for other stuff) -> ask for upstream change in emotion (which would maybe require some reorganisation of types/exports on their part) or reimplement/c&pkeyframes
into@storybook/theming
or dont usekeyframes
duringcreate
Issue Analytics
- State:
- Created 4 years ago
- Reactions:10
- Comments:19 (12 by maintainers)
Top Results From Across the Web
TypeScript - Storybook
Storybook is a frontend workshop for building UI components and pages in isolation ... Storybook has built-in TypeScript support, so your TypeScript project ......
Read more >Webpack for Storybook: Module not found for ts files with .web ...
I am trying to use Storybook, with expo and react-native-web. Whenever I try to use an expo module I am getting the following...
Read more >@storybook/react | Yarn - Package Manager
Storybook for React: Develop React Component in isolation with Hot Reloading. storybook. readme. Storybook. Build bulletproof UI components faster. Build Status ...
Read more >error loading dynamically imported module - You.com | The AI ...
We use Storybook + Chromatic. We have swapped from Webpack 5 builer to Vite as we swapped from CRA to Vite for the...
Read more >How to Create and Publish a React Component Library
In the dts config we need to specify that .css modules are external and should not be processed as part of our type...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
still relevant
@shilman it looks like the
@storybook/theming
package doesn’t cause TS + JSX conflicts.However it seems the
@storybook/knobs
package causes this issue still as it ships@types/react-color
. I’m unsure if this is intentional.The above causes the
@types/react
package to be installed when using the@storybook/knobs
package. If theknobs
addon can ship without this types dependency then this should resolve the Vue + TSX issues.