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:

committed by
Alex Rickabaugh

parent
446e3573e3
commit
b0c1282fbe
@ -197,4 +197,26 @@ describe('template variable assignment migration', () => {
|
||||
|
||||
expect(warnOutput.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should be able to report multiple templates within the same source file', () => {
|
||||
writeFile('/index.ts', `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
template: '<ng-template let-one><a (sayHello)="one=true"></a></ng-template>',
|
||||
})
|
||||
export class MyComp {}
|
||||
|
||||
@Component({
|
||||
template: '<ng-template let-two><b (greet)="two=true"></b></ng-template>',
|
||||
})
|
||||
export class MyComp2 {}
|
||||
`);
|
||||
|
||||
runMigration();
|
||||
|
||||
expect(warnOutput.length).toBe(2);
|
||||
expect(warnOutput[0]).toMatch(/^⮑ {3}index.ts@5:56: Found assignment/);
|
||||
expect(warnOutput[1]).toMatch(/^⮑ {3}index.ts@10:53: Found assignment/);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user