-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Allow type casting in @const declarations #15740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It works, and in VSCode as well. |
I'll close this but feel free to reopen if it's an actual issue. Thanks for reporting! |
Sorry, I wasn't paying attention and missed the notifications. I'm using JetBrains Rider. It's absolutely an issue, though perhaps not in other IDEs. |
JetBrains' Svelte plugin is known to still not have full Svelte 5 support. |
Describe the problem
I'm iterating an array and need to render sub-elements, so would like to have a
{@const x = item.node.data}
to make accessing thedata
part easier. However, I need to cast this to a subtype, and Svelte 5 currently rejects all attempts to do this inline:{@const x: ISub = item.node.data}
{@const x = <ISub>item.node.data}
{@const x = item.node.data as ISub}
I was able to work around the issue by declaring a
cast
function, but that is not a nice experience:function cast(node: INode): ISub { return <ISub>node.data; } {@const x = cast(item.node)}
Describe the proposed solution
Support additional syntax in the @const parser logic to enable inline casting.
Importance
would make my life easier
The text was updated successfully, but these errors were encountered: