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

Destructuring props no longer works without experimental features #8289

Closed
Lehoczky opened this issue May 11, 2023 · 2 comments
Closed

Destructuring props no longer works without experimental features #8289

Lehoczky opened this issue May 11, 2023 · 2 comments

Comments

@Lehoczky
Copy link

Lehoczky commented May 11, 2023

Vue version

3.3

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-hbtqav?file=src/App.vue

Steps to reproduce

Open the example in a new tab to see the console.log's.

You can see that the destructured variable in the Works component has been logged, but the one in the NotWorks component is undefined.

What is expected?

Both props are available. This worked below 3.3

What is actually happening?

Looking at nuxt/nuxt#20789 and nuxt/nuxt#20795 it seems like when we do not enable reactivity transform or the new props destructuring feature, then the destructured props are just lost after compilation.

Probably related to this code path: https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/script/definePropsDestructure.ts#L31

System Info

No response

Any additional comments?

No response

@Lehoczky Lehoczky changed the title destructuring props no longer works without experimental features Destructuring props no longer works without experimental features May 11, 2023
@leopiccionia
Copy link
Contributor

If this feature graduates from experimental to stable, snippets like Nuxt's would break, anyway, because error prop would suddenly become reactive, right? So, while destructuring props might be a valid pattern that should be considered by the compiler, just regressing to previous behavior may not be future-proof.

@Lehoczky
Copy link
Author

Yeah, but it would be better to keep the previous behaviour and introduce a deprecation warning after the new destructuring feature becomes stable and only then change the default compiler output. People would have a chance to react to this breaking change by doing it this way.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 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

2 participants