( injection: Readonly<Injection>, expectedType: Function, expectedTypeName?: string, )
| 406 | * @returns The name of the target |
| 407 | */ |
| 408 | export function assertTargetType( |
| 409 | injection: Readonly<Injection>, |
| 410 | expectedType: Function, |
| 411 | expectedTypeName?: string, |
| 412 | ) { |
| 413 | const targetName = ResolutionSession.describeInjection(injection).targetName; |
| 414 | const targetType = inspectTargetType(injection); |
| 415 | if (targetType && targetType !== expectedType) { |
| 416 | expectedTypeName = expectedTypeName ?? expectedType.name; |
| 417 | throw new Error( |
| 418 | `The type of ${targetName} (${targetType.name}) is not ${expectedTypeName}`, |
| 419 | ); |
| 420 | } |
| 421 | return targetName; |
| 422 | } |
| 423 | |
| 424 | /** |
| 425 | * Resolver for `@inject.getter` |
no test coverage detected