Gets an identifier that represents the given type node's resolved value.
(type: ts.TypeNode)
| 143 | |
| 144 | /** Gets an identifier that represents the given type node's resolved value. */ |
| 145 | function getInjectionType(type: ts.TypeNode): ts.Identifier | null { |
| 146 | // Unwraps union types with `null`. This is supported in Angular when |
| 147 | // `@Optional` is used. The `null` union type is ignored. |
| 148 | if (ts.isUnionTypeNode(type)) { |
| 149 | const nonNullTypes = type.types.filter(t => t.kind !== ts.SyntaxKind.NullKeyword); |
| 150 | return nonNullTypes.length === 1 ? getInjectionType(nonNullTypes[0]) : null; |
| 151 | } |
| 152 | if (!ts.isTypeReferenceNode(type)) { |
| 153 | return null; |
| 154 | } |
| 155 | const unwrapEntityName = (n: ts.EntityName): ts.Identifier => { |
| 156 | if (ts.isQualifiedName(n)) { |
| 157 | return unwrapEntityName(n.right); |
| 158 | } |
| 159 | return n; |
| 160 | }; |
| 161 | return unwrapEntityName(type.typeName); |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Analyzes the decorators of the given parameter. Returns whether it has |
no test coverage detected