sveltejs / prettier-plugin-svelte

Format your svelte components using prettier.
MIT License
714 stars 95 forks source link

Prettier Plugin Svelte does not format typescript code inside on* handlers #447

Closed lts20050703 closed 1 week ago

lts20050703 commented 1 week ago

It looks like Prettier does not format typescript code inside on* handlers

For example, prettier will successfully format the code below

<button onclick={() => {
  let i = 0
}}>

But it does not format the code below

<button onclick={() => {
  let i: number
}}>

Workaround: Move the code to a function in the <script> tag, then assign that function to the on* handler.