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

Function getAnnotation

packages/core/src/render3/jit/module.ts:424–452  ·  view source on GitHub ↗
(type: any, name: string)

Source from the content-addressed store, hash-verified

422}
423
424function getAnnotation<T>(type: any, name: string): T | null {
425 let annotation: T | null = null;
426 collect(type.__annotations__);
427 collect(type.decorators);
428 return annotation;
429
430 function collect(annotations: any[] | null) {
431 if (annotations) {
432 annotations.forEach(readAnnotation);
433 }
434 }
435
436 function readAnnotation(decorator: {
437 type: {prototype: {ngMetadataName: string}; args: any[]};
438 args: any;
439 }): void {
440 if (!annotation) {
441 const proto = Object.getPrototypeOf(decorator);
442 if (proto.ngMetadataName == name) {
443 annotation = decorator as any;
444 } else if (decorator.type) {
445 const proto = Object.getPrototypeOf(decorator.type);
446 if (proto.ngMetadataName == name) {
447 annotation = decorator.args[0];
448 }
449 }
450 }
451 }
452}
453
454/**
455 * Keep track of compiled components. This is needed because in tests we often want to compile the

Callers 1

Calls 1

collectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…