5.33.2, SvelteHTMLElements
and generics issues
#16046
Labels
Milestone
SvelteHTMLElements
and generics issues
#16046
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
After upgrading from 5.33.1 to 5.33.2, a bunch of errors started appearing in my CI (
sv check
). I believe the errors are caused by #15972, and they mostly affect<svelte:element>
and generic components.For example:
This used to work, but now has a type error:
Or another example:
fails with
which is odd, to say the least. No matter whether the condition is true or false, the type should be
any
, thus bypassing all type checks, yet there is an error - it seems the conditionTag extends string
is neither true nor false (Schrodinger style), and TypeScript gets confused. It's worth noting thatkeyof SvelteHTMLElements
does, in fact, extend string, so I'm unsure why TypeScript thinks thatTag
, which extendskeyof SvelteHTMLElements
, doesn't. I think someone with better TypeScript knowledge can help here, as I have no clue what's going on.Finally, I think the main issue here is that, because of this, polymorphic components are broken, for example:
now has two errors:
I consider myself decent with TypeScript, but after a couple of hours of trying things out I concluded that it's pretty much impossible to code anything that works with
keyof SvelteHTMLElements
. The workaround is to useTag extends string
, it seems to work correctly as before.Severity
annoyance
The text was updated successfully, but these errors were encountered: