diff --git a/.changeset/polite-tips-enjoy.md b/.changeset/polite-tips-enjoy.md
new file mode 100644
index 000000000000..ab95388f7fd9
--- /dev/null
+++ b/.changeset/polite-tips-enjoy.md
@@ -0,0 +1,5 @@
+---
+'svelte': patch
+---
+
+fix: add `typeParams` to `SnippetBlock` for legacy parser
diff --git a/packages/svelte/src/compiler/legacy.js b/packages/svelte/src/compiler/legacy.js
index e3f88c8f1d23..f6b7e4b0548d 100644
--- a/packages/svelte/src/compiler/legacy.js
+++ b/packages/svelte/src/compiler/legacy.js
@@ -378,7 +378,8 @@ export function convert(source, ast) {
end: node.end,
expression: node.expression,
parameters: node.parameters,
- children: node.body.nodes.map((child) => visit(child))
+ children: node.body.nodes.map((child) => visit(child)),
+ typeParams: node.typeParams
};
},
// @ts-expect-error
diff --git a/packages/svelte/tests/parser-legacy/samples/generic-snippets/input.svelte b/packages/svelte/tests/parser-legacy/samples/generic-snippets/input.svelte
new file mode 100644
index 000000000000..4ee619728d17
--- /dev/null
+++ b/packages/svelte/tests/parser-legacy/samples/generic-snippets/input.svelte
@@ -0,0 +1,10 @@
+
+
+{#snippet generic(val: T)}
+ {val}
+{/snippet}
+
+{#snippet complex_generic">>(val: T)}
+ {val}
+{/snippet}
\ No newline at end of file
diff --git a/packages/svelte/tests/parser-legacy/samples/generic-snippets/output.json b/packages/svelte/tests/parser-legacy/samples/generic-snippets/output.json
new file mode 100644
index 000000000000..37fb499e7b0f
--- /dev/null
+++ b/packages/svelte/tests/parser-legacy/samples/generic-snippets/output.json
@@ -0,0 +1,244 @@
+{
+ "html": {
+ "type": "Fragment",
+ "start": 30,
+ "end": 192,
+ "children": [
+ {
+ "type": "Text",
+ "start": 28,
+ "end": 30,
+ "raw": "\n\n",
+ "data": "\n\n"
+ },
+ {
+ "type": "SnippetBlock",
+ "start": 30,
+ "end": 92,
+ "expression": {
+ "type": "Identifier",
+ "start": 40,
+ "end": 47,
+ "name": "generic"
+ },
+ "parameters": [
+ {
+ "type": "Identifier",
+ "start": 66,
+ "end": 72,
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 36
+ },
+ "end": {
+ "line": 4,
+ "column": 42
+ }
+ },
+ "name": "val",
+ "typeAnnotation": {
+ "type": "TSTypeAnnotation",
+ "start": 69,
+ "end": 72,
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 39
+ },
+ "end": {
+ "line": 4,
+ "column": 42
+ }
+ },
+ "typeAnnotation": {
+ "type": "TSTypeReference",
+ "start": 71,
+ "end": 72,
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 41
+ },
+ "end": {
+ "line": 4,
+ "column": 42
+ }
+ },
+ "typeName": {
+ "type": "Identifier",
+ "start": 71,
+ "end": 72,
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 41
+ },
+ "end": {
+ "line": 4,
+ "column": 42
+ }
+ },
+ "name": "T"
+ }
+ }
+ }
+ }
+ ],
+ "children": [
+ {
+ "type": "MustacheTag",
+ "start": 76,
+ "end": 81,
+ "expression": {
+ "type": "Identifier",
+ "start": 77,
+ "end": 80,
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 2
+ },
+ "end": {
+ "line": 5,
+ "column": 5
+ }
+ },
+ "name": "val"
+ }
+ }
+ ],
+ "typeParams": "T extends string"
+ },
+ {
+ "type": "Text",
+ "start": 92,
+ "end": 94,
+ "raw": "\n\n",
+ "data": "\n\n"
+ },
+ {
+ "type": "SnippetBlock",
+ "start": 94,
+ "end": 192,
+ "expression": {
+ "type": "Identifier",
+ "start": 104,
+ "end": 119,
+ "name": "complex_generic"
+ },
+ "parameters": [
+ {
+ "type": "Identifier",
+ "start": 166,
+ "end": 172,
+ "loc": {
+ "start": {
+ "line": 8,
+ "column": 72
+ },
+ "end": {
+ "line": 8,
+ "column": 78
+ }
+ },
+ "name": "val",
+ "typeAnnotation": {
+ "type": "TSTypeAnnotation",
+ "start": 169,
+ "end": 172,
+ "loc": {
+ "start": {
+ "line": 8,
+ "column": 75
+ },
+ "end": {
+ "line": 8,
+ "column": 78
+ }
+ },
+ "typeAnnotation": {
+ "type": "TSTypeReference",
+ "start": 171,
+ "end": 172,
+ "loc": {
+ "start": {
+ "line": 8,
+ "column": 77
+ },
+ "end": {
+ "line": 8,
+ "column": 78
+ }
+ },
+ "typeName": {
+ "type": "Identifier",
+ "start": 171,
+ "end": 172,
+ "loc": {
+ "start": {
+ "line": 8,
+ "column": 77
+ },
+ "end": {
+ "line": 8,
+ "column": 78
+ }
+ },
+ "name": "T"
+ }
+ }
+ }
+ }
+ ],
+ "children": [
+ {
+ "type": "MustacheTag",
+ "start": 176,
+ "end": 181,
+ "expression": {
+ "type": "Identifier",
+ "start": 177,
+ "end": 180,
+ "loc": {
+ "start": {
+ "line": 9,
+ "column": 2
+ },
+ "end": {
+ "line": 9,
+ "column": 5
+ }
+ },
+ "name": "val"
+ }
+ }
+ ],
+ "typeParams": "T extends { bracket: \"<\" } | \"<\" | Set<\"<>\">"
+ }
+ ]
+ },
+ "instance": {
+ "type": "Script",
+ "start": 0,
+ "end": 28,
+ "context": "default",
+ "content": {
+ "type": "Program",
+ "start": 18,
+ "end": 19,
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 0
+ }
+ },
+ "body": [],
+ "sourceType": "module"
+ }
+ }
+}