Created
September 28, 2017 12:13
-
-
Save lankaapura/fb34e29b8ea9b6e49d31622961fd3ebe to your computer and use it in GitHub Desktop.
Typescript guard
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
export function guard() { | |
return function (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) { | |
const originalMethod = descriptor.value; | |
descriptor.value = function (...args: any[]) { | |
return false ? originalMethod.apply(this, args) : console.log('not authorized.'); | |
}; | |
return descriptor; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment