Skip to content

Symbol keys in state objects are not spread into rest props #17094

@gka

Description

@gka

Describe the bug

In JavaScript it is possible to spread Symbol keys into rest props:

const S = Symbol('key');
const a = { foo: 'bar', [S]: 42 }
const { foo, ...rest } = a;
console.log(rest[S]); // logs 42

But in Svelte this doesn't work:

<script>
  const S = Symbol('key');
	
  let a = $state({ foo: 'bar', [S]: 42 });
  $inspect('a[S]:', a[S]); // 42

  let { foo, ...rest } = $derived(a);
  $inspect('rest[S]:', rest[S]); // undefined
</script>

Reproduction

https://svelte.dev/playground/3798e7ae88584fd887cc81645c9522cc?version=5.43.2

Logs

System Info

All browsers, all Svelte 5.x versions (as far as I can tell)

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions