UNPKG

983 BPlain TextView Raw
1import { ts } from 'ts-morph';
2
3export function isModuleWithProviders(node: ts.VariableStatement): boolean {
4 let result = false;
5 if (node.declarationList) {
6 if (node.declarationList.declarations && node.declarationList.declarations.length > 0) {
7 let i = 0,
8 declarations = node.declarationList.declarations,
9 len = node.declarationList.declarations.length;
10
11 for (i; i < len; i++) {
12 let declaration = node.declarationList.declarations[i];
13
14 if (declaration.type) {
15 let type: ts.TypeReferenceNode = declaration.type as ts.TypeReferenceNode;
16 if (type.typeName) {
17 let text = type.typeName.getText();
18 if (text === 'ModuleWithProviders') {
19 result = true;
20 }
21 }
22 }
23 }
24 }
25 }
26 return result;
27}