Skip to content

Commit 7b8f3a4

Browse files
committed
fix for @const node
1 parent 458cb37 commit 7b8f3a4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/context/script-let.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ export class ScriptLetContext {
247247
parent: SvelteNode,
248248
...callbacks: ScriptLetCallback<ESTree.VariableDeclarator>[]
249249
): ScriptLetCallback<ESTree.VariableDeclarator>[] {
250-
const range = getNodeRange(declarator);
250+
const range =
251+
declarator.type === "VariableDeclarator"
252+
? // As of Svelte v5-next.65, VariableDeclarator nodes do not have location information.
253+
[getNodeRange(declarator.id)[0], getNodeRange(declarator.init!)[1]]
254+
: getNodeRange(declarator);
251255
const part = this.ctx.code.slice(...range);
252256
this.appendScript(
253257
`const ${part};`,

0 commit comments

Comments
 (0)