Skip to content

Instantly share code, notes, and snippets.

@voldikss
Created December 29, 2021 07:53
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 voldikss/60c386a8517ba790a6177c2a8b9b6518 to your computer and use it in GitHub Desktop.
Save voldikss/60c386a8517ba790a6177c2a8b9b6518 to your computer and use it in GitHub Desktop.
@classDecFactory()
class Student {
@propertyDecFactory()
name: string
@methodDecFactory()
run(@parameterDecFactory() arg: string) {
console.log(arg)
}
}
function classDecFactory(): ClassDecorator {
return (target) => {
console.log('classDecFactory', target, typeof target)
}
}
function propertyDecFactory(): PropertyDecorator {
return (target, propertyKey) => {
console.log('propertyDecFactory', target, typeof target)
}
}
function methodDecFactory(): MethodDecorator {
return (target, propertyKey, descriptor) => {
console.log('methodDecFactory', target, typeof target)
}
}
function parameterDecFactory(): ParameterDecorator {
return (target, propertyKey, parameterIndex) => {
console.log('parameterDecFactory', target, typeof target)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment