MCPcopy Create free account
hub / github.com/angular/angular / extractQueriesMetadata

Function extractQueriesMetadata

packages/core/src/render3/jit/directive.ts:445–479  ·  view source on GitHub ↗
(
  type: Type<any>,
  propMetadata: {[key: string]: any[]},
  isQueryAnn: (ann: any) => ann is Query,
)

Source from the content-addressed store, hash-verified

443 };
444}
445function extractQueriesMetadata(
446 type: Type<any>,
447 propMetadata: {[key: string]: any[]},
448 isQueryAnn: (ann: any) => ann is Query,
449): R3QueryMetadataFacade[] {
450 const signalQueriesMeta: R3QueryMetadataFacade[] = [];
451 const decoratorQueriesMeta: R3QueryMetadataFacade[] = [];
452 for (const field in propMetadata) {
453 if (Object.hasOwn(propMetadata, field)) {
454 const annotations = propMetadata[field];
455 annotations.forEach((ann) => {
456 if (isQueryAnn(ann)) {
457 if (!ann.selector) {
458 throw new Error(
459 `Can't construct a query for the property "${field}" of ` +
460 `"${stringifyForError(type)}" since the query selector wasn't defined.`,
461 );
462 }
463 if (annotations.some(isInputAnnotation)) {
464 throw new Error(`Cannot combine @Input decorators with query decorators`);
465 }
466 const queryMeta = convertToR3QueryMetadata(field, ann);
467 if (queryMeta.isSignal) {
468 signalQueriesMeta.push(queryMeta);
469 } else {
470 decoratorQueriesMeta.push(queryMeta);
471 }
472 }
473 });
474 }
475 }
476
477 // We match the behavior of AOT here by having signal queries first, then the decorator queries.
478 return [...signalQueriesMeta, ...decoratorQueriesMeta];
479}
480
481function extractExportAs(exportAs: string | undefined): string[] | null {
482 return exportAs === undefined ? null : splitByComma(exportAs);

Callers 1

directiveMetadataFunction · 0.85

Calls 5

stringifyForErrorFunction · 0.90
someMethod · 0.80
convertToR3QueryMetadataFunction · 0.70
forEachMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected