Skip to content

Commit

Permalink
fix for @const node
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Feb 24, 2024
1 parent 458cb37 commit 7b8f3a4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/context/script-let.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,11 @@ export class ScriptLetContext {
parent: SvelteNode,
...callbacks: ScriptLetCallback<ESTree.VariableDeclarator>[]
): ScriptLetCallback<ESTree.VariableDeclarator>[] {
const range = getNodeRange(declarator);
const range =
declarator.type === "VariableDeclarator"
? // As of Svelte v5-next.65, VariableDeclarator nodes do not have location information.
[getNodeRange(declarator.id)[0], getNodeRange(declarator.init!)[1]]
: getNodeRange(declarator);
const part = this.ctx.code.slice(...range);
this.appendScript(
`const ${part};`,
Expand Down

0 comments on commit 7b8f3a4

Please sign in to comment.