MCPcopy
hub / github.com/loopbackio/loopback-next / assertTargetType

Function assertTargetType

packages/context/src/inject.ts:408–422  ·  view source on GitHub ↗
(
  injection: Readonly<Injection>,
  expectedType: Function,
  expectedTypeName?: string,
)

Source from the content-addressed store, hash-verified

406 * @returns The name of the target
407 */
408export 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`

Callers 11

extensionsFunction · 0.90
viewFunction · 0.90
listFunction · 0.90
resolveAsViewFromConfigFunction · 0.90
resolveAsGetterFunction · 0.85
resolveAsSetterFunction · 0.85
resolveAsBindingFunction · 0.85
resolveValuesByFilterFunction · 0.85
resolveAsGetterByFilterFunction · 0.85
resolveAsContextViewFunction · 0.85

Calls 2

inspectTargetTypeFunction · 0.85
describeInjectionMethod · 0.80

Tested by

no test coverage detected