-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Open
Labels
Description
Describe the bug
There's a type mismatch between the <div> element type and HTMLAttributes<HTMLDivElement>
Reproduction
Type this into a Svelte file in VS Code. Notice the error on the spread of restProps on the <div>.
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
const { children, ...restProps }: HTMLAttributes<HTMLDivElement> = $props();
</script>
<div {...restProps}>
{@render children?.()}
</div>I've encountered a few issues related to spreading of props. Most are fairly simple to work around by just Omit<>ing the offending attribute and typing it correctly. As a catch all, it might be a good idea to create a TypeScript test for all of the elements in import('svelte/element').SvelteHTMLElements.
Logs
Types of property 'hidden' are incompatible.
Type 'boolean | "" | "until-found" | null | undefined' is not assignable to type 'boolean | null | undefined'.
Type '""' is not assignable to type 'boolean | null | undefined'.ts(2345)System Info
Svelte: ^5.1.3 => 5.1.3Severity
annoyance
mantissa7 and theetrain