[Bug] StorybookConfig type does not recognize `viteFinal` as a property
See original GitHub issueDescribe the bug
I’ve written my Storybook config in TypeScript as a main.ts
file instead of a main.js
file, but the typings of StorybookConfig
do not recognize viteFinal
as a valid property.
[tsserver 2322] [E] Type '{ stories: string[]; staticDirs: string[]; addons: string[]; framework: string; core: { builder: string; }; features: { storyStoreV7: true; }; viteFinal(storybookDefaultConfig: Record<string, any>, { configType: _configType }: { ...; }): Promise<...>; }' is not assignable to type 'StorybookConfig'.
Object literal may only specify known properties, and 'viteFinal' does not exist in type 'StorybookConfig'.
The definition for those types actually live in @storybook/core-common. I wasn’t sure whether to create this issue in the main repo or here, but figured this was more applicable.
Steps to reproduce the behavior
- Create a clean vite project
- Initialize latest storybook setup with
npx sb@next init --builder @storybook/builder-vite
- Rename
main.js
tomain.ts
and try to assign the config object to the type ofStorybookConfig
. - See type error.
Here is my example config in main.ts
:
import type { StorybookConfig } from '@storybook/core-common'
import { mergeConfig } from 'vite'
import appViteConfig from '../vite.config'
const config: StorybookConfig = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
staticDirs: ['../public'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
],
framework: '@storybook/react',
core: {
builder: '@storybook/builder-vite',
},
features: {
storyStoreV7: true,
},
async viteFinal(
storybookDefaultConfig: Record<string, any>,
{ configType: _configType }
) {
// We combine Storybook's default Vite config with our own. Any Storybook
// specific extensions are customized here as well.
return mergeConfig(mergeConfig(storybookDefaultConfig, appViteConfig), {
optimizeDeps: {
// Including things here works around Vite/storybook prebundling issues
// https://github.com/storybookjs/builder-vite/blob/70a9079fc2d545c046d63ff47666afdf8bb2810e/packages/builder-vite/README.md#known-issues
include: ['msw-storybook-addon'],
},
})
},
}
module.exports = config
Expected behavior
The viteFinal
property should be a recognized property in the typings.
Screenshots and/or logs
N/A
Environment
- OS: MacOS 12.0.1
- Node.js version: 16.14.2
- NPM version: 8.5.0
- Browser (if applicable): N/A
- Browser version (if applicable): N/A
- Device (if applicable): MacBook Pro (14-inch, 2021)
Additional context
N/A
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top Results From Across the Web
[Bug] Builder error with typescript 4.7.4 · Issue #418 - GitHub
What version of vite are you using? ... and build-storybook commands and I got this error. ... import type { StorybookViteConfig } from ......
Read more >How to resolve aliases in Storybook? - Stack Overflow
Couple things, resolve goes at the top-level of the webpack config, not under config.module . Not 100% sure about the webpack export/import ...
Read more >Vite - Storybook
Storybook is a frontend workshop for building UI components and pages in isolation. Thousands of teams use it for UI development, testing, and...
Read more >Using Vite for Bandler in Storybook | miyauci.me
Explains in detail the points where you can get stuck in a preact project. It also shows how to make the Storybook configuration...
Read more >storybookjs/storybook (Raised $170.00) - Issuehunt
[Bug]: v7/csf3 stories are not recognized when functions generate the csf format ... known properties, and 'env' does not exist in type 'StorybookConfig'....
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
This has been released in https://github.com/storybookjs/builder-vite/releases/tag/v0.1.32, thanks for the contribution, @dohooo!
@IanVS #349 Hi~