Merge pull request #3336 from Conduitry/gh-3274

don't warn when using each index in key
pull/3330/head^2
Rich Harris 5 years ago committed by GitHub
commit cf24dbd6a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -83,16 +83,16 @@ export default class EachBlock extends AbstractBlock {
this.scope.add(context.key.name, this.expression.dependencies, this);
});
this.key = info.key
? new Expression(component, this, this.scope, info.key)
: null;
if (this.index) {
// index can only change if this is a keyed each block
const dependencies = this.key ? this.expression.dependencies : new Set([]);
const dependencies = info.key ? this.expression.dependencies : new Set([]);
this.scope.add(this.index, dependencies, this);
}
this.key = info.key
? new Expression(component, this, this.scope, info.key)
: null;
this.has_animation = false;
this.children = map_children(component, this, this.scope, info.children);

@ -1,6 +1,6 @@
<script>
// script block prevents auto-declaration
</script>
<p>{potato}</p>
<p>{Math.max(1, 2)}</p>
<p>{Math.max(1, 2)}</p>
{#each window.something as foo, i (foo.x + i)}
hello
{/each}

@ -1,15 +1,15 @@
[{
"code": "missing-declaration",
"message": "'potato' is not defined",
"pos": 67,
"message": "'potato' is not defined. Consider adding a <script> block with 'export let potato' to declare a prop",
"pos": 4,
"start": {
"line": 5,
"line": 1,
"column": 4,
"character": 67
"character": 4
},
"end": {
"line": 5,
"line": 1,
"column": 10,
"character": 73
"character": 10
}
}]
Loading…
Cancel
Save