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

Variable decorators #5488

Closed
ismail-codar opened this issue Nov 2, 2015 · 2 comments
Closed

Variable decorators #5488

ismail-codar opened this issue Nov 2, 2015 · 2 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@ismail-codar
Copy link

ClassDecorator, PropertyDecorator, MethodDecorator, ParameterDecorator supported in typescript. All of them aimed class structure.

However, the following notation will be very useful. More javascript like code but powered with decorators.(Currently raises decorators are not valid here exception)

@ComponentDecl
var obj = {
//some object definition
}

@Log
function MyMethod() {

}
@HerringtonDarkholme
Copy link
Contributor

Why not just a function call? It is more flexible than decorator in TS.

@mhegazy
Copy link
Contributor

mhegazy commented Nov 2, 2015

There is a long discussion in the original decorator proposal about function declarations: #2249; one thing to note, what TypeScript has is an implementation to an existing ECMAScript proposal, and we will not want to deviate from the proposal much specially in such an early stage.

And as @HerringtonDarkholme mentioned, using a function should achive what you want with a clearer semantics:

var obj = ComponentDecl()({
//some object definition
});

var MyMethod = Log()(function MyMethod() {

});

@mhegazy mhegazy closed this as completed Nov 2, 2015
@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Nov 2, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

3 participants