Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

property decorator typescript constructor

function DecoratorName(attr: any) {
  return function _DecoratorName<T extends {new(...args: any[]): {}}>(constr: T){
    return class extends constr {
      constructor(...args: any[]) {
        super(...args)
        console.log('Did something after the original constructor!')
        console.log('Here is my attribute!', attr.attrName)
      }
    }
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #property #decorator #typescript #constructor
ADD COMMENT
Topic
Name
2+4 =