@@ -727,6 +727,26 @@ export function getClassDecorators(state: TransformState, classNode: ts.ClassLik
727727 return items ;
728728}
729729
730+ const onlyOneOf = [ "AirshipComponentMenu" , "AirshipComponentIcon" ] ;
731+ function pushOrReplaceDecorator (
732+ decorators : Array < AirshipBehaviourClassDecorator > ,
733+ decorator : AirshipBehaviourClassDecorator ,
734+ ) {
735+ if ( onlyOneOf . includes ( decorator . name ) ) {
736+ const existing = decorators . findIndex ( f => f . name === decorator . name ) ;
737+ if ( existing != - 1 ) {
738+ decorators [ existing ] = decorator ;
739+ } else {
740+ decorators . push ( decorator ) ;
741+ }
742+ } else {
743+ const decoratorId = AirshipBehaviourClassDecorator . getId ( decorator ) ;
744+ if ( ! decorators . some ( value => decoratorId === AirshipBehaviourClassDecorator . getId ( value ) ) ) {
745+ decorators . push ( decorator ) ;
746+ }
747+ }
748+ }
749+
730750function getPropertyDecorators (
731751 state : TransformState ,
732752 propertyNode : ts . PropertyDeclaration ,
@@ -840,6 +860,8 @@ function generateMetaForAirshipBehaviour(state: TransformState, node: ts.ClassLi
840860
841861 // Inheritance
842862 const inheritance = getAncestorTypeSymbols ( classType , state . typeChecker ) ;
863+ const classDecorators = new Array < AirshipBehaviourClassDecorator > ( ) ;
864+
843865 for ( const inherited of inheritance . reverse ( ) ) {
844866 const valueDeclaration = inherited . valueDeclaration ;
845867 if ( ! valueDeclaration ) continue ;
@@ -858,11 +880,20 @@ function generateMetaForAirshipBehaviour(state: TransformState, node: ts.ClassLi
858880 }
859881
860882 inheritedBehaviourIds . push ( name ) ;
883+
884+ const inheritedClassDecorators = getClassDecorators ( state , valueDeclaration ) ;
885+ for ( const decorator of inheritedClassDecorators ) {
886+ pushOrReplaceDecorator ( classDecorators , decorator ) ;
887+ }
888+ }
889+
890+ for ( const decorator of getClassDecorators ( state , node ) ) {
891+ pushOrReplaceDecorator ( classDecorators , decorator ) ;
861892 }
862893
863894 pushPropertyMetadataForAirshipBehaviour ( state , node , metadata ) ;
864895
865- const classDecorators = getClassDecorators ( state , node ) ;
896+ // const classDecorators = getClassDecorators(state, node);
866897 if ( classDecorators . length > 0 && ! state . data . isPublishing ) metadata . decorators = classDecorators ;
867898
868899 const sha1 = crypto . createHash ( "sha1" ) ;
0 commit comments