Class requires Angular annotation even when abstract.
See original GitHub issueAngular 10.0.0 build yields
NG2007: Class is using Angular features but is not decorated while class is marked as abstract.
export abstract class B {}
@Injectable({...})
export class A extends B {}
CLI should be able to compile, as did earlier versions.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:13
- Comments:38 (15 by maintainers)
Top Results From Across the Web
Missing @Directive()/@Component() decorator migration
This migration adds an empty @Directive() decorator to undecorated base classes that: Use Angular features; Are extended by directives or components.
Read more >angular - Angular4 Components inheritance with abstract class
There's no need to add @Component() annotations to abstract classes or register them to any module. It could be that there's something wrong ......
Read more >Using Abstract Classes As Dependency-Injection Tokens With ...
Ben Nadel looks at how to use an abstract class as a Dependency-Injection (DI) token in Angular 9.1.9. He uses a technique that...
Read more >Angular Dependency Injection: Complete Guide
So what exactly is dependency injection? When you are developing a smaller part of your system, like a module or a class, you...
Read more >How to Share Lifecycle Methods Between Components in ...
Sharing code between components in Angular is TOUGH. ... the problem of having to mark a component class as abstract because even without...
Read more >Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In my opinion
Component
,Directive
andInjectable
does not make any sense on anabstract class
. Clearly this error is a false positive and addingDirective
may be a workaround.@JoostK Using
abstract
classes which are meant to be extended only. The following example worked in Angular 9I think abstract classes should be excluded from the list of required annotations since it’s never meant (or be able to) to be instantiated anyway.