Skip to content

Commit 76fec26

Browse files
committed
js: tsconfig and tsconfig.base updated; .storybook tsconfigs updated, app works now
1 parent f194c2a commit 76fec26

File tree

12 files changed

+38
-65
lines changed

12 files changed

+38
-65
lines changed

js/.storybook/stories/Info.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
import * as React from 'react';
2-
export declare let Info: (fn: React.FunctionComponent<{}>) => any;
2+
declare type InfoComponent = (fn: React.FunctionComponent) => () => React.ReactElement<any>;
3+
export declare let Info: InfoComponent;
4+
export {};

js/.storybook/stories/Info.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

js/.storybook/stories/Info.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as React from 'react'
22
import { withInfo } from "@storybook/addon-info";
33

4-
export let Info = (fn: React.FunctionComponent) => withInfo({ inline: true })(() => {
4+
type InfoComponent = (fn: React.FunctionComponent) => () => React.ReactElement<any>
5+
6+
export let Info: InfoComponent = (fn: React.FunctionComponent) => withInfo({ inline: true })(() => {
57
return <div style={{padding: '10px 40px'}}>{fn({})}</div>
68
})

js/.storybook/stories/StoryButton.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
/// <reference types="react" />
12
declare type TOnClick = () => void;
23
declare type Props = {
4+
/**
5+
* Example value to display
6+
**/
37
enum?: " " | "a" | "b";
8+
/** Example value with string type */
49
value: string;
10+
/** Example value with some object type */
511
position?: {
612
x: number;
713
y: number;
814
};
15+
/** Example onClick with custom type */
916
onClick?: TOnClick;
1017
};
1118
export declare function StoryButton(props?: Props): JSX.Element;

js/.storybook/stories/StoryButton.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

js/.storybook/stories/StoryButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ type Props = {
1919
}
2020

2121
export function StoryButton(props: Props = {value: "Hello world!"}) {
22-
let [state, setState] = React.useState(0)
22+
let [state, setState] = React.useState(0)
23+
let {onClick} = props
2324
return <button onClick={() => {
2425
setState(++state);
25-
props.onClick();
26+
if (onClick!=null){onClick()}
2627
}}>{props.value}: {state}</button>
2728
}

js/.storybook/stories/index.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

js/.storybook/stories/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { Info } from "./Info";
77

88
import { StoryButton } from "./StoryButton";
99

10-
storiesOf("Button", module).add("With example value", Info(() => (
10+
storiesOf("Button", module).add("With example value", Info(() => (
1111
<StoryButton
1212
value={"Hello there!"}
13-
onClick={action('StoryButton onClick')}
13+
onClick={action('StoryButton onClick!')}
1414
/>
1515
)));

js/.storybook/tsconfig.build.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../tsconfig.base",
3+
"compilerOptions": {
4+
"rootDir": "./",
5+
"emitDeclarationOnly": true
6+
},
7+
"include": ["./stories/**/*.tsx", "./stories/**/*.ts"],
8+
}

js/.storybook/tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"extends": "../tsconfig.base",
33
"compilerOptions": {
4-
"rootDir": "./"
4+
"rootDir": "./",
5+
"emitDeclarationOnly": false
56
},
6-
"include": ["./stories/**/*.ts"]
7+
"include": ["./stories/**/*.tsx", "./stories/**/*.ts"],
78
}

0 commit comments

Comments
 (0)