diff --git a/src/generators/nodes/EachBlock.ts b/src/generators/nodes/EachBlock.ts index f4d90a8cfc..3e596a4db0 100644 --- a/src/generators/nodes/EachBlock.ts +++ b/src/generators/nodes/EachBlock.ts @@ -36,6 +36,12 @@ export default class EachBlock extends Node { // TODO handle indexes and destructuring this.scope.add(this.context, this.expression.dependencies); + if (this.index) { + // index can only change if this is a keyed each block + const dependencies = this.key ? this.expression.dependencies : []; + this.scope.add(this.index, dependencies); + } + // TODO more general approach to destructuring this.destructuredContexts = info.destructuredContexts || []; this.destructuredContexts.forEach(name => {