For example, to write your stories in Typescript, rather than with individual babel and configs, you can simply use the @storybook/preset-typescript
package, which does the heavy lifting for you.
Each preset has its own installation instructions, but the idea of presets is to simply install the preset and then load it.
Then load it in the file in your storybook folder (.storybook
by default):
That’s it. When Storybook starts up, it will configure itself for typescript without any further configuration. For more information, see the Typescript preset README.
Consider this example:
This configures the typescript docgen loader using the app’s and also tells the typescript loaders to only be applied to the current directory.
To see what presets are available, see the . To understand more about how presets work and write your own, see writing presets.