Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion crates/oxc_formatter/src/write/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,19 @@ impl<'a> Format<'a> for AstNode<'a, Vec<'a, TSEnumMember<'a>>> {

impl<'a> FormatWrite<'a> for AstNode<'a, TSEnumMember<'a>> {
fn write(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> {
write!(f, [self.id()])?;
let id = self.id();
let is_computed = matches!(id.as_ref(), TSEnumMemberName::ComputedTemplateString(_));

if is_computed {
write!(f, "[")?;
}

write!(f, [id])?;

if is_computed {
write!(f, "]")?;
}

if let Some(init) = self.initializer() {
write!(f, [space(), "=", space(), init])?;
}
Expand Down
4 changes: 1 addition & 3 deletions tasks/coverage/snapshots/formatter_misc.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
formatter_misc Summary:
AST Parsed : 49/49 (100.00%)
Positive Passed: 46/49 (93.88%)
Positive Passed: 47/49 (95.92%)
Expect to Parse: tasks/coverage/misc/pass/oxc-11487.cjs
Cannot use `await` as an identifier in an async context
Mismatch: tasks/coverage/misc/pass/oxc-2592.ts

Expect to Parse: tasks/coverage/misc/pass/oxc-4449.ts
Computed property names are not allowed in enums.
Loading