-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
Description
Describe the bug
When using slot variables, if you have a variable that's an object and you try to destructure it there's no problem:
<!-- this is fine: -->
<Component let:data={{ foo, bar, baz }} />However, if you try to rename some key in the object, or destructure a nested object, a compilation error is thrown:
<!-- this fails: -->
<Component let:data={{ foo: fooRenamed }} />
<!-- so does this: -->
<Component let:data={{ bar: { nestedInBar } }} />Interestringly, the Svelte for VS Code extension doesn't show any errors on the destructured code, perhaps because it's valid javascript.
Reproduction
https://svelte.dev/repl/98917cf206794f20a4d3c45d012583be?version=3.58.0
Logs
Stack trace from svelte.repl:
TypeError: Cannot read properties of undefined (reading 'index')
at get_slot_definition.ts:60:88
at Array.map (<anonymous>)
at get_slot_definition (get_slot_definition.ts:60:33)
at new SlotTemplateWrapper (SlotTemplate.ts:57:4)
at index.ts:92:52
at Array.map (<anonymous>)
at new InlineComponentWrapper (index.ts:92:39)
at new FragmentWrapper (Fragment.ts:124:21)
at new Renderer (Renderer.ts:90:19)
at dom (index.ts:23:19)System Info
Svelte: v3.58.0
All browsersSeverity
annoyance