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.


export declare function assertTargetType(injection: Readonly<Injection>, expectedType: Function, expectedTypeName?: string): string | undefined;


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


string | undefined

The name of the target