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

Function injectableDefOrInjectorDefFactory

packages/core/src/di/r3_injector.ts:571–596  ·  view source on GitHub ↗
(token: ProviderToken<any>)

Source from the content-addressed store, hash-verified

569}
570
571function injectableDefOrInjectorDefFactory(token: ProviderToken<any>): FactoryFn<any> {
572 // Most tokens will have an injectable def directly on them, which specifies a factory directly.
573 const injectableDef = getInjectableDef(token);
574 const factory = injectableDef !== null ? injectableDef.factory : getFactoryDef(token);
575
576 if (factory !== null) {
577 return factory;
578 }
579
580 // InjectionTokens should have an injectable def (ɵprov) and thus should be handled above.
581 // If it's missing that, it's an error.
582 if (token instanceof InjectionToken) {
583 throw new RuntimeError(
584 RuntimeErrorCode.INVALID_INJECTION_TOKEN,
585 ngDevMode && `Token ${stringify(token)} is missing a ɵprov definition.`,
586 );
587 }
588
589 // Undecorated types can sometimes be created if they have no constructor arguments.
590 if (token instanceof Function) {
591 return getUndecoratedInjectableFactory(token);
592 }
593
594 // There was no way to resolve a factory for this token.
595 throw new RuntimeError(RuntimeErrorCode.INVALID_INJECTION_TOKEN, ngDevMode && 'unreachable');
596}
597
598function getUndecoratedInjectableFactory(token: Function) {
599 // If the token has parameters then it has dependencies that we cannot resolve implicitly.

Callers 2

getMethod · 0.85
providerToFactoryFunction · 0.85

Calls 4

getInjectableDefFunction · 0.90
getFactoryDefFunction · 0.90
stringifyFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…