(token: ProviderToken<any>)
| 569 | } |
| 570 | |
| 571 | function 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 | |
| 598 | function getUndecoratedInjectableFactory(token: Function) { |
| 599 | // If the token has parameters then it has dependencies that we cannot resolve implicitly. |
no test coverage detected
searching dependent graphs…