[Bug]: React+Vite+TS PnP breaks type in .storybook/main.ts > config.framework.name
#23232
Labels
.storybook/main.ts > config.framework.name
#23232
Describe the bug
Storybook in yarn berry PnP & Vite (React + TS) creates type error in
.storybook/main.ts
(and other vite frameworks might have same issue)
Initializing storybook generates following code in
.storybook/main.ts
...... which are generated by ...
storybook/code/lib/cli/src/generators/baseGenerator.ts
Line 365 in 243ca40
storybook/code/lib/cli/src/generators/baseGenerator.ts
Lines 223 to 229 in 243ca40
storybook/code/lib/cli/src/generators/baseGenerator.ts
Lines 105 to 120 in 243ca40
storybook/code/lib/cli/src/generators/baseGenerator.ts
Lines 102 to 103 in 243ca40
... and this conflicts with type of
framework.name
inStorybookConfig
storybook/code/frameworks/react-vite/src/types.ts
Line 8 in 243ca40
Code above added in #20642, looks like PnP case was not considered.
Originally, type of
framework.name
, which was referringStorybookConfig
from@storybook/types
, was string and PR above narrowed it down to each framework's namestorybook/code/lib/types/src/modules/core-common.ts
Lines 325 to 328 in 4f7342b
storybook/code/lib/types/src/modules/core-common.ts
Lines 226 to 231 in 4f7342b
AFAIK about typescript, it seems like
type FrameworkName = string
is the only way to solve this issue, but not so sure.And it might lose advantages from strict typing.
(IMHO I love strict typing but in most case those values are created by generator so it doesn't look like huge advantage though)
Are there any other better solutions?
For somebody confronted same issue,
to bypass before this issue resolved, use
@ts-expect-error
like below.To Reproduce
nodeLinker: pnp
yarn create vite --template react-ts
yarn dlx storybook@latest init
System
--
Additional context
--
The text was updated successfully, but these errors were encountered: