Last active
May 7, 2019 21:16
-
-
Save arlindosilvaneto/ed9b5443cf1ca1e604b130597c0adf41 to your computer and use it in GitHub Desktop.
Typescript Decorators
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
function log(target: any, property: string, descriptor: PropertyDescriptor) { | |
let method = descriptor.value; | |
descriptor.value = function() { | |
console.warn(`[RUNNING]: ${property}`); | |
method.apply(this, arguments); | |
} | |
} | |
class Handlers { | |
@log | |
static handler(_: any, res: any): void { | |
res.send("Hello ts-node!"); | |
} | |
} |
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
Show hidden characters
{ | |
"compilerOptions": { | |
"experimentalDecorators": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment