From e2c87fc5b8660d2a8607b67382fe2ecb32e17f01 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Mon, 26 Jun 2017 17:52:16 +0200 Subject: [PATCH] add @storybook/addon-actions --- types/storybook__addon-actions/index.d.ts | 16 +++++++++++ .../storybook__addon-actions-tests.tsx | 19 +++++++++++++ types/storybook__addon-actions/tsconfig.json | 28 +++++++++++++++++++ types/storybook__addon-actions/tslint.json | 1 + 4 files changed, 64 insertions(+) create mode 100644 types/storybook__addon-actions/index.d.ts create mode 100644 types/storybook__addon-actions/storybook__addon-actions-tests.tsx create mode 100644 types/storybook__addon-actions/tsconfig.json create mode 100644 types/storybook__addon-actions/tslint.json diff --git a/types/storybook__addon-actions/index.d.ts b/types/storybook__addon-actions/index.d.ts new file mode 100644 index 0000000000..b650cd2d55 --- /dev/null +++ b/types/storybook__addon-actions/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for @storybook/addon-actions 3.0 +// Project: https://github.com/storybooks/storybook +// Definitions by: Joscha Feth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +// TODO: Once https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17434 is merged +// Remove the `declare module` wrapper. +// tslint:disable-next-line no-single-declare-module +declare module '@storybook/addon-actions' { + type HandlerFunction = (...args: any[]) => undefined; + type DecoratorFunction = (args: any[]) => any[]; + + function decorateAction(decorators: DecoratorFunction[]): HandlerFunction; + 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 new file mode 100644 index 0000000000..837a4ba214 --- /dev/null +++ b/types/storybook__addon-actions/storybook__addon-actions-tests.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +import { storiesOf } from '@storybook/react'; +import { action, decorateAction } from '@storybook/addon-actions'; + +const firstArgAction = decorateAction([ + args => args.slice(0, 1) +]); + +storiesOf('Button', module) + .add('action', () => ( + + )) + .add('decorated action', () => ( + + )); diff --git a/types/storybook__addon-actions/tsconfig.json b/types/storybook__addon-actions/tsconfig.json new file mode 100644 index 0000000000..1e05a92628 --- /dev/null +++ b/types/storybook__addon-actions/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@storybook/addon-actions": ["storybook__addon-actions"], + "@storybook/react": ["storybook__react"] + } + }, + "files": [ + "index.d.ts", + "storybook__addon-actions-tests.tsx" + ] +} diff --git a/types/storybook__addon-actions/tslint.json b/types/storybook__addon-actions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/storybook__addon-actions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }