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

Use decorators directly on functions #52038

Closed
flycran opened this issue Dec 28, 2022 · 1 comment
Closed

Use decorators directly on functions #52038

flycran opened this issue Dec 28, 2022 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@flycran
Copy link

flycran commented Dec 28, 2022

The existing decorators can only be applied to classes. Sometimes it is unnecessary to define a class for this purpose. Refer to the relevant syntax of Python. I think if you can directly define decorators for functions, you can save a lot of unnecessary code, especially you don't need to define a separate class for this purpose.

function logger(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
  //...
}

@logger
function fuc() {
  //...
}
@MartinJohns
Copy link
Contributor

You forgot to fill out the issue template. Duplicate of #7318, this is something not supported by JavaScript.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jan 5, 2023
@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants