Sitelet https://github.com/sveltejs/prettier-plugin-svelte/pull/537
Skip to content

fix: preserve nested rest patterns in {#each} destructuring context - #537

Merged
dummdidumm merged 2 commits into
sveltejs:mainfrom
baseballyama:fix/each-nested-rest-destructuring
Jun 15, 2026
Merged

dummdidumm merged 2 commits into
sveltejs:mainfrom
baseballyama:fix/each-nested-rest-destructuring

Conversation

@baseballyama

Copy link
Copy Markdown
Member

{#each items as [a, b, ...[c, d]]} and {#each items as [a, ...{ length }]} were printed as ...undefined, silently dropping the nested bindings.

expandNode's RestElement case read node.argument.name, which is undefined when the rest argument is itself an ArrayPattern / ObjectPattern rather than a plain Identifier. Recurse into the argument instead so nested destructuring rest patterns round-trip.

`{#each items as [a, b, ...[c, d]]}` and `{#each items as [a, ...{ length }]}`
were printed as `...undefined`, silently dropping the nested bindings.

`expandNode`'s `RestElement` case read `node.argument.name`, which is `undefined`
when the rest argument is itself an `ArrayPattern` / `ObjectPattern` rather than a
plain `Identifier`. Recurse into the argument instead so nested destructuring
rest patterns round-trip.
@dummdidumm
dummdidumm merged commit 1d8b086 into sveltejs:main Jun 15, 2026
4 of 5 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 15, 2026
@baseballyama
baseballyama deleted the fix/each-nested-rest-destructuring branch June 15, 2026 16:12
Migan178 pushed a commit to Migan178/miganart that referenced this pull request Jul 28, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte) | devDependencies | major | [`^3.5.0` → `^4.0.0`](https://renovatebot.com/diffs/npm/prettier-plugin-svelte/3.5.2/4.1.1) |

---

### Release Notes

<details>
<summary>sveltejs/prettier-plugin-svelte (prettier-plugin-svelte)</summary>

### [`v4.1.1`](https://github.com/sveltejs/prettier-plugin-svelte/blob/HEAD/CHANGELOG.md#411)

[Compare Source](https://github.com/sveltejs/prettier-plugin-svelte/compare/prettier-plugin-svelte@4.1.0...prettier-plugin-svelte@4.1.1)

##### Patch Changes

- fix: preserve nested rest patterns in `{#each}` destructuring ([#&#8203;537](sveltejs/prettier-plugin-svelte#537))

- fix: preserve whitespace inside `<textarea>` (its content is whitespace-sensitive, like `<pre>`) ([#&#8203;540](sveltejs/prettier-plugin-svelte#540))

- fix: don't drop `<script>`/`<style>` content when the closing tag has whitespace (`</script >`) ([#&#8203;539](sveltejs/prettier-plugin-svelte#539))

### [`v4.1.0`](https://github.com/sveltejs/prettier-plugin-svelte/blob/HEAD/CHANGELOG.md#410)

[Compare Source](https://github.com/sveltejs/prettier-plugin-svelte/compare/prettier-plugin-svelte@4.0.1...prettier-plugin-svelte@4.1.0)

##### Minor Changes

- feat: support Svelte 5 declaration tags ([#&#8203;533](sveltejs/prettier-plugin-svelte#533))

### [`v4.0.1`](https://github.com/sveltejs/prettier-plugin-svelte/blob/HEAD/CHANGELOG.md#401)

[Compare Source](https://github.com/sveltejs/prettier-plugin-svelte/compare/prettier-plugin-svelte@4.0.0...prettier-plugin-svelte@4.0.1)

##### Patch Changes

- fix: print `@const` correctly ([#&#8203;530](sveltejs/prettier-plugin-svelte#530))

### [`v4.0.0`](https://github.com/sveltejs/prettier-plugin-svelte/blob/HEAD/CHANGELOG.md#400)

[Compare Source](https://github.com/sveltejs/prettier-plugin-svelte/compare/v3.5.2...prettier-plugin-svelte@4.0.0)

- (breaking) Require Svelte 5
- (breaking) Remove `svelteBracketNewLine` option
- (breaking) Remove `svelteStrictMode` option
- (fix) Keep trailing `<!-- #endregion -->` comments below `svelte:options` / scripts / styles

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yODEuMCIsInVwZGF0ZWRJblZlciI6IjQzLjI4MS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.miganbox.com/migan/miganart/pulls/7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants