import { KindMeta as KindMetaBase , StoryMeta as StoryMetaBase , DecoratorFunction as DecoratorFunctionBase , StoryId , StoryName , StoryKind , DefaultParameters , } from './story' ; type Context = { id : StoryId ; kind : StoryKind ; name : StoryName ; } ; type StoryFn = ( c ? : Context ) => string ; type DecoratorFunction = DecoratorFunctionBase < Context , StoryFn > ; type KindMetaWithParams < Parameters , Component = unknown > = KindMetaBase < DecoratorFunction , Parameters , Component > ; type KindMeta < Component = unknown > = KindMetaWithParams < DefaultParameters , Component > ; type StoryMeta < Parameters = DefaultParameters > = StoryMetaBase < Context , StoryFn , DecoratorFunction , Parameters > ; type UserKindMeta < Component > = KindMetaWithParams < { a : string ; b : number ; c : null ; } , Component > ; const Button = ( ) => 'Button' ; const Input = ( ) => 'Input' ; const simple = { title : 'simple' , } ; const withUnknownComponent = { title : 'component' , component : Button , } ; const withTypedComponent = { title : 'buttonComponent' , component : Button , } ; const withDecorator = { title : 'withDecorator' , decorators : [ ( storyFn , context ) => `withDecorator(${ storyFn ( context ) })` ] , } ; const looseParameters = { title : 'looseKind' , parameters : { a : ( ) => null , b : NaN , c : Symbol ( 'symbol' ) } , } ; const strictParameters = { title : 'strictKind' , parameters : { a : 1 , b ( ) { } , c : [ Promise . resolve ( 'string' ) ] , } , } ; const complexKind = { id : 'button' , title : 'Button' , component : Button , subcomponents : { input : Input } , decorators : [ ( storyFn , context ) => `withDecorator(${ storyFn ( context ) })` ] , parameters : { a : '1' , b : 2 , c : null } , } ; const Simple = ( ) => 'Simple' ; const NamedStory = ( ) => 'Named Story' ; NamedStory . story = { name : 'Another name for story' } ; const DecoratedStory = ( ) => 'Body' ; DecoratedStory . story = { decorators : [ storyFn => `Wrapped(${ storyFn ( ) }` ] , } ; const LooseStory = Button ; LooseStory . story = { parameters : { a : [ 1 , '2' , { } ] , b : undefined , c : Button } , } ; const StrictStory = ( ) => Input ( ) ; StrictStory . story = { parameters : { a : [ '1' , '2' ] , b : Simple , c : ( storyFn , context ) => `withDecorator(${ storyFn ( context ) })` , } , } ; const ComplexStory = ( ) => `Once upon a time, there was a ${ Button ( ) }...` ; Simple . story = { name : 'simple story of lonely button' , decorators : [ ( storyFn , context ) => `Storyteller: '${ storyFn ( context ) }'` ] , parameters : { d : [ ] , e : { } , f : ( ) => null } , } ; const looseKind = complexKind ; const strictA = complexKind . parameters ?. a ?? '' ; const looseA = looseKind . parameters ?. a ; describe ( 'story' , ( ) => { test ( 'kinds' , ( ) => expect ( looseA ) . toBe ( strictA ) ) ; } ) ;