Skip to content

Preserve decorator ordering, remove restrictions on decorator-before-export in JavaScript files #52578

@DanielRosenwasser

Description

@DanielRosenwasser

As per conclusions we arrived at in the January 2023 meeting

  1. we should allow decorators before and after export/export default, but not around both.
  2. our down-level emit and printing should preserve the ordering of where decorators are placed.
declare function decorator(...args: any[]): any;

// ✅ Works!
@decorator export class Foo {}

// ✅ Works!
export @decorator class Bar {}

// ❌ You have to pick *one or the other*.
@decorator export @decorator class Baz {}
declare function decorator(...args: any[]): any;

// ✅ Works!
@decorator export default class Foo {}

// ✅ Works!
export default @decorator class default Bar {}

// ❌ Not in between.
export @decorator default class Baz {}

// ❌ Not around both.
@decorator export default @decorator class Biz {}

// ❌ DEFINITELY not interleaved.
@decorator export @decorator default @decorator class Wat {}

Metadata

Metadata

Assignees

Labels

Domain: DecoratorsThe issue relates to the decorator syntaxDomain: JS EmitThe issue relates to the emission of JavaScriptDomain: JavaScriptThe issue relates to JavaScript specificallyES NextNew featurers for ECMAScript (a.k.a. ESNext)Fix AvailableA PR has been opened for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions