sveltejs / svelte

web development for the rest of us
https://svelte.dev
MIT License
79.7k stars 4.23k forks source link

Snippets that use a `() => void` type break eslint when using typescript #13320

Open AlbertMarashi opened 1 month ago

AlbertMarashi commented 1 month ago

Describe the bug

There's a weird eslint bug with parsing snippets that contain () => void, even if it is commented out.

Reproduction

<script lang="ts">

</script>

{#snippet editor_button(foo: {
    // onclick: () => void,
})}

{/snippet}

Parsing error: '}' expected.eslint


<script lang="ts">

</script>

{#snippet editor_button(foo: {
    onclick: () => void,
})}

{/snippet}

Parsing error: '=>' expected.eslint

Logs

No response

System Info

System:
    OS: macOS 14.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 108.48 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
    pnpm: 9.7.0 - ~/Library/pnpm/pnpm
    bun: 1.1.18 - ~/.bun/bin/bun
  Browsers:
    Chrome: 128.0.6613.138
    Safari: 17.2
  npmPackages:
    svelte: 5.0.0-next.244 => 5.0.0-next.244

Severity

blocking upgrade

paoloricciuti commented 1 month ago

This feels like a https://github.com/sveltejs/eslint-plugin-svelte issue or a https://github.com/sveltejs/svelte-eslint-parser issue considering that svelte parse this correctly (i can't move it there unfortunately)