Skip to content

Docs on $$props/$$restProps optimisation are vagueΒ #8249

@brunnerh

Description

@brunnerh

Describe the bug

The docs state:

$$props references all props that are passed to a component, including ones that are not declared with export. It is not generally recommended, as it is difficult for Svelte to optimise.

$$restProps contains only the props which are not declared with export. It can be used to pass down other unknown attributes to an element in a component. It shares the same optimisation problems as $$props, and is likewise not recommended.

What exactly does that mean?
What are the consequences to expect?
Does the type of usage matter, e.g. $$props.something in JS vs <element {...$$props} />?

For $$restProps, would it be better to collect additional data in a single property when used in a spread?

<element {...$$restProps} />
vs
<script>export let attributes;</script>
<element {...attributes} />

Reproduction

N/A

Logs

No response

System Info

-

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions