From c1bb2397dd9796d690d9259f4759e6b1e4e0b517 Mon Sep 17 00:00:00 2001 From: "S. Elliott Johnson" Date: Sun, 24 Dec 2023 01:53:00 -0500 Subject: [PATCH] fix: snapshot --- .../3-transform/client/visitors/template.js | 3 +- .../samples/snippets/output.json | 53 +++++++++++++++---- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js index 06f7beb35c..505ef37544 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/template.js @@ -1757,7 +1757,8 @@ export const template_visitors = { const args = [context.state.node]; node.arguments.forEach((arg) => { if (arg.type === 'SpreadElement') { - // this is a spread operation, meaning we need to thunkify all of its members + // this is a spread operation, meaning we need to thunkify all of its members, which we can't + // do until runtime args.push( /** @type {import('estree').Expression} */ ( context.visit(b.spread(b.call('$.shallow_thunk', arg.argument))) diff --git a/packages/svelte/tests/parser-modern/samples/snippets/output.json b/packages/svelte/tests/parser-modern/samples/snippets/output.json index c43a6e4223..2bf5cff6ca 100644 --- a/packages/svelte/tests/parser-modern/samples/snippets/output.json +++ b/packages/svelte/tests/parser-modern/samples/snippets/output.json @@ -22,6 +22,16 @@ "type": "Identifier", "start": 39, "end": 42, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 13 + } + }, "name": "foo" }, "context": { @@ -29,21 +39,46 @@ "elements": [ { "type": "Identifier", - "name": "msg", "start": 43, - "end": 54, + "end": 25, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 25 + } + }, + "name": "msg", "typeAnnotation": { - "type": "TSStringKeyword", - "start": 48, + "type": "TSTypeAnnotation", + "start": 46, "end": 54, "loc": { "start": { - "line": 1, - "column": 48 + "line": 3, + "column": 17 }, "end": { - "line": 1, - "column": 54 + "line": 3, + "column": 25 + } + }, + "typeAnnotation": { + "type": "TSStringKeyword", + "start": 48, + "end": 54, + "loc": { + "start": { + "line": 3, + "column": 19 + }, + "end": { + "line": 3, + "column": 25 + } } } } @@ -178,4 +213,4 @@ "sourceType": "module" } } -} +} \ No newline at end of file