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
@storybook/theming causes type errors during tsc #7379
Comments
Automention: Hey @domyen @elevatebart @emilio-martinez @gaetanmaisse @kroeder @pksunkara, you've been tagged! Can you give a hand here? |
@backbone87 try: import { create } from '@storybook/theming/create'; Does that solve the issue? |
@ndelangen no, see section "solution" in the opening post |
still relevant |
Still, very need full custom styling for Storybook. |
I'm having the same issue with @storybook/vue... which installs some babel dependency which also changes the typings |
Can confirm, this isnt limited to theming anymore. (It has nothing to do with installs, just about what is imported, which means some import during storybook config/bootstrap imports something which imports something etc, until finally react TSX typings get imported, which results in conflict) the only 2 workarounds left are:
|
@backbone87 isn't there some way to make folder specific tsconfig? |
not as far as i know. the TSX declarations target the global namespace, so you can never have vue and react TSX shims imported (directly or indirectly) within the same compliation. just importing removing the vue TSX declarations (and not using TSX) is a good workaround, since TSX traction in the vue ecosystem is low, but that may change with vue 3. |
@backbone87 I sympathise.
That seems like the root of the problem. I'm guessing that's not configurable either? |
At least currently it is not configurable. but i dont think that it is feasible either. it would definitely require changes within typescript itself and maybe even the babel plugin to transpile 2 TSX files differently based on its path. vue tsx gets compiled into vues createElement calls, while react tsx gets compiled to reacts renderComponent (or whatever its called in react). but i think it is bad for frameworks/libs/packages to (indirectly) import tsx shims in their public typings since the code is compiled already most of the time and therefore the shims arent needed. when i opened this issue, these conflicts come from emotion packages, which was only imported when using storybook theming, but now the shims get even imported when importing |
fwiw: the real problem seems to be which means as soon as you want to use react in any way (and even it its just exposing some APIs which have nothing to do with rendering react at all) you get the react shims |
I'm facing the same issue. Had to add The .sink.d.ts is just an empty file and enables me to use my own |
Thank you for deleting my comment. |
We've just released zero-config typescript support in 6.0-beta. Please upgrade and test it! Thanks for your help and support getting this stable for release! |
@shilman it looks like the However it seems the The above causes the |
@blake-newman We’ve just released addon-controls in 6.0-beta! Controls are portable, auto-generated knobs that are intended to replace addon-knobs long term. Can also try to fix the knobs issue but if you’re able to upgrade i recommend it! |
Still have problem with JSX type conflicts, when i write stories like this:
|
Currently facing the same issue, one solution I found is to not use TypeScript at all for writing stories. Story files will all be ".js" files. |
This is resolved in storybook 7.0 beta because we bundle in emotion. |
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/*
react
@types/react
JSX
namespaceJSX
namespace of VueTo Reproduce
npx tsc
Expected behavior
Use
create
from@storybook/theming
without requiring react typings and therefore no JSX namespace conflicts.System:
Additional context
Workaround:
--skipLibCheck
Solution:
create
theme function/module that does not use@emotion/*
create
requires from@emotion/*
isimport { css, keyframes } from '@emotion/core';
inanimation.ts
)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
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
The text was updated successfully, but these errors were encountered: