Skip to content

Instantly share code, notes, and snippets.

@nehalist
Created June 26, 2019 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nehalist/a5167ca0f00d57f094bbdeab00af6d25 to your computer and use it in GitHub Desktop.
Save nehalist/a5167ca0f00d57f094bbdeab00af6d25 to your computer and use it in GitHub Desktop.
const CUSTOM_PROPS = 'custom:properties';
function Expose(target: object, key: string) {
let properties: string[] | undefined = Reflect.getMetadata(CUSTOM_PROPS, target);
if (! properties) {
properties = [];
}
properties.push(key);
Reflect.defineMetadata(CUSTOM_PROPS, properties, target);
}
class Page {
@Expose content: object;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment