Skip to content

Commit b72fd2b

Browse files
authored
fix: ignore TypeScript generics on variables (#14509)
fixes #14505
1 parent aaea254 commit b72fd2b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.changeset/wild-islands-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ignore TypeScript generics on variables

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ const visitors = {
104104
}
105105
return context.visit(node.parameter);
106106
},
107+
TSInstantiationExpression(node, context) {
108+
return context.visit(node.expression);
109+
},
107110
FunctionExpression: remove_this_param,
108111
FunctionDeclaration: remove_this_param,
109112
TSDeclareFunction() {

packages/svelte/tests/runtime-runes/samples/typescript/main.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
console.log(this);
99
}
1010
11-
class Foo {
11+
class Foo<T> {
1212
public name: string;
1313
x = 'x' as const;
1414
constructor(name: string) {
@@ -32,6 +32,8 @@
3232
export function overload(c: any): any {}
3333
3434
export type { Hello };
35+
36+
const TypedFoo = Foo<true>;
3537
</script>
3638

3739
<script>

0 commit comments

Comments
 (0)