presets: preset-typescript does not work according to instructions
I have a clean setup for storybook/react: npx -p @storybook/cli sb init --type react
I added preset-typescript to new presets.js file like that module.exports = ['@storybook/preset-typescript']; and dependencies npm i -D @storybook/preset-typescript react-docgen-typescript-loader ts-loader
Now I have quite a simple basic configuration:
/*.storybook/config.js*/
import { configure } from '@storybook/react';
// automatically import all files ending in *.stories.js
configure(require.context('../stories', true, /\.stories\.ts$/), module);
/*.storybook/presets.js*/
module.exports = ['@storybook/preset-typescript'];
/*.storybook/addons.js*/
import '@storybook/addon-actions/register';
import '@storybook/addon-links/register';
/*stories/0-Welcome.stories.ts*/
import React from 'react';
import { linkTo } from '@storybook/addon-links';
import { Welcome } from '@storybook/react/demo';
export default {
title: 'Welcome',
};
export const toStorybook = () => <Welcome showApp={linkTo('Button')} />;
toStorybook.story = {
name: 'to Storybook',
};
And instruction says that’s it, but:

So how does it work?
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 7
- Comments: 17 (5 by maintainers)
It looks to me like the problem is with the underlying webpack config. Running
npx start-storybook --debug-webpackwhen presets.js only hasmodule.exports = ["@storybook/preset-typescript"];produces the following:Notice the empty
includearray. But, if you change presets.js such thatincludeis specified…… everything works as expected and the relevant portion of the webpack config has the correct include directive:
Just for the sake of comparison, I checked the generated webpack config in a CRA project and found that it’s using this:
I’m not sure why the
includearray is empty when the directions for installing this preset are followed as published, but I’m reasonably sure that’s the issue.Trying to integrate Storybook as a part of a TSDX component library.
Steps I took:
npx -p @storybook/cli sb init --type reactyarn add -D @storybook/preset-typescript react-docgen-typescript-loader ts-loader fork-ts-checker-webpack-pluginConvert
.storybook/main.jsto:Button.stories.tsxwithinsrc/components/Button/__stories__/:After I run,
yarn storybook, I get the following:I ditched the preset and got everything working with this:
npx -p @storybook/cli sb init --type reactyarn add -D yarn add -D awesome-typescript-loader @storybook/addon-info react-docgen-typescript-loader.storybook/main.js:This should be improved when v6 is released 🙏
Hi have the same issue, however the tsconfig file did not work for me. We keep our stories in folders in with the component, would this make a difference? Below is a the error, looks like nothing is being transpiled using this preset.
I was gonna create a fork and throw up a pull request for this, but it looks like that’s already being addressed by @T0MASD in #83 👍
Bump. Me three.
tsconfig:
I’m having the same issue, tried from scratch a few times, but having the same issue that @daraclare has.