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

Cannot use prop as default value for other prop with props destructuring const { foo, bar = foo } #12386

Open
minht11 opened this issue Nov 13, 2024 · 0 comments · May be fixed by #12387
Open

Comments

@minht11
Copy link

minht11 commented Nov 13, 2024

Vue version

3.5.12

Link to minimal reproduction

https://play.vuejs.org/#__PROD__eNp9UsFOwzAM/RUrF0CaOsHgUrohQEOCA0zAMRIqrVsy2iRK0jKp6r/jZOvY0LRTbL/n5NkvHbvVOmobZDFLHNa6Sh3OuARIHpSCuFBqytlJesIZjKmejHdIlNrMCO3Aoms0VUStlXHgWwujauAsGlPiH+Ds2revG4jKRszZTMlClNHSKkkCOv8uZ5mqtajQvGgnlLScxRAQj6VVpX6eQs2ZBkdDPfvC7PtAfWlXvsbZwqBF05KMLeZSU6Jbw/O3Z1xRvAVrlTcVsY+Ar2hV1XiNa9pdI3OSvcMLah/DToQs3+185VDaYSgv1DP7wOeMlnR/ZPQ/uZPoMvRx2dMWN/v1Bm7cqFJZkmuO+rfO0Katgw7I0BF8pgamPoSezhwLIXFhlLZJIMRgnSHBgXgzZNDPTs/2LKRk/8vkog3BJgxXdR0dfZ+M/4F09QFwiPb+GQ350aLxi6MpJ9FVdH7B+l9N7+ZX

Steps to reproduce

Have code like this: const { foo, bar = foo } = defineProps<{ foo: string, bar?: string }>()

What is expected?

No error.

What is actually happening?

Error foo is not defined

System Info

n/a

Any additional comments?

const { a, b = a } = { a: 1, b: undefined } is valid syntax in regular js and as such should be supported in vue also.

@minht11 minht11 changed the title Cannot use one from to set other prop default value with props destructuring Cannot use prop as default value for other prop with props destructuring Nov 13, 2024
@minht11 minht11 changed the title Cannot use prop as default value for other prop with props destructuring Cannot use prop as default value for other prop with props destructuring const { foo, bar = foo } Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants