@jmalarcon/

TSParamDecorator

TypeScript

No description

fork
loading
Files
  • index.ts
  • tsconfig.json
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function logParameter(target: Object, methodName: string, index: number) {
  const metadataKey = `log_${methodName}`;
  target[metadataKey] = target[metadataKey] || [];
  target[metadataKey].unshift(index);
}

class Human {
  date(@logParameter day: number, month: number, @logParameter year: number): string {
    return `Date: ${day} ${month} ${year}`;
  }
}

const person = new Human();
person.date(1, 3, 2000);

console.log(person[`log_date`]);