From bca4c39f5efac180648b5c010c67ba6c9a06874f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 19 Oct 2025 09:40:24 -0400 Subject: [PATCH] fix: improve `each_key_without_as` error --- .changeset/three-wasps-work.md | 5 +++++ .../src/compiler/phases/2-analyze/visitors/EachBlock.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/three-wasps-work.md diff --git a/.changeset/three-wasps-work.md b/.changeset/three-wasps-work.md new file mode 100644 index 0000000000..318d8668a4 --- /dev/null +++ b/.changeset/three-wasps-work.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: improve `each_key_without_as` error diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/EachBlock.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/EachBlock.js index d3eb58053e..81a9c1e2d1 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/EachBlock.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/EachBlock.js @@ -1,3 +1,4 @@ +/** @import { Expression } from 'estree' */ /** @import { AST, Binding } from '#compiler' */ /** @import { Context } from '../types' */ /** @import { Scope } from '../../scope' */ @@ -29,7 +30,7 @@ export function EachBlock(node, context) { } if (node.metadata.keyed && !node.context) { - e.each_key_without_as(node); + e.each_key_without_as(/** @type {Expression} */ (node.key)); } // evaluate expression in parent scope