mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Merge pull request #32561 from amacleay/storybook__addon-info-decorator
@storybook/addon-info: Allow withInfo to be used as top-level story decorator
This commit is contained in:
6
types/storybook__addon-info/index.d.ts
vendored
6
types/storybook__addon-info/index.d.ts
vendored
@@ -6,7 +6,7 @@
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
import { RenderFunction } from '@storybook/react';
|
||||
import { RenderFunction, StoryDecorator } from '@storybook/react';
|
||||
|
||||
export interface WrapStoryProps {
|
||||
storyFn?: RenderFunction;
|
||||
@@ -29,6 +29,10 @@ export interface Options {
|
||||
maxPropStringLength?: number;
|
||||
}
|
||||
|
||||
// TODO: it would be better to use type inference for the parameters
|
||||
// type DecoratorParams = StoryDecorator extends (...a: infer A) => any ? A: never;
|
||||
export function withInfo(story: RenderFunction, context: { kind: string, story: string }): ReturnType<StoryDecorator>;
|
||||
// Legacy, but supported
|
||||
export function withInfo(textOrOptions?: string | Options): (storyFn: RenderFunction) => (context?: object) => React.ReactElement<WrapStoryProps>;
|
||||
|
||||
export function setDefaults(newDefaults: Options): Options;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
/// <reference types="storybook__react" />
|
||||
|
||||
import * as React from 'react';
|
||||
import { storiesOf } from '@storybook/react';
|
||||
import { addDecorator, storiesOf } from '@storybook/react';
|
||||
import { setDefaults, withInfo } from '@storybook/addon-info';
|
||||
|
||||
const { Component } = React;
|
||||
|
||||
addDecorator(withInfo);
|
||||
|
||||
setDefaults({
|
||||
inline: false,
|
||||
propTables: false
|
||||
|
||||
Reference in New Issue
Block a user