npm.io
7.0.8 • Published 10 months ago

@types/storybook-addon-jsx

Licence
MIT
Version
7.0.8
Deps
3
Size
5 kB
Vulns
0
Weekly
0
Stars
51.4K

Installation

npm install --save @types/storybook-addon-jsx

Summary

This package contains type definitions for storybook-addon-jsx (https://github.com/storybookjs/addon-jsx).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/storybook-addon-jsx.

index.d.ts

import { DecoratorFunction, Parameters, StoryApi } from "@storybook/addons";
import { ReactElement, ReactNode } from "react";

export type displayNameFunc = (element: ReactElement) => string;

export interface AddonParameters {
    skip?: number | undefined;
    enableBeautify?: boolean | undefined;
    onBeforeRender?: ((domString: string) => string) | undefined;
    displayName?: string | displayNameFunc | undefined;
}

export type AddWithJSXFunc<StoryFnReturnType> = (
    kind: string,
    fn: () => ReactNode,
    options?: AddonParameters,
) => StoryApi<StoryFnReturnType>;

declare module "@storybook/addons" {
    interface ClientStoryApi<StoryFnReturnType = unknown> {
        storiesOf(kind: string, module: NodeJS.Module):
            & StoryApi<StoryFnReturnType>
            & { addWithJSX: AddWithJSXFunc<StoryFnReturnType> };
        addDecorator(decorator: DecoratorFunction<StoryFnReturnType>): StoryApi<StoryFnReturnType>;
        addParameters(parameter: Parameters & { jsx: AddonParameters }): StoryApi<StoryFnReturnType>;
    }
}

export const jsxDecorator: DecoratorFunction<ReactElement<unknown>>;

Additional Details

Credits

These definitions were written by James Newell.