mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00: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:
parent
c2f7403774
commit
0ea27f4e65
4 changed files with 57 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue