From 47c02caa294bd80d08b7f627e4b7a91b33afa455 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Fri, 28 Jan 2022 16:53:39 -0800 Subject: [PATCH] refactor(compiler-cli): Update where and how the indexed errors are exposed (#44884) The initial commit e9124b42d5ac8f570b53a86691aff64d9f6c6ee1 stored the errors rather than throwing but did not store them in a place that was accessible to consumers. Instead, the errors should be added to the IndexedComponent so they can be surfaced where the index results are consumed PR Close #44884 --- packages/compiler-cli/src/ngtsc/indexer/src/api.ts | 2 ++ packages/compiler-cli/src/ngtsc/indexer/src/transform.ts | 3 +-- packages/compiler-cli/src/ngtsc/indexer/test/transform_spec.ts | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/compiler-cli/src/ngtsc/indexer/src/api.ts b/packages/compiler-cli/src/ngtsc/indexer/src/api.ts index 2ec0ff7fd31..fc166ac33a2 100644 --- a/packages/compiler-cli/src/ngtsc/indexer/src/api.ts +++ b/packages/compiler-cli/src/ngtsc/indexer/src/api.ts @@ -7,6 +7,7 @@ */ import {ParseSourceFile} from '@angular/compiler'; + import {ClassDeclaration, DeclarationNode} from '../../reflection'; /** @@ -135,4 +136,5 @@ export interface IndexedComponent { isInline: boolean, file: ParseSourceFile; }; + errors: Error[]; } diff --git a/packages/compiler-cli/src/ngtsc/indexer/src/transform.ts b/packages/compiler-cli/src/ngtsc/indexer/src/transform.ts index af49662786b..28b9cbc3fd1 100644 --- a/packages/compiler-cli/src/ngtsc/indexer/src/transform.ts +++ b/packages/compiler-cli/src/ngtsc/indexer/src/transform.ts @@ -22,7 +22,6 @@ import {getTemplateIdentifiers} from './template'; */ export function generateAnalysis(context: IndexingContext): Map { const analysis = new Map(); - const analysisErrors: Error[] = []; context.components.forEach(({declaration, selector, boundTemplate, templateMeta}) => { const name = declaration.name.getText(); @@ -47,7 +46,6 @@ export function generateAnalysis(context: IndexingContext): Map { usedComponents: new Set(), isInline: false, file: new ParseSourceFile('
{{foo}}
', decl.getSourceFile().fileName), - } + }, + errors: [], }); });