Skip to content

tsgo emits invalid code for decorated class methods with Symbol names #2446

@KostyaTretyak

Description

@KostyaTretyak

Steps to reproduce

tsgo compiles the following code incorrectly. Note the method name in the class:

class A {
  @(fakeDecorator as any)
  [Symbol()]() {}
}

function fakeDecorator() {}

tsconfig:

{
  "compilerOptions": {
    "module": "nodenext",
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "composite": true,
    "noImplicitOverride": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitReturns": true,
    "skipLibCheck": true,
    "target": "es2023",
    "strictPropertyInitialization": false,
    "noImplicitAny": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
  }
}

Behavior with typescript@5.9

Valid code

Behavior with tsgo

Emits a non-existent method name - _a. If you run the compiled code, it throws an error:

], A.prototype, _a, null);
                ^

ReferenceError: _a is not defined

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions