refactor(compiler-cli): Update where and how the indexed errors are exposed (#44884)

The initial commit e9124b42d5 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
This commit is contained in:
Andrew Scott
2022-01-28 16:53:39 -08:00
committed by Jessica Janiuk
parent 94c9e47dbe
commit 47c02caa29
3 changed files with 5 additions and 3 deletions
@@ -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[];
}
@@ -22,7 +22,6 @@ import {getTemplateIdentifiers} from './template';
*/
export function generateAnalysis(context: IndexingContext): Map<DeclarationNode, IndexedComponent> {
const analysis = new Map<DeclarationNode, IndexedComponent>();
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<DeclarationNode,
}
const {identifiers, errors} = getTemplateIdentifiers(boundTemplate);
analysisErrors.push(...errors);
analysis.set(declaration, {
name,
selector,
@@ -58,6 +56,7 @@ export function generateAnalysis(context: IndexingContext): Map<DeclarationNode,
isInline: templateMeta.isInline,
file: templateFile,
},
errors,
});
});
@@ -54,7 +54,8 @@ runInEachFileSystem(() => {
usedComponents: new Set(),
isInline: false,
file: new ParseSourceFile('<div>{{foo}}</div>', decl.getSourceFile().fileName),
}
},
errors: [],
});
});