Last active
March 25, 2017 12:43
-
-
Save Ibro/c7f1c736a2419b1ab09b62b874c953bd to your computer and use it in GitHub Desktop.
TypeScript decorators composition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
public name: string; | |
constructor(name: string) { | |
this.name = name; | |
} | |
@a() | |
@b() | |
@c() | |
public appendTextToName(text: string) { | |
this.name += text; | |
return this.name; | |
} | |
} | |
function a() { | |
console.log('a(): evaluated'); | |
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) { | |
console.log('a(): called'); | |
} | |
} | |
function b() { | |
console.log('b(): evaluated'); | |
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) { | |
console.log('b(): called'); | |
} | |
} | |
function c() { | |
console.log('c(): evaluated'); | |
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) { | |
console.log('c(): called'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment