Skip to content

Decorator wrapped around declare or abstract fields are failing since 0.19.8 #3684

Closed
@rodrigofuentes

Description

@rodrigofuentes

The issue I'm facing is decorated declare or abstract fields are causing an Error: Decorators are not valid here. After some inspection it seems that esbuild supported this until version 0.19.8

Is this no longer supported?

Code example:

function log(target: any, key: string): void {
  console.log(`Logging ${key} function`)
}

abstract class ExampleClass {
  @log
  abstract prop1: string

  @log
  prop2: boolean = true
}

class ExampleClass2 extends ExampleClass {
  prop1: string = "world"
}

Esbuild result:

[ERROR] Decorators are not valid here

    entry.ts:6:2:
      6 │   @log
        ╵   ^

Some playground links:

Working esbuild-playground on version 0.19.7

typescript-playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions