diff --git a/addons/addon-contexts/src/@types/index.ts b/addons/addon-contexts/src/@types/index.ts index 4abb84340629..28264f9f72a6 100644 --- a/addons/addon-contexts/src/@types/index.ts +++ b/addons/addon-contexts/src/@types/index.ts @@ -5,7 +5,7 @@ declare type ReactNode = import('react').ReactNode; declare type ReactElement = import('react').ReactElement; declare type FC

= import('react').FunctionComponent

; -// auxiliary @types +// auxiliary types declare type FCNoChildren

= FC<{ children?: never } & P>; declare type Omit = Pick>; declare type GenericFnWithReturn = (...args: any[]) => T; @@ -13,7 +13,7 @@ declare type GenericProps = { [key: string]: GenericProps } | null; export declare type StringObject = { [key: string]: string }; export declare type StringTuple = [string, string]; -// config @types +// config types export declare type AddonOptions = { deep?: boolean; disable?: boolean; @@ -38,7 +38,7 @@ export declare type ContextNode = Required & { nodeId: string; }; -// duck @types +// duck types export declare type UPDATE_PROPS_MAP = { type: 'UPDATE_PROPS_MAP'; payload: { @@ -50,7 +50,7 @@ export declare type PropsTreeUpdaterType = ( nodes: ContextNode[] ) => ([nodeId, name]: StringTuple) => UPDATE_PROPS_MAP; -// helper @types +// helper types export declare type RenderAggregatedComponents = ( ...arg: [ComponentType[], GenericProps, AddonOptions, number] ) => GenericFnWithReturn; @@ -65,7 +65,7 @@ export declare type UseChannel = ( input?: unknown[] ) => void; -// Component @types +// Component types export declare type Wrapper = (...arg: [Function, unknown, WrapperSettings]) => ReactNode; export declare type TAddonManager = FCNoChildren<{ channel: Channel; @@ -100,3 +100,6 @@ export declare type TToolBarMenuOptions = FCNoChildren<{ list: string[]; onSelectOption: (name: string) => () => void; }>; + +// core types +export declare type WithContexts = (contexts: AddonSetting[]) => any; diff --git a/addons/addon-contexts/src/index.ts b/addons/addon-contexts/src/index.ts index b000b8a94f1b..5ae541d7cb2b 100644 --- a/addons/addon-contexts/src/index.ts +++ b/addons/addon-contexts/src/index.ts @@ -2,7 +2,7 @@ import { createElement as h, Fragment } from 'react'; import addons, { makeDecorator } from '@storybook/addons'; import { AddonWrapper } from './containers/AddonWrapper'; import { ID, PARAM } from './libs/constants'; -import { Wrapper } from './@types'; +import { WithContexts, Wrapper } from './@types'; const wrapper: Wrapper = (getStory, context, settings) => h(AddonWrapper, { @@ -11,7 +11,7 @@ const wrapper: Wrapper = (getStory, context, settings) => children: (ready: boolean) => () => (ready ? getStory(context) : h(Fragment)), }); -export const withContexts = makeDecorator({ +export const withContexts: WithContexts = makeDecorator({ name: ID, parameterName: PARAM, skipIfNoParametersOrOptions: true,