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
10 changes: 6 additions & 4 deletions crates/oxc_formatter/src/write/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,12 @@ impl<'a> Format<'a> for FormatClass<'a, '_> {
// Decorators are handled differently depending on the parent context
// When the class is exported, the export statement handles decorator formatting
// to ensure proper placement relative to the export keyword
if !matches!(
self.parent,
AstNodes::ExportNamedDeclaration(_) | AstNodes::ExportDefaultDeclaration(_)
) {
if self.is_expression()
|| !matches!(
self.parent,
AstNodes::ExportNamedDeclaration(_) | AstNodes::ExportDefaultDeclaration(_)
)
{
write!(f, decorators)?;
}

Expand Down
1 change: 1 addition & 0 deletions crates/oxc_formatter/src/write/export_declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fn format_export_keyword_with_class_decorators<'a>(

if let AstNodes::Class(class) = declaration
&& !class.decorators.is_empty()
&& !class.is_expression()
{
// `@decorator export class Cls {}`
// decorators are placed before the export keyword
Expand Down
6 changes: 1 addition & 5 deletions tasks/coverage/snapshots/formatter_typescript.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: 261630d6

formatter_typescript Summary:
AST Parsed : 8816/8816 (100.00%)
Positive Passed: 8785/8816 (99.65%)
Positive Passed: 8787/8816 (99.67%)
Mismatch: tasks/coverage/typescript/tests/cases/compiler/amdLikeInputDeclarationEmit.ts

Expect to Parse: tasks/coverage/typescript/tests/cases/compiler/arrayFromAsync.ts
Expand Down Expand Up @@ -45,10 +45,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/classes/prope
Classes may not have a static property named prototypeClasses may not have a static property named prototypeClasses may not have a static property named prototypeClasses may not have a static property named prototypeClasses may not have a static property named prototypeClasses may not have a static property named prototype
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/controlFlow/controlFlowAssignmentPatternOrder.ts
An implementation cannot be declared in ambient contexts.
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/esDecorators/classExpression/esDecorators-classExpression-missingEmitHelpers-classDecorator.3.ts
Decorators are not valid here.Unexpected token
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/esDecorators/classExpression/namedEvaluation/esDecorators-classExpression-namedEvaluation.8.ts
Decorators are not valid here.Unexpected token
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/expressions/elementAccess/letIdentifierInElementAccess01.ts
Unexpected token
Mismatch: tasks/coverage/typescript/tests/cases/conformance/expressions/typeGuards/typeGuardsInRightOperandOfAndAndOperator.ts
Expand Down
Loading