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

incorrect default value of boolean prop in defineProps #12543

Closed
CaiWenlie opened this issue Dec 13, 2024 · 1 comment
Closed

incorrect default value of boolean prop in defineProps #12543

CaiWenlie opened this issue Dec 13, 2024 · 1 comment

Comments

@CaiWenlie
Copy link

Vue version

3.5.13

Link to minimal reproduction

https://play.vuejs.org/#eNqFUstOwzAQ/JWVLwWpSg5wqtIiQD3AASrg6EuabIOLY1t+lEoh/87aoQ8kaG87O7P27NgduzUm2wRkE1a4ygrjwaEPBmSpmiln3nE240q0RlsP97o1sLK6hVGWRxBHR1xxVeTDNGkJeGyNLD0SAijSVE51kR8RbEyHV1qtRJOtnVbkoItyzirSC4n22XihFRmYQGIiV0qpPx9Tz9uA412/esfq44/+2m1jj7OFRYd2g5ztOV/aBv1Az1+fcEv1nmx1HSSpT5Av6LQM0eMguwuqJttHuuT2IWUnVPPm5luPyu2Wikajsk96zijLGNV/qx/sXmXXaY6rnlLcvcOZJ6SonQdjtXEwhRpXQuEioiLdUN5MwHlLNpObJUEV2iXaBCuCS60llirh+oDhC2jvdFxNhmYXl6d/Qy02qQDouh87PW1CTD5Qv39J/w0r/uD7

Steps to reproduce

define props like:

const props = defineProps<{
  a?: string,
  b?: number,
  c?: boolean,
  d?: boolean | undefined
}>()

got the result:

{ "c": false, "d": false }

What is expected?

default value of (not required) boolean props should be undefined

What is actually happening?

got false

System Info

No response

Any additional comments?

No response

@jacekkarczmarczyk
Copy link
Contributor

jacekkarczmarczyk commented Dec 13, 2024

It's not a bug, it's a documented behaviour https://vuejs.org/guide/components/props.html#boolean-casting

@jh-leong jh-leong closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 28, 2024
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

3 participants