You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
decorators adding args (undocumented, probably we want to deprecate this).
Currently we treat the "input" args as the same type as the component's props, but this is incorrect. For conditional controls, it is not an issue, as if an arg is optional, then the component's prop must be optional too.
Describe the solution you'd like
For arg mappings, we can use the type of the mapping object to transform TArgs taken from the component to TInputArgs used in story objects:
exportconstMyComponent=({ children }: {children: ReactNode})=>{};constmeta: Meta<typeofMyComponent>{render(args:TArgs){// TArgs should = ComponentProps<typeof MyComponent>, so you can do:return<MyComponent{...args}/>;// or similar},argTypes: {children: {mapping: {icon: <Icon/>,button: <Button/>}}},// However the type of args here should be TInputArgs,// where TInputArgs['children'] = 'icon' | 'button'args: {children: 'icon'}}
### Describealternativesyou've considered
_No response_
### Are you able to assist to bring the feature to reality?
no
### Additional context
_No response_
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe
It's possible for args to change from the unmapped ("input") args in various ways before reaching the story's render function:
Currently we treat the "input" args as the same type as the component's props, but this is incorrect. For conditional controls, it is not an issue, as if an arg is optional, then the component's prop must be optional too.
Describe the solution you'd like
For arg mappings, we can use the type of the
mapping
object to transformTArgs
taken from the component toTInputArgs
used in story objects:The text was updated successfully, but these errors were encountered: