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 a71944c421..8ed454f336 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 @@ -1187,7 +1187,10 @@ function tcbGetDirectiveInputs( // To determine which of directive's inputs are unset, we keep track of the set of field names // that have not been seen yet. A field is removed from this set once a binding to it is found. - const unsetFields = new Set(propMatch.values()); + // Note: it's actually important here that `propMatch.values()` isn't used, as there can be + // multiple fields which share the same property name and only one of them will be listed as a + // value in `propMatch`. + const unsetFields = new Set(Object.keys(inputs)); el.inputs.forEach(processAttribute); el.attributes.forEach(processAttribute); diff --git a/packages/compiler-cli/test/ngtsc/template_typecheck_spec.ts b/packages/compiler-cli/test/ngtsc/template_typecheck_spec.ts index 543f106218..97641b203d 100644 --- a/packages/compiler-cli/test/ngtsc/template_typecheck_spec.ts +++ b/packages/compiler-cli/test/ngtsc/template_typecheck_spec.ts @@ -174,6 +174,33 @@ export declare class AnimationEvent { .toEqual(`Argument of type 'string' is not assignable to parameter of type 'number'.`); }); + it('should support one input property mapping to multiple fields', () => { + env.write('test.ts', ` + import {Component, Directive, Input, NgModule} from '@angular/core'; + + @Directive({ + selector: '[dir]', + }) + export class Dir { + + @Input('propertyName') fieldA!: string; + @Input('propertyName') fieldB!: string; + } + + @Component({ + selector: 'test-cmp', + template: '
', + }) + export class Cmp {} + + @NgModule({declarations: [Dir, Cmp]}) + export class Module {} + `); + + const diags = env.driveDiagnostics(); + expect(diags.length).toBe(0); + }); + it('should check event bindings', () => { env.tsconfig({fullTemplateTypeCheck: true, strictOutputEventTypes: true}); env.write('test.ts', `