Skip to content

Commit 83a3151

Browse files
committed
fix: ignore typescript abstract methods during code transformation
1 parent 02788f8 commit 83a3151

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

.changeset/tasty-pumas-train.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 abstract methods during code transformation

packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @import { ClassBody, Expression, Identifier, Literal, MethodDefinition, PrivateIdentifier, PropertyDefinition } from 'estree' */
1+
/** @import { ClassBody, Expression, Identifier, Literal, MethodDefinition, PrivateIdentifier, PropertyDefinition, StaticBlock } from 'estree' */
22
/** @import { } from '#compiler' */
33
/** @import { Context, StateField } from '../types' */
44
import { dev, is_ignored } from '../../../../state.js';
@@ -13,8 +13,17 @@ import { build_proxy_reassignment, should_proxy } from '../utils.js';
1313
*/
1414
export function ClassBody(node, context) {
1515
if (!context.state.analysis.runes) {
16-
context.next();
17-
return;
16+
/** @type {Array<MethodDefinition | PropertyDefinition | StaticBlock>} */
17+
const body = [];
18+
19+
for (const definition of node.body) {
20+
if (definition.type == 'MethodDefinition' && definition.abstract) {
21+
continue;
22+
}
23+
body.push(definition);
24+
}
25+
26+
return { ...node, body };
1827
}
1928

2029
/** @type {Map<string, StateField>} */
@@ -30,6 +39,10 @@ export function ClassBody(node, context) {
3039
const private_ids = [];
3140

3241
for (const definition of node.body) {
42+
if (definition.type == 'MethodDefinition' && definition.abstract) {
43+
continue;
44+
}
45+
3346
if (
3447
(definition.type === 'PropertyDefinition' || definition.type === 'MethodDefinition') &&
3548
(definition.key.type === 'Identifier' ||
@@ -96,6 +109,10 @@ export function ClassBody(node, context) {
96109

97110
// Replace parts of the class body
98111
for (const definition of node.body) {
112+
if (definition.type == 'MethodDefinition' && definition.abstract) {
113+
continue;
114+
}
115+
99116
if (
100117
definition.type === 'PropertyDefinition' &&
101118
(definition.key.type === 'Identifier' ||

0 commit comments

Comments
 (0)