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

Function extractQueriesMetadata

packages/core/src/render3/jit/directive.ts:449–483  ·  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

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