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

Function Decorator #41158

Closed
CofeeWithRose opened this issue Oct 19, 2020 · 2 comments
Closed

Function Decorator #41158

CofeeWithRose opened this issue Oct 19, 2020 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@CofeeWithRose
Copy link

Suggestion

support function no in class Decorator.
In react app, I hope to use decorator to define the route information of function components.

Use Cases

Page.tsx


@Reflect.metadata('Route', { path: '/home' })
export function Page(){
  return <div> Home Page </div>
}


console.log(Reflect.getMetadata('Route', Page).path ) //   "/home"


Examples

Checklist

My suggestion meets these guidelines:

  • [yes ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • [ yes] This wouldn't change the runtime behavior of existing JavaScript code
  • [yes ] This could be implemented without emitting different JS based on the types of the expressions
  • [ yes] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • [yes ] This feature would agree with the rest of TypeScript's Design Goals.
@MartinJohns
Copy link
Contributor

Duplicate of #7318. And this would first require JavaScript to support function decorators.

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Oct 19, 2020
@RyanCavanaugh
Copy link
Member

Please follow the "search terms" part of the template. Thanks!

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