Skip to content

Decorators on accessor class fields fail to parse in Bun #29197

@kevgeoleo

Description

@kevgeoleo

What version of Bun is running?

1.3.11-canary.1+9e93bfa1b

What platform is your computer?

Linux 5.10.0-12-amd64 x86_64 x86_64

What steps can reproduce the bug?

Hi,

The behavior can be reproduced using the below PoC:

// a.ts
function example(target: any, context: any) {}
class Foo {
  @example accessor x = "value";
}

What is the expected behavior?

This is valid TypeScript (TS 5+ accessor field syntax with decorators). It should work without throwing Error

What do you see instead?

root@KContainer:~/22254# bun run a.ts
4 |   @example accessor x = "value";
                        ^
error: Expected ";" but found "x"
    at /home/c01kele/22254/a.ts:4:21

4 |   @example accessor x = "value";
                          ^
error: Expected identifier but found "="
    at /home/c01kele/22254/a.ts:4:23

Bun v1.3.11-canary.1+9e93bfa1b (Linux x64)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions