(token: Function)
| 596 | } |
| 597 | |
| 598 | function 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 | |
| 624 | function providerToRecord(provider: SingleProvider): Record<any> { |
| 625 | if (isValueProvider(provider)) { |
no test coverage detected
searching dependent graphs…