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

Function reflectDependency

packages/core/src/di/jit/util.ts:30–78  ·  view source on GitHub ↗
(dep: any | any[])

Source from the content-addressed store, hash-verified

28}
29
30function reflectDependency(dep: any | any[]): R3DependencyMetadataFacade {
31 const meta: R3DependencyMetadataFacade = {
32 token: null,
33 attribute: null,
34 host: false,
35 optional: false,
36 self: false,
37 skipSelf: false,
38 };
39
40 if (Array.isArray(dep) && dep.length > 0) {
41 for (let j = 0; j < dep.length; j++) {
42 const param = dep[j];
43 if (param === undefined) {
44 // param may be undefined if type of dep is not set by ngtsc
45 continue;
46 }
47
48 const proto = Object.getPrototypeOf(param);
49
50 if (param instanceof Optional || proto.ngMetadataName === 'Optional') {
51 meta.optional = true;
52 } else if (param instanceof SkipSelf || proto.ngMetadataName === 'SkipSelf') {
53 meta.skipSelf = true;
54 } else if (param instanceof Self || proto.ngMetadataName === 'Self') {
55 meta.self = true;
56 } else if (param instanceof Host || proto.ngMetadataName === 'Host') {
57 meta.host = true;
58 } else if (param instanceof Inject) {
59 meta.token = param.token;
60 } else if (param instanceof Attribute) {
61 if (param.attributeName === undefined) {
62 throw new RuntimeError(
63 RuntimeErrorCode.INVALID_INJECTION_TOKEN,
64 ngDevMode && `Attribute name must be defined.`,
65 );
66 }
67 meta.attribute = param.attributeName;
68 } else {
69 meta.token = param;
70 }
71 }
72 } else if (dep === undefined || (Array.isArray(dep) && dep.length === 0)) {
73 meta.token = null;
74 } else {
75 meta.token = dep;
76 }
77 return meta;
78}

Callers 1

convertDependenciesFunction · 0.85

Calls 1

isArrayMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…