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

Support TS annotation on v-model #4640

Closed
qgates opened this issue Sep 21, 2021 · 1 comment
Closed

Support TS annotation on v-model #4640

qgates opened this issue Sep 21, 2021 · 1 comment

Comments

@qgates
Copy link

qgates commented Sep 21, 2021

What problem does this feature solve?

An object with attributes of union type throws ts2322 in Volar when supplied to v-model for textarea, input (and others). v-bind allows TS type annotation on attributes, clearing the error, but v-model does not. Ergo the only current workaround is to use a v-bind/@change combo where TS annotations can be used.

Example usecase:

interface MyType {
  data: string|Date,
}

Template:

<textarea v-model="arr[index].data as string" ...

where arr is a MyType[]

More info: vuejs/language-tools#512

@qgates
Copy link
Author

qgates commented Sep 21, 2021

@yyx990803 maybe I'm missing something but I still see errors in template compilation and Volar with the above?

@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant