Skip to content

@storybook/theming causes type errors during tsc #7379

@backbone87

Description

@backbone87

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions