fix(ivy): ngtsc directive compilation should use shared ConstantPool (#25620)
This fixes a bug in ngtsc where each @Directive was compiled using a separate ConstantPool. This resulted in two issues: * Directive constants were not shared across the file * Extra statements from directive compilation were dropped instead of added to the file This commit fixes both issues and adds a test to verify @Directive is working properly. PR Close #25620
This commit is contained in:

committed by
Matias Niemelä

parent
22d58fc89b
commit
eb1fe19088
@ -45,13 +45,13 @@ export class DirectiveDecoratorHandler implements DecoratorHandler<R3DirectiveMe
|
||||
return {analysis};
|
||||
}
|
||||
|
||||
compile(node: ts.ClassDeclaration, analysis: R3DirectiveMetadata): CompileResult {
|
||||
const pool = new ConstantPool();
|
||||
compile(node: ts.ClassDeclaration, analysis: R3DirectiveMetadata, pool: ConstantPool):
|
||||
CompileResult {
|
||||
const res = compileDirectiveFromMetadata(analysis, pool, makeBindingParser());
|
||||
return {
|
||||
name: 'ngDirectiveDef',
|
||||
initializer: res.expression,
|
||||
statements: pool.statements,
|
||||
statements: res.statements,
|
||||
type: res.type,
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user