fix: prune typescript class field declarations (#16154)

* fix: prune typescript class field declarations

* add test
pull/16147/head
ComputerGuy 3 months ago committed by GitHub
parent 6a7df1cce8
commit 36315fece4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: prune typescript class field declarations

@ -115,6 +115,19 @@ const visitors = {
TSDeclareFunction() {
return b.empty;
},
ClassBody(node, context) {
const body = [];
for (const _child of node.body) {
const child = context.visit(_child);
if (child.type !== 'PropertyDefinition' || !child.declare) {
body.push(child);
}
}
return {
...node,
body
};
},
ClassDeclaration(node, context) {
if (node.declare) {
return b.empty;

@ -14,6 +14,7 @@
class Foo<T> {
public name: string;
declare bar: string;
x = 'x' as const;
constructor(name: string) {
this.name = name;

Loading…
Cancel
Save