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 a props that has a primitive as default value gives a vague error #8863

Closed
JoshQuaintance opened this issue Jun 27, 2023 · 0 comments · Fixed by #8871
Closed
Labels
compiler Changes relating to the compiler

Comments

@JoshQuaintance
Copy link

JoshQuaintance commented Jun 27, 2023

Describe the bug

When a prop is destructured in their export declaration, it would ask for a default value because of the complex binding, and if a user uses a primitive type value (which someone did, asked a question in SO, the reason this issue is raised), it just errors out
with TypeError: Cannot read properties of undefined (reading 'reassigned') which I assume is caused by an attempt to reassign an immutable variable.

Note that this does only happen during build time, and the code would work perfectly fine on dev mode

I know creating readable error traces depends on issues found, and I think there can be a better error message that would tell the person about it, or maybe prevent them from destructuring a prop.

Here's the SO question: https://stackoverflow.com/questions/76566184/svelte-compiler-gives-me-an-error-in-my-icon-component-file-while-building-wh/76568264#76568264

Reproduction

https://svelte.dev/repl/37cb75a470a443c3b767ad7d79cdb7b7?version=4.0.0

Logs

/* Error compiling component

Cannot read properties of undefined (reading 'reassigned')

*/

System Info

Svelte: ^4.0.0

Severity

annoyance

@dummdidumm dummdidumm added the compiler Changes relating to the compiler label Jun 28, 2023
dummdidumm pushed a commit that referenced this issue Jul 11, 2023
fixes #8863

---------

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Changes relating to the compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants