Skip to content

Instantly share code, notes, and snippets.

@vivainio
Last active November 9, 2016 12:53
Show Gist options
  • Save vivainio/4df8c39527999b8c08af900b48d14d69 to your computer and use it in GitHub Desktop.
Save vivainio/4df8c39527999b8c08af900b48d14d69 to your computer and use it in GitHub Desktop.
// deprecate a set of properties. Handy e.g. to see bad access in angular directives where TypeScript doesn't help you
class FooClass { ... }
function deprecate(klass: any, props: string[]) {
props.forEach(prop => {
Object.defineProperty(klass.prototype, prop, {
get: () => { debugger; console.log('BAD READ', prop) },
set: () => console.log('BAD WRITE', prop)
})
})
}
deprecate(FooClass, ['bar', 'attribute']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment