diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts b/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts index e67d5bce2b..bb281fc4a6 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/directive.ts @@ -45,13 +45,13 @@ export class DirectiveDecoratorHandler implements DecoratorHandler { .toContain('function GrandChild_Factory(t) { return new (t || GrandChild)(); }'); }); + it('generates base factories for directives', () => { + writeConfig(); + write(`test.ts`, ` + import {Directive} from '@angular/core'; + + class Base {} + + @Directive({ + selector: '[test]', + }) + class Dir extends Base { + } + `); + + + const exitCode = main(['-p', basePath], errorSpy); + expect(errorSpy).not.toHaveBeenCalled(); + expect(exitCode).toBe(0); + const jsContents = getContents('test.js'); + + expect(jsContents).toContain('var ɵDir_BaseFactory = i0.ɵgetInheritedFactory(Dir)'); + }); + it('should wrap "directives" in component metadata in a closure when forward references are present', () => { writeConfig();