Skip to content

Commit 34967a9

Browse files
committed
fix(app): service/injectable export in module providers
fix #1290
1 parent 2306c47 commit 34967a9

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/app/compiler/angular/deps/helpers/class-helper.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { StringifyObjectLiteralExpression } from '../../../../../utils/object-li
1313
import DependenciesEngine from '../../../../engines/dependencies.engine';
1414
import Configuration from '../../../../configuration';
1515
import { StringifyArrowFunction } from '../../../../../utils/arrow-function.util';
16+
import { getNodeDecorators, nodeHasDecorator } from '../../../../../utils/node.util';
1617

1718
const crypto = require('crypto');
1819
const { marked } = require('marked');
@@ -49,7 +50,7 @@ export class ClassHelper {
4950
}
5051

5152
private getDecoratorOfType(node, decoratorType) {
52-
let decorators = node.decorators || [];
53+
let decorators = getNodeDecorators(node) || [];
5354
let result = [];
5455
const len = decorators.length;
5556

@@ -536,7 +537,8 @@ export class ClassHelper {
536537
}
537538
members = this.visitMembers(classDeclaration.members, sourceFile);
538539

539-
if (classDeclaration.decorators) {
540+
if (nodeHasDecorator(classDeclaration)) {
541+
const classDecorators = getNodeDecorators(classDeclaration);
540542
// Loop and search for official decorators at top-level :
541543
// Angular : @NgModule, @Component, @Directive, @Injectable, @Pipe
542544
// Nestjs : @Controller, @Module, @Injectable
@@ -546,18 +548,16 @@ export class ClassHelper {
546548
let isPipe = false;
547549
let isModule = false;
548550
let isController = false;
549-
for (let a = 0; a < classDeclaration.decorators.length; a++) {
551+
for (let a = 0; a < classDecorators.length; a++) {
550552
//console.log(classDeclaration.decorators[i].expression);
551553

552554
// RETURN TOO EARLY FOR MANY DECORATORS !!!!
553555
// 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]);
561561
}
562562
if (isDirective) {
563563
return {
@@ -1170,8 +1170,9 @@ export class ClassHelper {
11701170
result.description = marked(cleanedDescription);
11711171
}
11721172

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);
11751176
}
11761177

11771178
if (property.modifiers) {
@@ -1313,8 +1314,9 @@ export class ClassHelper {
13131314
result.description = marked(cleanedDescription);
13141315
}
13151316

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);
13181320
}
13191321

13201322
if (method.modifiers) {
@@ -1506,8 +1508,10 @@ export class ClassHelper {
15061508
}
15071509
}
15081510
}
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(
15111515
item => item.name !== 'Input' && item.name !== 'HostBinding'
15121516
);
15131517
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy