-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Description
Describe the bug
Attempting to follow the docs in how rest props are declared, i.e.:
interface MyProps {
required: string;
optional?: number;
partOfEverythingElse?: boolean;
};
let { required, optional, ...everythingElse }: MyProps = $props();This error is displayed Object literal may only specify known properties, and '"onclick"' does not exist in type '$$ComponentProps'.ts(2353)
Reproduction
This is what I was trying to do:
<!-- Parent.svelte -->
<script lang="ts">
import Button from './Button.svelte';
</script>
<!-- Object literal may only specify known properties, and '"onclick"' does not exist in type '$$ComponentProps'. -->
<Button onclick={() => console.log('This works')}>Children</Button><!-- Button.svelte -->
<script lang="ts">
import type { Snippet } from 'svelte';
let { children, ...restProps }: { children: Snippet } = $props();
</script>
<button {...restProps}>{@render children()}</button>Would be nice to have some clarity on how rest props are to be used if the above example isn't correct.
Logs
No response
System Info
System:
OS: Linux 6.9 Fedora Linux 40 (Workstation Edition)
CPU: (8) x64 Intel(R) Core(TM) i5-1035G7 CPU @ 1.20GHz
Memory: 1.81 GB / 7.35 GB
Container: Yes
Shell: 5.2.26 - /bin/bash
Binaries:
Node: 20.12.2 - /usr/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 10.5.0 - /usr/bin/npm
pnpm: 9.4.0 - /usr/local/bin/pnpm
npmPackages:
svelte: 5.0.0-next.193 => 5.0.0-next.193Severity
annoyance
elron
Metadata
Metadata
Assignees
Labels
No labels