Skip to content

transformer: legacy decorators apply static members before instance members declared later, unlike tsc #27742

Closed

Description

@fengmk2

With decorator: { legacy: true }, oxc applies member decorators in source order. TypeScript applies every instance member decorator first, then every static member decorator.

const log: string[] = [];
const d = (name: string) => (..._args: unknown[]) => {
  log.push(name);
};

class A {
  @d('instance-prop') prop = 1;
  @d('static-prop') static s = 2;
  @d('instance-method') m() {}
  @d('static-method') static sm() {}
}
console.log(log.join(' > '));

oxc-transform 0.154.0 (target: 'es2022') emits:

_decorate([d("instance-prop")], A.prototype, "prop", void 0);
_decorate([d("static-prop")], A, "s", void 0);
_decorate([d("instance-method")], A.prototype, "m", null);
_decorate([d("static-method")], A, "sm", null);
Compiler Printed order
oxc instance-prop > static-prop > instance-method > static-method
tsc 6.0, --experimentalDecorators --target es2022 instance-prop > instance-method > static-prop > static-method
esbuild, through tsx 4.23 instance-prop > instance-method > static-prop > static-method

Code that depends on the order in which decorators run, such as decorators that register metadata, sees a different order than under tsc.

Activity

  1. added
    A-transformer
    on Oct 16, 2026
  2. added a commit that references this issue on Nov 17, 2026
    d59aa8e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-transformer

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions