mirror of https://github.com/sveltejs/svelte
feat: simplify derived object destructuring (#12781)
* simplify derived object destructuring * add test for destructuring an array * add changeset * shorter temp variable name * skip intermediate derived for simple cases --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/12786/head
parent
d6e26c0953
commit
7de3e3b703
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
feat: simplify derived object destructuring
|
@ -1,5 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `true 1 2 baz`
|
||||
html: `true 1 2 baz 1 2 3`
|
||||
});
|
||||
|
@ -1,6 +1,9 @@
|
||||
<script>
|
||||
let stuff = $state({ foo: true, bar: [1, 2, {baz: 'baz'}] });
|
||||
let { foo, bar: [a, b, { baz }]} = $derived(stuff);
|
||||
|
||||
let stuff2 = $state([1, 2, 3]);
|
||||
let [d, e, f] = $derived(stuff2);
|
||||
</script>
|
||||
|
||||
{foo} {a} {b} {baz}
|
||||
{foo} {a} {b} {baz} {d} {e} {f}
|
Loading…
Reference in new issue