Skip to content

Commit cb8093e

Browse files
committed
fix for @const node
1 parent 2621ab9 commit cb8093e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/context/script-let.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,11 @@ export class ScriptLetContext {
250250
parent: SvelteNode,
251251
...callbacks: ScriptLetCallback<ESTree.VariableDeclarator>[]
252252
): ScriptLetCallback<ESTree.VariableDeclarator>[] {
253-
const range = getNodeRange(declarator);
253+
const range =
254+
declarator.type === "VariableDeclarator"
255+
? // As of Svelte v5-next.65, VariableDeclarator nodes do not have location information.
256+
[getNodeRange(declarator.id)[0], getNodeRange(declarator.init!)[1]]
257+
: getNodeRange(declarator);
254258
const part = this.ctx.code.slice(...range);
255259
this.appendScript(
256260
`const ${part};`,

0 commit comments

Comments
 (0)