diff --git a/.changeset/famous-mugs-rhyme.md b/.changeset/famous-mugs-rhyme.md new file mode 100644 index 000000000000..433d1024dfda --- /dev/null +++ b/.changeset/famous-mugs-rhyme.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: remove unwanted properties from both replaced and unreplaced nodes 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 5e4fa231dec3..96639829bb60 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 @@ -18,14 +18,14 @@ function remove_this_param(node, context) { /** @type {Visitors} */ const visitors = { _(node, context) { - context.next(); + const n = context.next() ?? node; // TODO there may come a time when we decide to preserve type annotations. // until that day comes, we just delete them so they don't confuse esrap - delete node.typeAnnotation; - delete node.typeParameters; - delete node.returnType; - delete node.accessibility; + delete n.typeAnnotation; + delete n.typeParameters; + delete n.returnType; + delete n.accessibility; }, Decorator(node) { e.typescript_invalid_feature(node, 'decorators (related TSC proposal is not stage 4 yet)');