Skip to content

Commit 44231fd

Browse files
committed
fix: ignore generic type arguments while creating AST
bumps esrap and fixes a resulting error: because esrap now uses a more compliant TSESTree AST, it has `typeArguments` instead of `typeParameters` in some places - those were not deleted while stripping types, which caused an error.
1 parent 3682371 commit 44231fd

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

Diff for: .changeset/happy-snakes-pump.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ignore generic type arguments while creating AST

Diff for: packages/svelte/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
"axobject-query": "^4.1.0",
157157
"clsx": "^2.1.1",
158158
"esm-env": "^1.2.1",
159-
"esrap": "^1.4.3",
159+
"esrap": "^1.4.6",
160160
"is-reference": "^3.0.3",
161161
"locate-character": "^3.0.0",
162162
"magic-string": "^0.30.11",

Diff for: packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const visitors = {
2424
// until that day comes, we just delete them so they don't confuse esrap
2525
delete n.typeAnnotation;
2626
delete n.typeParameters;
27+
delete n.typeArguments;
2728
delete n.returnType;
2829
delete n.accessibility;
2930
},

Diff for: packages/svelte/tests/runtime-runes/samples/typescript/main.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
console.log(this);
99
}
1010
11-
function foo(): string {
11+
function foo<T>(): string {
1212
return ""!;
1313
}
1414
@@ -46,6 +46,7 @@
4646
4747
const TypedFoo = Foo<true>;
4848
const typeAssertion = <boolean>true;
49+
const x = foo<true>();
4950
</script>
5051

5152
<script>

Diff for: pnpm-lock.yaml

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)