createHostDirectiveTypes function

List<CompileTypedMetadata> createHostDirectiveTypes(
  1. CompileTypeMetadata componentType
)

Creates metadata necessary to flow types from a host view to its component.

Implementation

List<CompileTypedMetadata> createHostDirectiveTypes(
    CompileTypeMetadata componentType) {
  // If the component doesn't have any generic type parameters, there's no need
  // to specify generic type arguments.
  if (componentType.typeParameters.isEmpty) {
    return [];
  }
  // Otherwise, the returned metadata flows each type parameter of the host view
  // as a type argument to the component (and its associated views).
  return [
    CompileTypedMetadata(
      componentType.name,
      componentType.moduleUrl,
      componentType.typeParameters.map((t) => t.toType()).toList(),
    )
  ];
}