fix(ivy): ensure factory statements are emitted correctly (#25425)
A small bug caused base factory variable statements for @Component to not be emitted properly. At the same time as this is fixed, those statements are now emitted as const. PR Close #25425
This commit is contained in:
parent
82e2725154
commit
b40c437379
|
@ -165,7 +165,7 @@ export class ComponentDecoratorHandler implements DecoratorHandler<R3ComponentMe
|
|||
return {
|
||||
name: 'ngComponentDef',
|
||||
initializer: res.expression,
|
||||
statements: [],
|
||||
statements: res.statements,
|
||||
type: res.type,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -181,7 +181,8 @@ export function compileFactoryFunction(meta: R3FactoryMetadata):
|
|||
} else {
|
||||
const baseFactory = o.variable(`ɵ${meta.name}_BaseFactory`);
|
||||
const getInheritedFactory = o.importExpr(R3.getInheritedFactory);
|
||||
const baseFactoryStmt = baseFactory.set(getInheritedFactory.callFn([meta.type])).toDeclStmt();
|
||||
const baseFactoryStmt = baseFactory.set(getInheritedFactory.callFn([meta.type]))
|
||||
.toDeclStmt(o.INFERRED_TYPE, [o.StmtModifier.Final]);
|
||||
statements.push(baseFactoryStmt);
|
||||
|
||||
// There is no constructor, use the base class' factory to construct typeForCtor.
|
||||
|
@ -205,8 +206,8 @@ export function compileFactoryFunction(meta: R3FactoryMetadata):
|
|||
if (meta.delegate.isEquivalent(meta.type)) {
|
||||
throw new Error(`Illegal state: compiling factory that delegates to itself`);
|
||||
}
|
||||
const delegateFactoryStmt =
|
||||
delegateFactory.set(getFactoryOf.callFn([meta.delegate])).toDeclStmt();
|
||||
const delegateFactoryStmt = delegateFactory.set(getFactoryOf.callFn([meta.delegate]))
|
||||
.toDeclStmt(o.INFERRED_TYPE, [o.StmtModifier.Final]);
|
||||
|
||||
statements.push(delegateFactoryStmt);
|
||||
const r = makeConditionalFactory(delegateFactory.callFn([]));
|
||||
|
|
Loading…
Reference in New Issue