Skip to content

Commit

Permalink
explain usage for higher kinded T
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperpeulen committed Oct 10, 2022
1 parent 9a29dd4 commit fbf3c7a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ export type StrictGlobalTypes = { [name: string]: StrictInputType };

export type AnyFramework = {
component: unknown;
T: unknown;
storyResult: unknown;
// A generic type T that can be used in the definition of the component like this:
// component: (args: this['T']) => string;
// This generic type will eventually be filled in with TArgs
// Credits to Michael Arnaldi.
T: unknown;
};

export type StoryContextForEnhancers<
Expand Down Expand Up @@ -267,7 +271,7 @@ export interface ComponentAnnotations<TFramework extends AnyFramework = AnyFrame
*
* Used by addons for automatic prop table generation and display of other component metadata.
*/
component?: (TFramework & { T: Args extends TArgs ? any : TArgs})['component'];
component?: (TFramework & { T: Args extends TArgs ? any : TArgs })['component'];

/**
* Auxiliary subcomponents that are part of the stories.
Expand Down

0 comments on commit fbf3c7a

Please sign in to comment.