question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@storybook/theming causes type errors during tsc

See original GitHub issue

Describe 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

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/* is import { css, keyframes } from '@emotion/core'; in animation.ts)
  • where css type doesnt require react typings (so no problem here), but is imported from @emotion/core types, which imports react typings for other stuff (this is a problem) -> import css from @emotion/css
  • where keyframes type doesnt require react typings (so no problem here), but its type is declared in @emotion/core type declaration file that imports react typings, but actually dont use react typings for keyframes 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&p keyframes into @storybook/theming or dont use keyframes during create

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:10
  • Comments:19 (12 by maintainers)

github_iconTop GitHub Comments

5reactions
backbone87commented, Aug 1, 2019

still relevant

2reactions
blake-newmancommented, May 28, 2020

@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 the knobs addon can ship without this types dependency then this should resolve the Vue + TSX issues.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found