Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier adding surrounding parentheses on new function bindings #477

Open
pierregoutheraud opened this issue Dec 20, 2024 · 3 comments
Open

Comments

@pierregoutheraud
Copy link

pierregoutheraud commented Dec 20, 2024

With newer version of svelte 5, function bindings allows you to do this:

<input bind:value={get, set} />

Prettier is automatically adding parentheses:

<input bind:value={(get, set)} />

which throws a svelte error:

`bind:value={get, set}` must not have surrounding parentheses
https://svelte.dev/e/bind_invalid_parens [bind_invalid_parens]

I am using:

"prettier": "3.4.2",
"prettier-plugin-svelte": "3.3.2",
"svelte": "5.15.0"
{
  "singleQuote": false,
  "trailingComma": "none",
  "printWidth": 80,
  "plugins": ["prettier-plugin-svelte"],
  "overrides": [
    {
      "files": "*.svelte",
      "options": {
        "parser": "svelte"
      }
    }
  ]
}
@rodshtein
Copy link

rodshtein commented Dec 24, 2024

Temporally workaround:

{/* @ts-ignore */ null}
<!-- FIXME remove after resolve issue prettier-plugin-svelte#477 -->
<!-- prettier-ignore -->
<input
  bind:value={() => void, null}
/>

ts-ignore for second nullish set arg

@dummdidumm
Copy link
Member

Please provide a repository reproduction, this should work (not able to reproduce)

@rodshtein
Copy link

After updating dependencies and restarting vscode everything is ok.
It can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants