-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Description
Prettier 3.4.2
prettier-plugin-svelte 3.3.3
Input:
<script lang="ts">
const modes = { a: "mode 1", b: "mode 2", c: "mode 3" } as const;
type Mode = keyof typeof modes;
let currentMode: Mode = $state("a");
</script>
{#each (Object.entries(modes) as [Mode, string][]) as [id, name]}
<button onclick={() => (currentMode = id)}>{name}</button>
{/each}
Output:
<script lang="ts">
const modes = { a: "mode 1", b: "mode 2", c: "mode 3" } as const;
type Mode = keyof typeof modes;
let currentMode: Mode = $state("a");
</script>
{#each Object.entries(modes) as [Mode, string][] as [id, name]}
<button onclick={() => (currentMode = id)}>{name}</button>
{/each}
Expected output: (same as input)
Why?
Formatter is removing parentheses from the each block types, which leads to a syntax error when the code is formatted.
Metadata
Metadata
Assignees
Labels
No labels