-
let {
icon = "line-md:close",
button_style = "",
icon_style = "text-2xl",
children,
...props,
}: {
icon: string;
button_style: string;
icon_style?: string;
children?: Snippet;
...props?: any; // <= what is the correct syntax here to type it?
} = $props(); Thank you for your help! |
Beta Was this translation helpful? Give feedback.
Answered by
brunnerh
May 28, 2024
Replies: 1 comment
-
Depends on how the props are used. import type { HTMLButtonAttributes } from 'svelte/elements';
let {
icon = "line-md:close",
button_style = "",
icon_style = "text-2xl",
children,
...props
}: {
icon: string;
button_style: string;
icon_style?: string;
children?: Snippet;
} & HTMLButtonAttributes = $props(); If you only want to allow events (limited by the prefix let { /*...*/ }: {
icon: string;
button_style: string;
icon_style?: string;
children?: Snippet;
[key: `on${string}`]: Function;
} = $props(); Expand the types to |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
J4gQBqqR
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Depends on how the props are used.
E.g. if they are passed on to an element, you can intersect the declared props with a type from
svelte/elements
.If you only want to allow events (limited by the prefix
on
), you can define an index like this:Expand the types to
[key…