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

Function validateInjectionKey

packages/upgrade/src/common/src/util.ts:110–156  ·  view source on GitHub ↗
(
  $injector: IInjectorService,
  downgradedModule: string,
  injectionKey: string,
  attemptedAction: string,
)

Source from the content-addressed store, hash-verified

108}
109
110export function validateInjectionKey(
111 $injector: IInjectorService,
112 downgradedModule: string,
113 injectionKey: string,
114 attemptedAction: string,
115): void {
116 const upgradeAppType = getUpgradeAppType($injector);
117 const downgradedModuleCount = getDowngradedModuleCount($injector);
118
119 // Check for common errors.
120 switch (upgradeAppType) {
121 case UpgradeAppType.Dynamic:
122 case UpgradeAppType.Static:
123 if (downgradedModule) {
124 throw new Error(
125 `Error while ${attemptedAction}: 'downgradedModule' unexpectedly specified.\n` +
126 "You should not specify a value for 'downgradedModule', unless you are downgrading " +
127 "more than one Angular module (via 'downgradeModule()').",
128 );
129 }
130 break;
131 case UpgradeAppType.Lite:
132 if (!downgradedModule && downgradedModuleCount >= 2) {
133 throw new Error(
134 `Error while ${attemptedAction}: 'downgradedModule' not specified.\n` +
135 'This application contains more than one downgraded Angular module, thus you need to ' +
136 "always specify 'downgradedModule' when downgrading components and injectables.",
137 );
138 }
139
140 if (!$injector.has(injectionKey)) {
141 throw new Error(
142 `Error while ${attemptedAction}: Unable to find the specified downgraded module.\n` +
143 'Did you forget to downgrade an Angular module or include it in the AngularJS ' +
144 'application?',
145 );
146 }
147
148 break;
149 default:
150 throw new Error(
151 `Error while ${attemptedAction}: Not a valid '@angular/upgrade' application.\n` +
152 'Did you forget to downgrade an Angular module or include it in the AngularJS ' +
153 'application?',
154 );
155 }
156}
157
158export class Deferred<R> {
159 promise: Promise<R>;

Callers 2

directiveFactoryFunction · 0.90
factoryFunction · 0.90

Calls 3

getUpgradeAppTypeFunction · 0.85
getDowngradedModuleCountFunction · 0.85
hasMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…