diff --git a/.changeset/wild-islands-help.md b/.changeset/wild-islands-help.md new file mode 100644 index 000000000000..5386e5d6b189 --- /dev/null +++ b/.changeset/wild-islands-help.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ignore TypeScript generics on variables diff --git a/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js b/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js index 8db29ab06746..b968e95213a2 100644 --- a/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js +++ b/packages/svelte/src/compiler/phases/1-parse/remove_typescript_nodes.js @@ -104,6 +104,9 @@ const visitors = { } return context.visit(node.parameter); }, + TSInstantiationExpression(node, context) { + return context.visit(node.expression); + }, FunctionExpression: remove_this_param, FunctionDeclaration: remove_this_param, TSDeclareFunction() { diff --git a/packages/svelte/tests/runtime-runes/samples/typescript/main.svelte b/packages/svelte/tests/runtime-runes/samples/typescript/main.svelte index 8a3db5dead23..3b98dafa0597 100644 --- a/packages/svelte/tests/runtime-runes/samples/typescript/main.svelte +++ b/packages/svelte/tests/runtime-runes/samples/typescript/main.svelte @@ -8,7 +8,7 @@ console.log(this); } - class Foo { + class Foo { public name: string; x = 'x' as const; constructor(name: string) { @@ -32,6 +32,8 @@ export function overload(c: any): any {} export type { Hello }; + + const TypedFoo = Foo;