refactor(core): migrations do not properly handle multiple templates in source file (#29841)

Currently if there are multiple source files within a given
TypeScript source file, only the last template in the source
file is checked as we store templates in a `Map` with the
source file paths as keys.

This is problematic as multiple templates can live within the
same source file and we therefore accidentally overwrite
existing entries in the resolved templates map.

PR Close #29841
This commit is contained in:
Paul Gschwendtner
2019-04-11 18:59:12 +02:00
committed by Alex Rickabaugh
parent 446e3573e3
commit b0c1282fbe
5 changed files with 34 additions and 10 deletions

View File

@ -33,8 +33,9 @@ export class Rule extends Rules.TypedRule {
// Analyze each resolved template and print a warning for property writes to
// template variables.
resolvedTemplates.forEach((template, filePath) => {
const nodes = analyzeResolvedTemplate(filePath, template);
resolvedTemplates.forEach(template => {
const filePath = template.filePath;
const nodes = analyzeResolvedTemplate(template);
const templateFile =
template.inline ? sourceFile : createHtmlSourceFile(filePath, template.content);