diff --git a/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts b/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts index c8627b3823..ed37665032 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/src/type_check_block.ts @@ -857,6 +857,11 @@ function tcbGetDirectiveInputs( * a matching binding. */ function processAttribute(attr: TmplAstBoundAttribute | TmplAstTextAttribute): void { + // Skip non-property bindings. + if (attr instanceof TmplAstBoundAttribute && attr.type !== BindingType.Property) { + return; + } + // Skip the attribute if the directive does not have an input for it. if (!propMatch.has(attr.name)) { return; diff --git a/packages/compiler-cli/src/ngtsc/typecheck/test/type_check_block_spec.ts b/packages/compiler-cli/src/ngtsc/typecheck/test/type_check_block_spec.ts index cdad5d93de..d2bac46b00 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/test/type_check_block_spec.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/test/type_check_block_spec.ts @@ -129,6 +129,22 @@ describe('type check blocks', () => { expect(block).not.toContain('.style = '); }); + it('should only apply property bindings to directives', () => { + const TEMPLATE = ` +
+ `; + const DIRECTIVES: TestDeclaration[] = [{ + type: 'directive', + name: 'Dir', + selector: '[dir]', + inputs: {'color': 'color', 'strong': 'strong', 'enabled': 'enabled'}, + }]; + const block = tcb(TEMPLATE, DIRECTIVES); + expect(block).toContain( + 'var _t2 = Dir.ngTypeCtor({ color: (null as any), strong: (null as any), enabled: (null as any) });'); + expect(block).toContain('"blue"; false; true;'); + }); + it('should generate a circular directive reference correctly', () => { const TEMPLATE = `