MCPcopy Index your code
hub / github.com/angular/angular / getUndecoratedInjectableFactory

Function getUndecoratedInjectableFactory

packages/core/src/di/r3_injector.ts:598–622  ·  view source on GitHub ↗
(token: Function)

Source from the content-addressed store, hash-verified

596}
597
598function getUndecoratedInjectableFactory(token: Function) {
599 // If the token has parameters then it has dependencies that we cannot resolve implicitly.
600 const paramLength = token.length;
601 if (paramLength > 0) {
602 throw new RuntimeError(
603 RuntimeErrorCode.INVALID_INJECTION_TOKEN,
604 ngDevMode &&
605 `Can't resolve all parameters for ${stringify(token)}: (${newArray(paramLength, '?').join(
606 ', ',
607 )}).`,
608 );
609 }
610
611 // The constructor function appears to have no parameters.
612 // This might be because it inherits from a super-class. In which case, use an injectable
613 // def from an ancestor if there is one.
614 // Otherwise this really is a simple class with no dependencies, so return a factory that
615 // just instantiates the zero-arg constructor.
616 const inheritedInjectableDef = getInheritedInjectableDef(token);
617 if (inheritedInjectableDef !== null) {
618 return () => inheritedInjectableDef.factory(token as Type<any>);
619 } else {
620 return () => new (token as Type<any>)();
621 }
622}
623
624function providerToRecord(provider: SingleProvider): Record<any> {
625 if (isValueProvider(provider)) {

Callers 1

Calls 5

stringifyFunction · 0.90
newArrayFunction · 0.90
joinMethod · 0.65
factoryMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…