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

Function resolveHostDirectives

packages/compiler/test/typecheck/util.ts:510–541  ·  view source on GitHub ↗

* Flattens the host directives of a directive into the list of matches they contribute, with only * the inputs and outputs that the host exposes (under the aliases the host exposes them as).

(
  decl: TestDirective,
  results: TcbDirectiveMetadata[] = [],
)

Source from the content-addressed store, hash-verified

508 * the inputs and outputs that the host exposes (under the aliases the host exposes them as).
509 */
510function resolveHostDirectives(
511 decl: TestDirective,
512 results: TcbDirectiveMetadata[] = [],
513): TcbDirectiveMetadata[] {
514 for (const hostDir of decl.hostDirectives ?? []) {
515 resolveHostDirectives(hostDir.directive, results);
516
517 const meta = toDirectiveMetadata(hostDir.directive, MatchSource.HostDirective);
518 const exposedInputs = parseMappingArray(hostDir.inputs ?? []);
519 const exposedOutputs = parseMappingArray(hostDir.outputs ?? []);
520 const inputs: {[fieldName: string]: TcbInputMapping} = {};
521 const outputs: {[fieldName: string]: string} = {};
522
523 for (const [publicName, alias] of Object.entries(exposedInputs)) {
524 for (const input of meta.inputs.getByBindingPropertyName(publicName) ?? []) {
525 inputs[input.classPropertyName] = {...input, bindingPropertyName: alias};
526 }
527 }
528 for (const [publicName, alias] of Object.entries(exposedOutputs)) {
529 for (const output of meta.outputs.getByBindingPropertyName(publicName) ?? []) {
530 outputs[output.classPropertyName] = alias;
531 }
532 }
533
534 results.push({
535 ...meta,
536 inputs: ClassPropertyMapping.fromMappedObject<TcbInputMapping>(inputs),
537 outputs: ClassPropertyMapping.fromMappedObject(outputs),
538 });
539 }
540 return results;
541}
542
543/** Parses `['field', 'field: alias']` style mappings into a `{field: alias}` record. */
544function parseMappingArray(values: string[]): {[field: string]: string} {

Callers 1

prepareDeclarationsFunction · 0.70

Calls 6

toDirectiveMetadataFunction · 0.85
parseMappingArrayFunction · 0.85
fromMappedObjectMethod · 0.80
entriesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected