Skip to content
New issue

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

[Feature Request]: Support correct argTypes type inference for named TypeScript types #23313

Closed
segevfiner opened this issue Jul 4, 2023 · 1 comment

Comments

@segevfiner
Copy link

Is your feature request related to a problem? Please describe

A Vue component defining a prop like this will get it's type correctly inferred by Storybook and will render as a select with the proper types:

const props = defineProps<{
  /**
   * size of the button
   */
  size?: 'small' | 'medium' | 'large',
}>();

A prop defined like this won't get properly inferred and be treated as an object:

type Sizes = 'small' | 'medium' | 'large';

const props = defineProps<{
  /**
   * size of the button
   */
  size?: Sizes,
}>();

Or:

import type { Sizes } from '../sharedTypes';

const props = defineProps<{
  /**
   * size of the button
   */
  size?: Sizes,
}>();

Describe the solution you'd like

For Storybook to be able to correctly infer types in such cases.

Describe alternatives you've considered

Manually overriding the inference using argTypes. Requires also creating an array with the actual values and TypeScript trickery to turn it back into a type.

Are you able to assist to bring the feature to reality?

no

Additional context

No response

@chakAs3
Copy link
Contributor

chakAs3 commented Jul 4, 2023

hi @segevfiner, this issue is fixed in this PR #22285,
You will get something like this
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants