From ff0a65d0586ba322ba9dcb06a7fb552fdd02c5e2 Mon Sep 17 00:00:00 2001 From: Mark Kornblum Date: Thu, 12 Oct 2017 18:32:16 -0700 Subject: [PATCH] Add storybook/addon-info types (#20538) * Add storybook__addon-info types for version 3.2 * Better return type * Remove unnecessary compiler option --- types/storybook__addon-info/index.d.ts | 31 ++++++++++++++++++ .../storybook__addon-info-tests.tsx | 30 +++++++++++++++++ types/storybook__addon-info/tsconfig.json | 32 +++++++++++++++++++ types/storybook__addon-info/tslint.json | 1 + 4 files changed, 94 insertions(+) create mode 100644 types/storybook__addon-info/index.d.ts create mode 100644 types/storybook__addon-info/storybook__addon-info-tests.tsx create mode 100644 types/storybook__addon-info/tsconfig.json create mode 100644 types/storybook__addon-info/tslint.json diff --git a/types/storybook__addon-info/index.d.ts b/types/storybook__addon-info/index.d.ts new file mode 100644 index 0000000000..68179af293 --- /dev/null +++ b/types/storybook__addon-info/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for @storybook/addon-info 3.2 +// Project: https://github.com/storybooks/storybook +// Definitions by: Mark Kornblum +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import * as React from 'react'; +import { RenderFunction } from '@storybook/react'; + +export interface WrapStoryProps { + storyFn?: RenderFunction; + context?: object; + options?: object; +} + +export interface Options { + text?: string; + header?: boolean; + inline?: boolean; + source?: boolean; + propTables?: JSX.Element[]; + propTablesExclude?: JSX.Element[]; + styles?: object; + marksyConf?: object; + maxPropsIntoLine?: number; + maxPropObjectKeys?: number; + maxPropArrayLength?: number; + maxPropStringLength?: number; +} + +export function withInfo(textOrOptions: string | Options): (storyFn: RenderFunction) => () => React.ReactElement; diff --git a/types/storybook__addon-info/storybook__addon-info-tests.tsx b/types/storybook__addon-info/storybook__addon-info-tests.tsx new file mode 100644 index 0000000000..562727c6fa --- /dev/null +++ b/types/storybook__addon-info/storybook__addon-info-tests.tsx @@ -0,0 +1,30 @@ +/// + +import * as React from 'react'; +import { storiesOf } from '@storybook/react'; +import { withInfo } from '@storybook/addon-info'; + +const { Component } = React; + +storiesOf('Component', module) + .add('simple info', + withInfo('doc string about my component')(() => + Click the "?" mark at top-right to view the info. + ) + ) + .add('using an options object', + withInfo({ + text: 'String or React Element with docs about my component', + inline: true, + header: true, + source: true, + styles: {}, + marksyConf: {}, + maxPropObjectKeys: 1, + maxPropArrayLength: 2, + maxPropsIntoLine: 3, + maxPropStringLength: 4, + })(() => + Click the "?" mark at top-right to view the info. + ) + ); diff --git a/types/storybook__addon-info/tsconfig.json b/types/storybook__addon-info/tsconfig.json new file mode 100644 index 0000000000..87d702ce2b --- /dev/null +++ b/types/storybook__addon-info/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "paths": { + "@storybook/addon-info": [ + "storybook__addon-info" + ], + "@storybook/react": [ + "storybook__react" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "storybook__addon-info-tests.tsx" + ] +} diff --git a/types/storybook__addon-info/tslint.json b/types/storybook__addon-info/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/storybook__addon-info/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }