Consider removing the Omit type from the HTMLProps type

#2225

Issue

Open
D
dummdidumm
Dec 7, 2023, 2:32 PM

This type in our d.ts file in svelte2tsx:

type HTMLProps<Property extends string, Override> =
    Omit<import('svelte/elements').SvelteHTMLElements[Property], keyof Override> & Override;

Results in the data-${string} type overriding any more narrow types like data-sveltekit-... In other words, I can pass an invalid value to data-sveltekit-.. and it doesn't error, because the fallback type overrides it so that anything is allowed.

The question now is: Should we simplify the HTMLProps type to import('svelte/elements').SvelteHTMLElements[Property] & Override? The one drawback is that you cannot pass properties that have conflicting types anymore. Given that you rarely want to override a type (you mainly want to add new ones), and in case you do want to override them, you mostly want to narrow them (which is fine with the simplified type, too), I lean towards making this change. @jasonlyu123 thoughts?

Info

Assignees None
Labels breaking change
Milestone None