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

Empty attribute can be a string as well #261

Closed
jods4 opened this issue Jun 10, 2021 · 0 comments
Closed

Empty attribute can be a string as well #261

jods4 opened this issue Jun 10, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@jods4
Copy link

jods4 commented Jun 10, 2021

Volar incorrectly errors if you're using an empty attribute to target a non-boolean prop.

Here you can see Type 'true' is not assignable to type 'string | undefined':
image

It assumes that empty attribute are true, which is not compatible with string but that's not an accurate representation of runtime behavior.

Vue only coalesces an empty attribute into true if the target prop is typed as a boolean.
If the target prop is a string, then no conversion occurs and it's set to an empty string.

So in the example above, confirm is set to the value "", which is assignable to type string | undefined

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants