fix(es/codegen): Emit declare keyword for class properties (#8478)

This commit is contained in:
David Sherret 2024-01-03 00:40:01 -05:00 committed by GitHub
parent faf8cdec19
commit 2076ef8f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 1 deletions

View File

@ -1606,6 +1606,11 @@ where
emit!(dec)
}
if n.declare {
keyword!("declare");
space!();
}
self.emit_accessibility(n.accessibility)?;
if n.is_static {

View File

@ -7,4 +7,5 @@ class MyClass extends Base {
readonly #prop6 = "asdf";
public abstract override readonly prop7 = 5;
override readonly #prop8 = 5;
declare public static readonly prop9: string;
}

View File

@ -7,4 +7,5 @@ class MyClass extends Base {
readonly #prop6 = "asdf";
public abstract override readonly prop7 = 5;
override readonly #prop8 = 5;
declare public static readonly prop9: string;
}

View File

@ -1 +1 @@
class MyClass extends Base{prop1?: string;prop2!: string;#prop3?: string;#prop4?: string="test";static readonly prop5!: string;readonly #prop6="asdf";public abstract override readonly prop7=5;override readonly #prop8=5}
class MyClass extends Base{prop1?: string;prop2!: string;#prop3?: string;#prop4?: string="test";static readonly prop5!: string;readonly #prop6="asdf";public abstract override readonly prop7=5;override readonly #prop8=5;declare public static readonly prop9: string}

View File

@ -143,6 +143,7 @@ impl VisitMut for StripType {
}
fn visit_mut_class_prop(&mut self, prop: &mut ClassProp) {
prop.declare = false;
prop.readonly = false;
prop.is_override = false;
prop.is_optional = false;