Skip to content

support Decorators #38

@SimonLdj

Description

@SimonLdj

It could be cool to add decorators methods

class Person {
  firstName: string = "Jon"
  lastName: string = "Doe"

  @monitored
  getFullName () {
    return `${this.firstName} ${this.lastName}`;
  }
}

instead of we doing now a lot of

class Person {
  firstName: string = "Jon"
  lastName: string = "Doe"

  getFullName () {
    return monitored('getFullName', () => {
      return `${this.firstName} ${this.lastName}`;
    });
  }
}

The drawbacks are that decorators for now can only be applied on class declaration, method, accessor, property, or parameter (not raw functions), and are an experimental feature (TS experimental JS stage 2 proposal). I feel it's not a problem as sooner or later it will be standardized and we can do the small adjustment later. Many big frameworks used or use decorators despite it, and after all, we provide it as optional opt-in feature.

Metadata

Metadata

Assignees

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