mirror of https://github.com/sveltejs/svelte
fix: error if `each` block has `key` but no `as` clause (#16966)
parent
7d977fad88
commit
9b5fb3f430
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: error if `each` block has `key` but no `as` clause
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
error: {
|
||||||
|
code: 'each_key_without_as',
|
||||||
|
message: 'An `{#each ...}` block without an `as` clause cannot have a key'
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
let items = [{ id: 3 }, { id: 2 }, { id: 1 }];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each items, i (items[i].id)}
|
||||||
|
<p>{items[i].id}</p>
|
||||||
|
{/each}
|
||||||
Loading…
Reference in new issue