-
Notifications
You must be signed in to change notification settings - Fork 24
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
enable typescript in project #5
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,24 @@ | ||
module.exports = { | ||
stories: ['../src/components/**/*.stories.js'], | ||
stories: ['../src/**/*.stories.(js|tsx)'], | ||
addons: ['@storybook/addon-actions', '@storybook/addon-links'], | ||
|
||
/** | ||
* todo: once https://github.com/storybookjs/presets/pull/83 is merged in, we may no longer need | ||
* to do this manually and simply just use the preset | ||
*/ | ||
webpackFinal: async config => { | ||
config.module.rules.push({ | ||
test: /\.(ts|tsx)$/, | ||
use: [ | ||
{ | ||
loader: require.resolve('ts-loader'), | ||
}, | ||
{ | ||
loader: require.resolve('react-docgen-typescript-loader'), | ||
}, | ||
], | ||
}); | ||
config.resolve.extensions.push('.ts', '.tsx'); | ||
return config; | ||
}, | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from "react"; | ||
import MySillyButton from "./button"; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
export default { | ||
title: 'MySillyButton', | ||
component: MySillyButton, | ||
}; | ||
|
||
export const example = () => <MySillyButton onClick={action('clicked')} /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as React from "react"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to figure out how to write There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try |
||
|
||
interface MySillyButton { | ||
onClick: any | ||
} | ||
const MySillyButton = ({ onClick }: MySillyButton) => <button onClick={onClick}>hehe</button>; | ||
|
||
export default MySillyButton; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "build/lib", | ||
"module": "commonjs", | ||
"target": "es5", | ||
"lib": ["es5", "es6", "es7", "es2017", "dom"], | ||
"sourceMap": true, | ||
"allowJs": false, | ||
"jsx": "react", | ||
"moduleResolution": "node", | ||
"rootDirs": ["src"], | ||
"baseUrl": "src", | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"declaration": true, | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true, | ||
"allowSyntheticDefaultImports": true, | ||
"esModuleInterop": true | ||
}, | ||
"include": ["./src"], | ||
"exclude": ["node_modules", "build", "scripts"] | ||
} |
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that the
typescript-preset
actually has an error 🤦♀️. This manual step is required till the PR fix is merged in.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference, here is the link to the related github issue: storybookjs/presets#65