You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wonder if Svelte can do much here, these types don't really work.
If you union string with 'string literal' the result is always string.
The if type narrowing in the script block only works due to flow analysis, i.e. there is no code changing the variable before the if, hence the type at that point is inferred to be that of the data provided in the declaration, rather than ServiceData whose type prop is useless.
As pointed out, the union type needs something to clearly discriminate against, and string widens the type such that it no longer works. Closing as there's nothing Svelte can do
Describe the bug
Discriminating union does not work in template
Reproduction
Context on the type
The issue
Can the svelte team fix this, and is there a work around?
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: