Skip to content
Discussion options

You must be logged in to vote

If you declare types, you also have to declare children. Not every component accepts this property, so it has to be added manually for those that do.

import type { Snippet } from 'svelte';

interface Props {
    children: Snippet;
    // ...
}
let { children, /*...*/ }: Props = $props();

(If you are wrapping an element, you can make the props extend an interface from 'svelte/elements', those already include the children property.)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Keshav-writes-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants