Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DanielRosenwasser opened this issue Feb 2, 2023 · 0 comments · Fixed by #52582
Assignees
Labels
Domain: Decorators The issue relates to the decorator syntax Domain: JavaScript The issue relates to JavaScript specifically Domain: JS Emit The issue relates to the emission of JavaScript ES Next New featurers for ECMAScript (a.k.a. ESNext) Fix Available A PR has been opened for this issue

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Feb 2, 2023

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 {}
@DanielRosenwasser DanielRosenwasser added Domain: Decorators The issue relates to the decorator syntax ES Next New featurers for ECMAScript (a.k.a. ESNext) Domain: JavaScript The issue relates to JavaScript specifically labels Feb 2, 2023
@DanielRosenwasser DanielRosenwasser added this to the TypeScript 5.0.1 milestone Feb 2, 2023
@DanielRosenwasser DanielRosenwasser changed the title Remove restrictions on decorator-before-export in JavaScript files Preserve decorator ordering, remove restrictions on decorator-before-export in JavaScript files Feb 2, 2023
@DanielRosenwasser DanielRosenwasser added the Domain: JS Emit The issue relates to the emission of JavaScript label Feb 2, 2023
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Decorators The issue relates to the decorator syntax Domain: JavaScript The issue relates to JavaScript specifically Domain: JS Emit The issue relates to the emission of JavaScript ES Next New featurers for ECMAScript (a.k.a. ESNext) Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants