Skip to content

TS: Type cast inside reactive assignment not working #1046

@dummdidumm

Description

@dummdidumm

Describe the bug
When using a type cast (as X) inside a reactive assignment, the code is transformed wrongly and weird errors occur

To Reproduce

<script lang="ts">
	type Team = any;
	$: team = { search: "Real", players: [] } as Team;
</script>

Expected behavior
This should be possible

System (please complete the following information):
language-server 0.14.1

Additional context
Possible fix: Add parantheses around it after transformation. This works:

<script lang="ts">
	type Team = any;
	$: team = ({ search: "Real", players: [] } as Team);
</script>

But the parantheses are removed by prettier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedFixed in master branch. Pending production release.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions