Skip to content
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

Docs: Typescript Configuration Examples for v5 #5928

Merged
merged 1 commit into from
Mar 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions docs/src/pages/configurations/typescript-config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,25 @@ We first have to use the [custom Webpack config in full control mode, extending

```js
const path = require('path');
module.exports = (baseConfig, env, config) => {
module.exports = ({ config, mode }) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [{
loader: require.resolve('awesome-typescript-loader')
}, {
loader: require.resolve('react-docgen-typescript-loader')
}]
use: [
{
loader: require.resolve('awesome-typescript-loader')
},
// Optional
{
loader: require.resolve('react-docgen-typescript-loader')
}
]
});
config.resolve.extensions.push('.ts', '.tsx');
return config;
};
```

The above example shows a working Webpack config with the TSDocgen plugin also integrated; remove the optional sections if you don't plan on using them.
The above example shows a working Webpack config with the [TSDocgen plugin](https://github.com/strothj/react-docgen-typescript-loader) integrated. This plugin is not necessary to use Storybook and the section marked `// optional` can be safely removed if the features of TSDocgen are not required.

### `tsconfig.json`

Expand Down Expand Up @@ -91,13 +95,13 @@ yarn add -D @types/storybook__react # typings
We first have to use the [custom Webpack config in full control mode, extending default configs](/configurations/custom-webpack-config/#full-control-mode--default) by creating a `webpack.config.js` file in our Storybook configuration directory (by default, it’s `.storybook`):

```js
module.exports = (baseConfig, env, config) => {
module.exports = ({ config, mode }) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve('babel-loader'),
options: {
presets: [['react-app', { flow: false, typescript: true }]],
},
presets: [['react-app', { flow: false, typescript: true }]]
}
});
config.resolve.extensions.push('.ts', '.tsx');
return config;
Expand Down