Skip to content

Commit

Permalink
fix(es/codegen): Emit declare keyword for class properties (#8478)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Jan 3, 2024
1 parent faf8cde commit 2076ef8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions crates/swc_ecma_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,11 @@ where
emit!(dec)
}

if n.declare {
keyword!("declare");
space!();
}

self.emit_accessibility(n.accessibility)?;

if n.is_static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/swc_ecma_transforms_typescript/src/strip_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2076ef8

Please sign in to comment.