fix(compiler): fix detection of directive deps in JIT (#62666)

This fix also matches the implementation to the jsdoc for `hasDirectiveDependencies` "Whether any of the component's dependencies are directives"

fixes #62573

PR Close #62666
This commit is contained in:
Matthieu Riegler
2025-07-16 19:32:54 +02:00
committed by Kirill Cherkashin
parent c2625575aa
commit 8ad10fd63b
2 changed files with 30 additions and 1 deletions
+1 -1
View File
@@ -657,7 +657,7 @@ function convertDeclareComponentFacadeToMetadata(
decl.pipes && declarations.push(...convertPipeMapToMetadata(decl.pipes));
}
const hasDirectiveDependencies = declarations.every(
const hasDirectiveDependencies = declarations.some(
({kind}) =>
kind === R3TemplateDependencyKind.Directive || kind === R3TemplateDependencyKind.NgModule,
);
@@ -387,6 +387,35 @@ describe('component declaration jit compilation', () => {
});
});
it('should bind directive inputs as regular property (not DOM property) in the presence of pipes', () => {
// https://github.com/angular/angular/issues/62573
const def = ɵɵngDeclareComponent({
version: '18.0.0',
type: TestClass,
isStandalone: true,
dependencies: [
{
kind: 'directive',
type: TestDir,
selector: '[dir]',
inputs: ['dir'],
},
{
kind: 'pipe',
type: TestPipe,
name: 'test',
},
],
template: `<div [dir]="'test' | test"></div>`,
}) as ComponentDef<TestClass>;
expectComponentDef(def, {
template: functionContaining([/property[^(]*\('dir',/]),
directives: [TestDir],
pipes: [TestPipe],
});
});
it('should compile used components', () => {
const def = ɵɵngDeclareComponent({
version: '18.0.0',