Skip to content

Commit

Permalink
fix(codegen): support optional class methods
Browse files Browse the repository at this point in the history
  • Loading branch information
escaton committed Jul 2, 2024
1 parent b007553 commit 63c5f1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2413,6 +2413,9 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for MethodDefinition<'a> {
if self.computed {
p.print(b']');
}
if self.optional {
p.print(b'?');
}
if let Some(type_parameters) = self.value.type_parameters.as_ref() {
type_parameters.gen(p, ctx);
}
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_codegen/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ fn typescript() {
);
test_ts("let foo: { <T>(t: T): void }", "let foo: {<T>(t: T): void};\n", false);
test_ts("function <const T>(){}", "function<const T>() {}\n", false);
test_ts("class A {m?(): void}", "class A {\n\tm?(): void;\n}\n", false);
}

fn test_comment_helper(source_text: &str, expected: &str) {
Expand Down

0 comments on commit 63c5f1e

Please sign in to comment.