From f15efe5921009e64586ac5a5e6d7d04af503d925 Mon Sep 17 00:00:00 2001 From: Janeene Beeforth Date: Wed, 7 Mar 2018 23:31:42 +1100 Subject: [PATCH] [@storybook/addon-actions]: Fix faulty decoratedAction definition. The decoratedAction function is supposed to return a function equivalent to the action function, rather than the return value of running the action function. The reason that the original tests were passing was because it is valid typescript to set the onClick handler of a button to undefined. --- types/storybook__addon-actions/index.d.ts | 2 +- .../storybook__addon-actions-tests.tsx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/types/storybook__addon-actions/index.d.ts b/types/storybook__addon-actions/index.d.ts index 9b7009fbad..2d5cc73ef8 100644 --- a/types/storybook__addon-actions/index.d.ts +++ b/types/storybook__addon-actions/index.d.ts @@ -7,5 +7,5 @@ export type HandlerFunction = (...args: any[]) => undefined; export type DecoratorFunction = (args: any[]) => any[]; -export function decorateAction(decorators: DecoratorFunction[]): HandlerFunction; +export function decorateAction(decorators: DecoratorFunction[]): (name: string) => HandlerFunction; export function action(name: string): HandlerFunction; diff --git a/types/storybook__addon-actions/storybook__addon-actions-tests.tsx b/types/storybook__addon-actions/storybook__addon-actions-tests.tsx index 77ba80985b..b9c9bbba7f 100644 --- a/types/storybook__addon-actions/storybook__addon-actions-tests.tsx +++ b/types/storybook__addon-actions/storybook__addon-actions-tests.tsx @@ -19,3 +19,21 @@ storiesOf('Button', module) Hello World! )); + +interface CustomComponentProps { + id: string; + setValues(id: string, values: string[]): void; +} +class CustomComponent extends React.Component { + setSomeValues = () => { + this.props.setValues(this.props.id, ['one', 'two', 'three']); + } + render() { + return ; + } +} + +storiesOf('CustomComponent', module) + .add('decorated custom action', () => ( + + ));