diff --git a/packages/compiler/src/render3/r3_factory.ts b/packages/compiler/src/render3/r3_factory.ts index 43d910babb6..a6f73dba1ba 100644 --- a/packages/compiler/src/render3/r3_factory.ts +++ b/packages/compiler/src/render3/r3_factory.ts @@ -133,7 +133,7 @@ export function compileFactoryFunction(meta: R3FactoryMetadata): R3CompiledExpre function makeConditionalFactory(nonCtorExpr: o.Expression): o.ReadVarExpr { const r = o.variable('__ngConditionalFactory__'); - body.push(new o.DeclareVarStmt(r.name, o.NULL_EXPR, o.INFERRED_TYPE)); + body.push(new o.DeclareVarStmt(r.name, o.NULL_EXPR, o.DYNAMIC_TYPE)); const ctorStmt = ctorExpr !== null ? r.set(ctorExpr).toStmt() @@ -188,7 +188,13 @@ export function compileFactoryFunction(meta: R3FactoryMetadata): R3CompiledExpre // There is a base factory variable so wrap its declaration along with the factory function into // an IIFE. factoryFn = o - .arrowFn([], [new o.DeclareVarStmt(baseFactoryVar.name!), new o.ReturnStatement(factoryFn)]) + .arrowFn( + [], + [ + new o.DeclareVarStmt(baseFactoryVar.name!, undefined, o.DYNAMIC_TYPE), + new o.ReturnStatement(factoryFn), + ], + ) .callFn([], /* sourceSpan */ undefined, /* pure */ true); } diff --git a/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.ts b/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.ts index 714d26951d6..2d481ee1ece 100644 --- a/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.ts +++ b/packages/compiler/src/template/pipeline/src/phases/i18n_const_collection.ts @@ -246,7 +246,7 @@ function collectMessage( // Sort the params for consistency with TemaplateDefinitionBuilder output. messageOp.params = new Map([...messageOp.params.entries()].sort()); - const mainVar = o.variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX)); + const mainVar = o.variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX), o.DYNAMIC_TYPE); // Closure Compiler requires const names to start with `MSG_` but disallows any other // const to start with `MSG_`. We define a variable starting with `MSG_` just for the // `goog.getMsg` call diff --git a/packages/compiler/src/template/pipeline/src/phases/reify.ts b/packages/compiler/src/template/pipeline/src/phases/reify.ts index 3b064be9448..34a190eb4a3 100644 --- a/packages/compiler/src/template/pipeline/src/phases/reify.ts +++ b/packages/compiler/src/template/pipeline/src/phases/reify.ts @@ -342,7 +342,12 @@ function reifyCreateOperations(unit: CompilationUnit, ops: ir.OpList( op, ir.createStatementOp( - new o.DeclareVarStmt(op.variable.name, op.initializer, undefined, o.StmtModifier.Final), + new o.DeclareVarStmt( + op.variable.name, + op.initializer, + o.DYNAMIC_TYPE, + o.StmtModifier.Final, + ), ), ); break; @@ -693,7 +698,12 @@ function reifyUpdateOperations(unit: CompilationUnit, ops: ir.OpList( op, ir.createStatementOp( - new o.DeclareVarStmt(op.variable.name, op.initializer, undefined, o.StmtModifier.Final), + new o.DeclareVarStmt( + op.variable.name, + op.initializer, + o.DYNAMIC_TYPE, + o.StmtModifier.Final, + ), ), ); break;