Skip to content

Instantly share code, notes, and snippets.

@ludndev
Created October 16, 2024 14:23
Show Gist options
  • Save ludndev/42a383567957ead5d93d34c4f5f6e088 to your computer and use it in GitHub Desktop.
Save ludndev/42a383567957ead5d93d34c4f5f6e088 to your computer and use it in GitHub Desktop.
Metadata Reflection Demo
/**
* Metadata Reflection Demo by https://github.com/ludndev
*/
const reportClass: any[] = []
function report(constructor: Function) {
reportClass.push(constructor.name)
}
@report
class MathematicsReportClass {
type = "report";
title: string;
constructor(t: string) {
this.title = t;
}
}
@report
class BiologyReportClass {
type = "report";
title: string;
constructor(t: string) {
this.title = t;
}
}
console.log('All report classes', reportClass);