Angular 10: Class is using Angular features but is not decorated
See original GitHub issueI am trying to use this library with Angular 10. I get the following error when I try to build the Angular project:
src/directives/generated/value-accessor.ts:4:14 - error NG2007: Class is using Angular features but is not decorated. Please add an explicit Angular decorator.
4 export class ValueAccessor implements ControlValueAccessor {
This new behaviour seems to have been introduced by https://github.com/angular/angular/pull/36921.
Manually appending @Directive() to ValueAccessor fixes the issue:
import {Directive, ElementRef, HostListener} from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
@Directive()
export class ValueAccessor implements ControlValueAccessor {
// ...
I wanted to create a pull request for that, but @Directive changed between Angular 9 and Angular 10.
In Angular 9, @Directive() requires a selector attribute, while in Angular 10, you can pass it without any option.
So maybe Stencil needs to be aware of the Angular version effectively used?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:8
Top Results From Across the Web
Class is using Angular features but is not decorated. Please ...
From Angular 10, you can fix this issue by adding the decorator @Injectable() to your abstract base class like ...
Read more >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 >Answer: Class is using Angular features but is not decorated ...
You'll need to add a @Component decorator to that base class (which should probably also be declared abstract ).
Read more >class is using angular features but is not ... - Code Grepper
1. After angular 10, all the class with service function needs to inject: ; 2. @Injectable() //reason to satisfy the compiler.
Read more >Class is using Angular features but is not decorated ... - iTecNote
You'll need to add a @Component decorator to that base class (which should probably also be declared abstract ). ... For Angular 10+,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top 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
Same story…
Angular team, please let us write normal abstract/base classes. This limitation looks ridiculous. It forces me to decorate my abstract class just because it implements
OnDestroyinterface.And even more, compiler emits this error only in normal mode. When I run the prod build, everything’s fine.
For me it occurs on an abstract class.