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

Function toDirectiveMetadata

packages/compiler/test/typecheck/util.ts:459–504  ·  view source on GitHub ↗
(
  decl: TestDirective,
  matchSource = MatchSource.Selector,
)

Source from the content-addressed store, hash-verified

457}
458
459function toDirectiveMetadata(
460 decl: TestDirective,
461 matchSource = MatchSource.Selector,
462): TcbDirectiveMetadata {
463 const inputs: {[fieldName: string]: TcbInputMapping} = {};
464 for (const [fieldName, input] of Object.entries(decl.inputs ?? {})) {
465 inputs[fieldName] =
466 typeof input === 'string'
467 ? {
468 classPropertyName: fieldName,
469 bindingPropertyName: input,
470 required: false,
471 isSignal: false,
472 }
473 : {...input};
474 }
475
476 return {
477 ref: createReference(decl.name),
478 name: decl.name,
479 selector: decl.selector || null,
480 exportAs: decl.exportAs || null,
481 isComponent: decl.isComponent ?? false,
482 isGeneric: decl.isGeneric ?? false,
483 isStructural: decl.isStructural ?? false,
484 isStandalone: decl.isStandalone ?? false,
485 isExplicitlyDeferred: false,
486 deferredBlocks: null,
487 preserveWhitespaces: decl.preserveWhitespaces ?? false,
488 matchSource,
489 typeParameters: toTcbTypeParameters(decl.typeParameters ?? DEFAULT_TYPE_PARAMETERS),
490 inputs: ClassPropertyMapping.fromMappedObject<TcbInputMapping>(inputs),
491 outputs: ClassPropertyMapping.fromMappedObject(decl.outputs ?? {}),
492 requiresInlineTypeCtor: decl.requiresInlineTypeCtor ?? false,
493 ngTemplateGuards: decl.ngTemplateGuards ?? [],
494 hasNgTemplateContextGuard: decl.hasNgTemplateContextGuard ?? false,
495 hasNgFieldDirective: decl.hasNgFieldDirective ?? false,
496 coercedInputFields: new Set(decl.coercedInputFields ?? []),
497 restrictedInputFields: new Set(decl.restrictedInputFields ?? []),
498 stringLiteralInputFields: new Set(decl.stringLiteralInputFields ?? []),
499 undeclaredInputFields: new Set(decl.undeclaredInputFields ?? []),
500 publicMethods: new Set(decl.publicMethods ?? []),
501 ngContentSelectors: decl.ngContentSelectors || null,
502 animationTriggerNames: null,
503 };
504}
505
506/**
507 * Flattens the host directives of a directive into the list of matches they contribute, with only

Callers 2

prepareDeclarationsFunction · 0.85
resolveHostDirectivesFunction · 0.85

Calls 4

createReferenceFunction · 0.85
toTcbTypeParametersFunction · 0.85
fromMappedObjectMethod · 0.80
entriesMethod · 0.45

Tested by

no test coverage detected