Closed as not planned
Description
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 the data
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
Metadata
Metadata
Assignees
Labels
No labels