-
-
Notifications
You must be signed in to change notification settings - Fork 10
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: parse validator values #9
Comments
Can you give a more concrete example ? I'm having a hard time understanding exactly what you mean :S |
Hey! Sure :) If I'm not mistaken, vue-intellisense requires user to define valid values for a prop: /**
* The position of the action buttons.
* @type {'top' | 'bottom' | 'right' | 'left'} <--- this
*/
actionButtonsPosition: {
type: String,
default: 'top',
validator: (prop) => ['top', 'bottom', 'right', 'left'].includes(prop),
}, Notice that the list of valid values is duplicated in I was wondering if we could infer the options the prop from the validator array, so the following snippet would yield the same vetur config as the one above: /**
* The position of the action buttons.
*/
actionButtonsPosition: {
type: String,
default: 'top',
validator: (prop) => validValues.includes(prop), // @type is inferred from here
}, |
Hi! I checked and noticed that this works: /**
* The position of the action buttons.
*/
actionButtonsPosition: {
type: String,
default: 'top',
validator: (prop) => ['top', 'bottom', 'right', 'left'].includes(prop),
}, so I assume the limitation is with using a variable to set the array? |
I'll go ahead and close this issue since this looks like an upstream limitation :) Tracked here: vue-styleguidist/vue-styleguidist#1049 |
@afontcu I'm so sorry I never replied. I got super busy and always forgot to come back to this.
this is exactly right!! : ) Under the hood I use the vue-styleguidist API : ) even though it's upstream, let's keep this issue open so I don't forget ;) |
Hi! And thank you for this amazing tool. I was wondering if it would be possible to parse
validator
values, instead of having to set a@type
JSDoc comment? That would be amazing, because we'd have a single source of truth. vue-styleguidist seems to be able to do so.Thanks! 🙌
The text was updated successfully, but these errors were encountered: