Skip to content

Commit f2690bd

Browse files
committed
fix: strip exported TypeScript function overloads
fixes #14455
1 parent 19d80ad commit f2690bd

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

.changeset/shy-starfishes-type.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: strip exported TypeScript function overloads

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ const visitors = {
3636
if (node.exportKind === 'type') return b.empty;
3737

3838
if (node.declaration) {
39-
return context.next();
39+
const result = context.next();
40+
if (result?.declaration?.type === 'EmptyStatement') {
41+
return b.empty;
42+
}
43+
return result;
4044
}
4145

4246
if (node.specifiers) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
export type Foo = true
2828
}
2929
30+
export function overload(a: boolean): boolean;
31+
export function overload(b: string): number;
32+
export function overload(c: any): any {}
33+
3034
export type { Hello };
3135
</script>
3236

0 commit comments

Comments
 (0)