Skip to content

Commit

Permalink
fix: ignore typescript abstract methods during code transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
caiquetorres committed Feb 11, 2025
1 parent 02788f8 commit 83a3151
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-pumas-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ignore typescript abstract methods during code transformation
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @import { ClassBody, Expression, Identifier, Literal, MethodDefinition, PrivateIdentifier, PropertyDefinition } from 'estree' */
/** @import { ClassBody, Expression, Identifier, Literal, MethodDefinition, PrivateIdentifier, PropertyDefinition, StaticBlock } from 'estree' */
/** @import { } from '#compiler' */
/** @import { Context, StateField } from '../types' */
import { dev, is_ignored } from '../../../../state.js';
Expand All @@ -13,8 +13,17 @@ import { build_proxy_reassignment, should_proxy } from '../utils.js';
*/
export function ClassBody(node, context) {
if (!context.state.analysis.runes) {
context.next();
return;
/** @type {Array<MethodDefinition | PropertyDefinition | StaticBlock>} */
const body = [];

for (const definition of node.body) {
if (definition.type == 'MethodDefinition' && definition.abstract) {
continue;
}
body.push(definition);
}

return { ...node, body };
}

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

for (const definition of node.body) {
if (definition.type == 'MethodDefinition' && definition.abstract) {
continue;
}

if (
(definition.type === 'PropertyDefinition' || definition.type === 'MethodDefinition') &&
(definition.key.type === 'Identifier' ||
Expand Down Expand Up @@ -96,6 +109,10 @@ export function ClassBody(node, context) {

// Replace parts of the class body
for (const definition of node.body) {
if (definition.type == 'MethodDefinition' && definition.abstract) {
continue;
}

if (
definition.type === 'PropertyDefinition' &&
(definition.key.type === 'Identifier' ||
Expand Down

0 comments on commit 83a3151

Please sign in to comment.