refactor(compiler): implement let declarations in render3 ast (#55848)

Introduces a new `LetDeclaration` into the Render3 AST, simiarly to the HTML AST, and adds an initial integration into the various visitors.

PR Close #55848
This commit is contained in:
Kristiyan Kostadinov
2024-05-20 22:04:18 +02:00
committed by Jessica Janiuk
parent 1ae06e4fc6
commit 9eef041211
12 changed files with 127 additions and 5 deletions
@@ -28,6 +28,7 @@ import {
TmplAstForLoopBlockEmpty,
TmplAstIfBlock,
TmplAstIfBlockBranch,
TmplAstLetDeclaration,
TmplAstNode,
TmplAstRecursiveVisitor,
TmplAstReference,
@@ -351,6 +352,10 @@ class TemplateVisitor extends TmplAstRecursiveVisitor {
this.visitAll(block.children);
}
override visitLetDeclaration(decl: TmplAstLetDeclaration): void {
this.visitExpression(decl.value);
}
/** Creates an identifier for a template element or template node. */
private elementOrTemplateToIdentifier(
node: TmplAstElement | TmplAstTemplate,
@@ -27,6 +27,7 @@ import {
TmplAstIcu,
TmplAstIfBlock,
TmplAstIfBlockBranch,
TmplAstLetDeclaration,
TmplAstNode,
TmplAstRecursiveVisitor,
TmplAstReference,
@@ -264,6 +265,10 @@ class TemplateVisitor<Code extends ErrorCode>
this.visitAllNodes(block.children);
}
visitLetDeclaration(decl: TmplAstLetDeclaration): void {
this.visitAst(decl.value);
}
getDiagnostics(template: TmplAstNode[]): NgTemplateDiagnostic<Code>[] {
this.diagnostics = [];
this.visitAllNodes(template);