Created
September 1, 2017 13:36
-
-
Save serjKim/c74bcbcef66ad00afd5fc435db13be91 to your computer and use it in GitHub Desktop.
reflect-metadata
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
import 'reflect-metadata'; | |
type MyDecObj = {a: number}; | |
const myDecKey = Symbol('design:myDec') | |
function MyDec(obj: MyDecObj) { | |
return Reflect.metadata(myDecKey, obj); | |
} | |
@MyDec({a: 100}) | |
class A { | |
@MyDec({a: 0}) | |
public property: string; | |
} | |
const inst = new A; | |
const obj = Reflect.getMetadata(myDecKey, inst, 'property'); | |
console.log(obj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment