(dep: any | any[])
| 28 | } |
| 29 | |
| 30 | function 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 | } |
no test coverage detected
searching dependent graphs…