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

Parameters

Parameter Type Description
injection Readonly<Injection> Injection information
expectedType Function Expected type
expectedTypeName string Name of the expected type to be used in the error

Returns:

string | undefined

The name of the target