(
filePath: string,
content: string,
classes: nga.ClassMetadata[],
templatesByClass: Map<string, ParsedComponentTemplate>,
options: Partial<ParseTemplateOptions> = {},
tcbConfig: NgpTypeCheckingConfig,
dependencyTemplates: DependencyTemplates,
tracer: Tracer,
)
| 174 | } |
| 175 | |
| 176 | export function buildTcbTargets( |
| 177 | filePath: string, |
| 178 | content: string, |
| 179 | classes: nga.ClassMetadata[], |
| 180 | templatesByClass: Map<string, ParsedComponentTemplate>, |
| 181 | options: Partial<ParseTemplateOptions> = {}, |
| 182 | tcbConfig: NgpTypeCheckingConfig, |
| 183 | dependencyTemplates: DependencyTemplates, |
| 184 | tracer: Tracer, |
| 185 | ): TcbTargetInput[] { |
| 186 | const tcbTargets: TcbTargetInput[] = []; |
| 187 | const consumer = {filePath, content, classes, templatesByClass}; |
| 188 | |
| 189 | for (const cls of classes) { |
| 190 | const {className, component, directive, hostBindings, hostListeners} = cls; |
| 191 | if (!className) { |
| 192 | continue; |
| 193 | } |
| 194 | |
| 195 | if (component) { |
| 196 | if (component.isJit || (component.isPoisoned && !tcbConfig.usePoisonedData)) { |
| 197 | continue; |
| 198 | } |
| 199 | |
| 200 | // 1. Parse template (or reuse if already parsed in processFile) |
| 201 | const parsed = getOrParseComponentTemplate( |
| 202 | templatesByClass, |
| 203 | cls, |
| 204 | component, |
| 205 | filePath, |
| 206 | content, |
| 207 | options, |
| 208 | tracer, |
| 209 | ); |
| 210 | |
| 211 | const parsedSchemas: SchemaMetadata[] = []; |
| 212 | if (component.schemas) { |
| 213 | for (const schema of component.schemas) { |
| 214 | if (schema === 'CUSTOM_ELEMENTS_SCHEMA') { |
| 215 | parsedSchemas.push({name: 'custom-elements'}); |
| 216 | } else if (schema === 'NO_ERRORS_SCHEMA') { |
| 217 | parsedSchemas.push({name: 'no-errors-schema'}); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | // 9. Collect component for TCB generation (optimize mode only) |
| 223 | tcbTargets.push({ |
| 224 | // TODO(cleanup): access fields mirrored from `classMeta` directly instead of duplicating them on `TcbTargetInput`. |
| 225 | classMeta: cls, |
| 226 | className, |
| 227 | template: component.template || '', |
| 228 | templateNodes: parsed.diagNodes, |
| 229 | declarations: dependencyTemplates.withNgContentSelectors( |
| 230 | component.resolvedDeclarations ?? [], |
| 231 | consumer, |
| 232 | ), |
| 233 | ownDeclaration: metadataToDeclaration( |
no test coverage detected