Consider removing the Omit
type from the HTMLProps
type
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 any
thing 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?
Another possibility is that some event type was changed to a new sub-type, and people want to enhance it. Like the submit event situation in #1305. There is also another problem. We have the same HTMLProps
in the Svelte 4 version of svelteHTML
, so it might be considered a breaking change.
Another possibility is that some event type was changed to a new sub-type, and people want to enhance it
Do you mean this as in "this is another use case where people want the current behavior, and it would no longer possible if we changed the type"?
We have the same HTMLProps in the Svelte 4 version of svelteHTML, so it might be considered a breaking change.
Good point, if we do it then probably as part of Svelte 5 typings