import { Component , ChangeDetectionStrategy } from '@angular/core' ; declare var Reflect ; const _reflect = Reflect ; export class DecoratorUtils { public static getMetadata ( metadata = { } , customDecoratorMetadata ? ) { if ( metadata . changeDetection ) { metadata . changeDetection = metadata . changeDetection ; } else { metadata . changeDetection = ChangeDetectionStrategy . OnPush ; } if ( metadata . encapsulation ) { metadata . encapsulation = metadata . encapsulation ; } if ( metadata . init ) { metadata . init ( ) ; } return metadata ; } public static annotateComponent ( cls , metadata = { } , customDecoratorMetadata ? ) { let annotations = _reflect . getMetadata ( 'annotations' , cls ) || [ ] ; annotations . push ( new Component ( DecoratorUtils . getMetadata ( metadata , customDecoratorMetadata ) ) ) ; _reflect . defineMetadata ( 'annotations' , annotations , cls ) ; return cls ; } }