Page Contents
Home > @loopback/context > assertTargetType
assertTargetType() function
Assert the target type inspected from TypeScript for injection to be the expected type. If the types don’t match, an error is thrown.
Signature:
export declare function assertTargetType(injection: Readonly<Injection>, expectedType: Function, expectedTypeName?: string): string;
Parameters
| Parameter | Type | Description |
|---|---|---|
| injection | Readonly<[Injection](/doc/en/lb4/apidocs.context.injection.html)> | Injection information |
| expectedType | Function | Expected type |
| expectedTypeName | string | _(Optional)_ Name of the expected type to be used in the error |
Returns:
string
The name of the target