Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Decorators #38

Open
SimonLdj opened this issue Jun 23, 2022 · 0 comments · May be fixed by #45
Open

support Decorators #38

SimonLdj opened this issue Jun 23, 2022 · 0 comments · May be fixed by #45
Assignees

Comments

@SimonLdj
Copy link
Contributor

SimonLdj commented Jun 23, 2022

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.

@SimonLdj SimonLdj self-assigned this Jun 23, 2022
@SimonLdj SimonLdj linked a pull request Jul 11, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant