Skip to content

Instantly share code, notes, and snippets.

@lankaapura
Created September 28, 2017 12:13
Show Gist options
  • Save lankaapura/fb34e29b8ea9b6e49d31622961fd3ebe to your computer and use it in GitHub Desktop.
Save lankaapura/fb34e29b8ea9b6e49d31622961fd3ebe to your computer and use it in GitHub Desktop.
Typescript guard
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