* Analyzes the decorators of the given parameter. Returns whether it has * an `@Inject` or `@Optional` decorator applied.
(param: ts.ParameterDeclaration)
| 166 | * an `@Inject` or `@Optional` decorator applied. |
| 167 | */ |
| 168 | function analyzeDecorators(param: ts.ParameterDeclaration): { |
| 169 | hasInject: boolean; |
| 170 | isOptional: boolean; |
| 171 | } { |
| 172 | const decorators = ts.getDecorators(param); |
| 173 | |
| 174 | if (!decorators) { |
| 175 | return {hasInject: false, isOptional: false}; |
| 176 | } |
| 177 | |
| 178 | let hasInject = false; |
| 179 | let isOptional = false; |
| 180 | for (const decorator of decorators) { |
| 181 | const expr = decorator.expression; |
| 182 | if (!ts.isCallExpression(expr) || !ts.isIdentifier(expr.expression)) { |
| 183 | continue; |
| 184 | } |
| 185 | if (expr.expression.text === 'Inject') { |
| 186 | hasInject = true; |
| 187 | } |
| 188 | if (expr.expression.text === 'Optional') { |
| 189 | isOptional = true; |
| 190 | } |
| 191 | } |
| 192 | return {hasInject, isOptional}; |
| 193 | } |
no outgoing calls
no test coverage detected