Skip to content

Destructuring a props that has a primitive as default value gives a vague error #8863

@JoshQuaintance

Description

@JoshQuaintance

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerChanges relating to the compiler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions