Last active
November 9, 2016 12:53
-
-
Save vivainio/4df8c39527999b8c08af900b48d14d69 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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