diff --git a/package.json b/package.json index b38ce45..ba64d01 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "@storybook/eslint-config-storybook" ], "rules": { + "@typescript-eslint/no-empty-interface": "off", "import/no-unresolved": "error", "jest/expect-expect": [ "warn", diff --git a/src/story.ts b/src/story.ts index df41a93..424edf1 100644 --- a/src/story.ts +++ b/src/story.ts @@ -200,7 +200,7 @@ export interface StrictGlobalTypes { [name: string]: StrictInputType; } -export type Renderer = { +export interface Renderer { /** What is the type of the `component` annotation in this renderer? */ component: unknown; @@ -215,7 +215,7 @@ export type Renderer = { // This generic type will eventually be filled in with TArgs // Credits to Michael Arnaldi. T?: unknown; -}; +} /** @deprecated - use `Renderer` */ export type AnyFramework = Renderer; @@ -247,13 +247,6 @@ export interface StoryContextUpdate { } export type ViewMode = 'story' | 'docs'; -export interface StoryContextForLoaders - extends StoryContextForEnhancers, - Required> { - hooks: unknown; - viewMode: ViewMode; - originalStoryFn: StoryFn; -} export type LoaderFunction = ( context: StoryContextForLoaders @@ -266,13 +259,30 @@ export type BeforeEach = ( context: StoryContext ) => Awaitable; +export interface Canvas {} + export interface StoryContext - extends StoryContextForLoaders { + extends StoryContextForEnhancers, + Required> { loaded: Record; abortSignal: AbortSignal; canvasElement: TRenderer['canvasElement']; + hooks: unknown; + originalStoryFn: StoryFn; + viewMode: ViewMode; + step: StepFunction; + context: this; + canvas: Canvas; } +/** @deprecated Use {@link StoryContext} instead. */ +export interface StoryContextForLoaders + extends StoryContext {} + +/** @deprecated Use {@link StoryContext} instead. */ +export interface PlayFunctionContext + extends StoryContext {} + export type StepLabel = string; export type StepFunction = ( @@ -280,13 +290,6 @@ export type StepFunction = play: PlayFunction ) => Promise | void; -export type PlayFunctionContext = StoryContext< - TRenderer, - TArgs -> & { - step: StepFunction; -}; - export type PlayFunction = ( context: PlayFunctionContext ) => Promise | void; @@ -325,10 +328,10 @@ export type DecoratorApplicator = ( label: StepLabel, play: PlayFunction, - context: PlayFunctionContext + context: StoryContext ) => Promise; -export type BaseAnnotations = { +export interface BaseAnnotations { /** * Wrapper components or Storybook decorators that wrap a story. * @@ -382,12 +385,10 @@ export type BaseAnnotations * Named tags for a story, used to filter stories in different contexts. */ tags?: Tag[]; -}; +} -export type ProjectAnnotations< - TRenderer extends Renderer = Renderer, - TArgs = Args -> = BaseAnnotations & { +export interface ProjectAnnotations + extends BaseAnnotations { argsEnhancers?: ArgsEnhancer[]; argTypesEnhancers?: ArgTypesEnhancer[]; /** @@ -398,7 +399,7 @@ export type ProjectAnnotations< globalTypes?: GlobalTypes; applyDecorators?: DecoratorApplicator; runStep?: StepRunner; -}; +} type StoryDescriptor = string[] | RegExp; export interface ComponentAnnotations