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