@@ -13,6 +13,7 @@ import { StringifyObjectLiteralExpression } from '../../../../../utils/object-li
13
13
import DependenciesEngine from '../../../../engines/dependencies.engine' ;
14
14
import Configuration from '../../../../configuration' ;
15
15
import { StringifyArrowFunction } from '../../../../../utils/arrow-function.util' ;
16
+ import { getNodeDecorators , nodeHasDecorator } from '../../../../../utils/node.util' ;
16
17
17
18
const crypto = require ( 'crypto' ) ;
18
19
const { marked } = require ( 'marked' ) ;
@@ -49,7 +50,7 @@ export class ClassHelper {
49
50
}
50
51
51
52
private getDecoratorOfType ( node , decoratorType ) {
52
- let decorators = node . decorators || [ ] ;
53
+ let decorators = getNodeDecorators ( node ) || [ ] ;
53
54
let result = [ ] ;
54
55
const len = decorators . length ;
55
56
@@ -536,7 +537,8 @@ export class ClassHelper {
536
537
}
537
538
members = this . visitMembers ( classDeclaration . members , sourceFile ) ;
538
539
539
- if ( classDeclaration . decorators ) {
540
+ if ( nodeHasDecorator ( classDeclaration ) ) {
541
+ const classDecorators = getNodeDecorators ( classDeclaration ) ;
540
542
// Loop and search for official decorators at top-level :
541
543
// Angular : @NgModule , @Component, @Directive, @Injectable, @Pipe
542
544
// Nestjs : @Controller , @Module, @Injectable
@@ -546,18 +548,16 @@ export class ClassHelper {
546
548
let isPipe = false ;
547
549
let isModule = false ;
548
550
let isController = false ;
549
- for ( let a = 0 ; a < classDeclaration . decorators . length ; a ++ ) {
551
+ for ( let a = 0 ; a < classDecorators . length ; a ++ ) {
550
552
//console.log(classDeclaration.decorators[i].expression);
551
553
552
554
// RETURN TOO EARLY FOR MANY DECORATORS !!!!
553
555
// iterating through the decorators array we have to keep the flags `true` values from the previous loop iteration
554
- isDirective =
555
- isDirective || this . isDirectiveDecorator ( classDeclaration . decorators [ a ] ) ;
556
- isService = isService || this . isServiceDecorator ( classDeclaration . decorators [ a ] ) ;
557
- isPipe = isPipe || this . isPipeDecorator ( classDeclaration . decorators [ a ] ) ;
558
- isModule = isModule || this . isModuleDecorator ( classDeclaration . decorators [ a ] ) ;
559
- isController =
560
- isController || this . isControllerDecorator ( classDeclaration . decorators [ a ] ) ;
556
+ isDirective = isDirective || this . isDirectiveDecorator ( classDecorators [ a ] ) ;
557
+ isService = isService || this . isServiceDecorator ( classDecorators [ a ] ) ;
558
+ isPipe = isPipe || this . isPipeDecorator ( classDecorators [ a ] ) ;
559
+ isModule = isModule || this . isModuleDecorator ( classDecorators [ a ] ) ;
560
+ isController = isController || this . isControllerDecorator ( classDecorators [ a ] ) ;
561
561
}
562
562
if ( isDirective ) {
563
563
return {
@@ -1170,8 +1170,9 @@ export class ClassHelper {
1170
1170
result . description = marked ( cleanedDescription ) ;
1171
1171
}
1172
1172
1173
- if ( property . decorators ) {
1174
- result . decorators = this . formatDecorators ( property . decorators ) ;
1173
+ if ( nodeHasDecorator ( property ) ) {
1174
+ const propertyDecorators = getNodeDecorators ( property ) ;
1175
+ result . decorators = this . formatDecorators ( propertyDecorators ) ;
1175
1176
}
1176
1177
1177
1178
if ( property . modifiers ) {
@@ -1313,8 +1314,9 @@ export class ClassHelper {
1313
1314
result . description = marked ( cleanedDescription ) ;
1314
1315
}
1315
1316
1316
- if ( method . decorators ) {
1317
- result . decorators = this . formatDecorators ( method . decorators ) ;
1317
+ if ( nodeHasDecorator ( method ) ) {
1318
+ const methodDecorators = getNodeDecorators ( method ) ;
1319
+ result . decorators = this . formatDecorators ( methodDecorators ) ;
1318
1320
}
1319
1321
1320
1322
if ( method . modifiers ) {
@@ -1506,8 +1508,10 @@ export class ClassHelper {
1506
1508
}
1507
1509
}
1508
1510
}
1509
- if ( property . decorators ) {
1510
- _return . decorators = this . formatDecorators ( property . decorators ) . filter (
1511
+
1512
+ if ( nodeHasDecorator ( property ) ) {
1513
+ const propertyDecorators = getNodeDecorators ( property ) ;
1514
+ _return . decorators = this . formatDecorators ( propertyDecorators ) . filter (
1511
1515
item => item . name !== 'Input' && item . name !== 'HostBinding'
1512
1516
) ;
1513
1517
}
0 commit comments