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

feat(component-meta): add typing resolution for defineModel modifiers #4175

Merged

Conversation

stafyniaksacha
Copy link
Collaborator

This PR aims to retrieve types of model modifiers from defineModel macro.

// default
const [modelValue, modelModifiers] = defineModel<string, 'lazy' | 'trim'>()

// modelValue: import("vue").PropType<string>
// modelModifiers: import("vue").PropType<Record<'lazy' | 'trim', true>>


// named
const [named, modifiers] = defineModel<string, 'foo'>('named')

// named: import("vue").PropType<string>
// namedModifiers: import("vue").PropType<Record<'foo', true>>

Here is a playground where we can see property being generated: https://play.vuejs.org/#eNqFkk1PwzAMhv+KlUtBqrYDnKZuEqAdQOJDgLgQDlHrlow0iZJ0DEr/O26qlQlN2y1+/dp+bKVlF9ZO1g2yGct87qQN4DE0FpTQ1Zyz4DlbcJ0b7QO81qZA9SJUgynE960pZCnR+TeYQ4Gl1EgSqswHJ3WVQqLE91cCP5CQUCeLk9OxmRY1FrHPkRalMVSYRH9C9dl0ICUuCgLWVomAFAFk1uGibaHtAxgY9/Kmg+E/Q5Q76Lps2nfqZ+30Zyndg+hLWU1W3mg6WhzEWW5qKxW6exskbcfZbIvAmVDKfN5ELTgi2er5O+Yfe/SV3/QaZw8OPbo1cjbmgnAVhiG9fLrDDb3HJG3RKHIfSD6iN6rpGQfbZaMLwt7xRdrr2hoX6PrPfrkJqP12qR40nij6OaOfc3Vg9T/cs8l5rOO6Y90vLZfTGA==

Co-authored-by: Johnson Chu <johnsoncodehk@gmail.com>
@johnsoncodehk johnsoncodehk merged commit df80d70 into vuejs:master Mar 31, 2024
3 checks passed
@johnsoncodehk
Copy link
Member

Thanks!

@stafyniaksacha stafyniaksacha deleted the feat/define-model-modifiers branch March 31, 2024 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants