From 4a1ef31cf9850212ee6177dbf7b8f188181f9f75 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 17 Dec 2024 22:13:50 -0500 Subject: [PATCH] fix: remove unwanted properties from both replaced and unreplaced nodes --- .changeset/famous-mugs-rhyme.md | 5 +++++ .../compiler/phases/1-parse/remove_typescript_nodes.js | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .changeset/famous-mugs-rhyme.md 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)');