Add storybook/addon-info types (#20538)

* Add storybook__addon-info types for version 3.2

* Better return type

* Remove unnecessary compiler option
This commit is contained in:
Mark Kornblum 2017-10-12 18:32:16 -07:00 committed by Wesley Wigham
parent 7f298ec31e
commit ff0a65d058
4 changed files with 94 additions and 0 deletions

31
types/storybook__addon-info/index.d.ts vendored Normal file
View File

@ -0,0 +1,31 @@
// Type definitions for @storybook/addon-info 3.2
// Project: https://github.com/storybooks/storybook
// Definitions by: Mark Kornblum <https://github.com/mkornblum>
// 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<WrapStoryProps>;

View File

@ -0,0 +1,30 @@
/// <reference types="storybook__react" />
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')(() =>
<Component>Click the "?" mark at top-right to view the info.</Component>
)
)
.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,
})(() =>
<Component>Click the "?" mark at top-right to view the info.</Component>
)
);

View File

@ -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"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }