mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
+5
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+16
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user