fix(core): visit ng-let expression value in signal migration schematics

Before this fix, references to inputs inside @let statements were not
accounted for.
This commit is contained in:
tmpln 2026-04-30 14:11:28 +00:00 committed by Alex Rickabaugh
parent c2f7403774
commit 0ea27f4e65
4 changed files with 57 additions and 0 deletions

View file

@ -26,6 +26,7 @@ import {
TmplAstDeferredBlock,
TmplAstForLoopBlock,
TmplAstIfBlockBranch,
TmplAstLetDeclaration,
TmplAstNode,
TmplAstRecursiveVisitor,
TmplAstSwitchBlock,
@ -223,6 +224,10 @@ export class TemplateReferenceVisitor<
this.templateAttributeReferencedFields.push(...referencedFields);
}
}
override visitLetDeclaration(decl: TmplAstLetDeclaration): void {
this.checkExpressionForReferencedFields(decl, decl.value);
}
}
/**

View file

@ -0,0 +1,16 @@
// tslint:disable
import {Component, Input} from '@angular/core';
@Component({
template: `
@let sum = one + two;
@let three = this.three;
{{ sum }} {{ three }}
`,
})
export class MyComp {
@Input() one = 1;
@Input() two = 2;
@Input() three = 3;
}

View file

@ -1257,6 +1257,24 @@ export class MyComp {
readonly fourth = input(true);
readonly fifth = input(true);
}
@@@@@@ template_ng_let.ts @@@@@@
// tslint:disable
import {Component, input} from '@angular/core';
@Component({
template: `
@let sum = one() + two();
@let three = this.three();
{{ sum }} {{ three }}
`,
})
export class MyComp {
readonly one = input(1);
readonly two = input(2);
readonly three = input(3);
}
@@@@@@ template_object_shorthand.ts @@@@@@
// tslint:disable

View file

@ -1211,6 +1211,24 @@ export class MyComp {
readonly fourth = input(true);
readonly fifth = input(true);
}
@@@@@@ template_ng_let.ts @@@@@@
// tslint:disable
import {Component, input} from '@angular/core';
@Component({
template: `
@let sum = one() + two();
@let three = this.three();
{{ sum }} {{ three }}
`,
})
export class MyComp {
readonly one = input(1);
readonly two = input(2);
readonly three = input(3);
}
@@@@@@ template_object_shorthand.ts @@@@@@
// tslint:disable