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> 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