We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am having issues with mapping complex types to more usable args in storybook.
I created an example using one of your storybook examples and these are the props of the component
type User = { name: string; }; interface HeaderProps { user?: User; onLogin?: () => void; onLogout?: () => void; onCreateAccount?: () => void; }
I then do the mapping as shown in the docs
const userOne = { name: 'Jane Doe' }; const userTwo = { name: 'John Smith' }; const userThree = { name: 'bobby' }; const users = { userOne, userTwo, userThree }; const meta = { ... argTypes: { user: { options: Object.keys(users), mapping: users, control: { type: 'radio', }, }, }, } satisfies Meta<typeof Header>;
I then render the story like so, which works for storybook and correctly renders userOne
userOne
export const LoggedIn: Story = { args: { user: 'userOne', }, };
However this throws a type error as Type 'string' is not assignable to type 'User'..
Type 'string' is not assignable to type 'User'.
https://stackblitz.com/edit/github-xzv4rz?file=src%2Fstories%2FHeader.stories.ts
Storybook Environment Info: System: OS: macOS 14.4.1 CPU: (10) arm64 Apple M1 Pro Shell: 5.9 - /bin/zsh Binaries: Node: 18.19.1 - ~/.nvm/versions/node/v18.19.1/bin/node Yarn: 1.22.22 - ~/.nvm/versions/node/v18.19.1/bin/yarn npm: 10.2.4 - ~/.nvm/versions/node/v18.19.1/bin/npm pnpm: 9.0.5 - ~/.nvm/versions/node/v18.19.1/bin/pnpm <----- active Browsers: Chrome: 123.0.6312.87 Edge: 124.0.2478.80 Safari: 17.4.1
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
Summary
I am having issues with mapping complex types to more usable args in storybook.
I created an example using one of your storybook examples and these are the props of the component
I then do the mapping as shown in the docs
I then render the story like so, which works for storybook and correctly renders
userOne
However this throws a type error as
Type 'string' is not assignable to type 'User'.
.To Reproduce
https://stackblitz.com/edit/github-xzv4rz?file=src%2Fstories%2FHeader.stories.ts
System
Additional context
No response
The text was updated successfully, but these errors were encountered: