Checking the Story
type, it's defined as BaseStory<Args, StoryFnReactReturnType> & Annotations<Args, StoryFnReactReturnType>
.
BaseStory
isn't particularly interesting or relevant here, but Annotations
has the property: args?: Partial<Args>
.
In your code, Args
is LoaderProps
, so the Annotations
object has an optional property args
that itself is all of the LoaderProps
properties made optional. That is, loader.args
is of type Partial<LoaderProps>
which is { open?: boolean }
. The fact that it is optional is what allows it to also be undefined
.
As for why storybook does this, I can only guess since the documentation in the types on Annotation.args
in the type definitions has a dead link. If the properties on args
were required, then you would have to set all of the properties in your Props
definitions.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…