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

Optional props are incorrectly typed in <template> #3779

Closed
DrJume opened this issue Dec 6, 2023 · 1 comment · Fixed by #3838
Closed

Optional props are incorrectly typed in <template> #3779

DrJume opened this issue Dec 6, 2023 · 1 comment · Fixed by #3838
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first upstream

Comments

@DrJume
Copy link

DrJume commented Dec 6, 2023

Optional props in Vue 3 are not optional anymore on the resolved props value from defineProps:

Additionally, Vue 3 casts optional boolean props to only type boolean, because of https://vuejs.org/guide/components/props.html#boolean-casting.

The only correct way to allow undefined for a boolean prop is to manually set it as a default with withDefaults. (see reproduction components/BooleanWithUndefined.vue)

This should also reflect in the <template>.

Link to reproduction

@so1ve so1ve added bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first labels Dec 6, 2023
@johnsoncodehk
Copy link
Member

It will fix in Vue 3.5 via vuejs/core#10801.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first upstream
Projects
None yet
3 participants