Solvedangular Can't resolve all parameters for .... This will become an error in Angular v6.x
✔️Accepted Answer
If I can help someone... I solved my issue
I had this error. The problem for me was a missing @Inject
.
I created an InjectionToken to pass a config to my Service from the forRoot,
but I was missing the @Inject("myTokenName")
in my Service.
So when building with --aot
and --build-optimizer=true
or --build-optimizer=false
I had the warning!
After adding the @Inject
problem solved!!
Other Answers:
Having this problem too. Angular 7 complaining only when ng build is called with --prod / --aot.
Its still a warning (not an error), but its annoying to have logged. I can also confirm that its different to the duplicate tickets marked above.
I had this issue because I am using generics to reduce code duplication. Here is my original code that was causing the warning:
@Injectable()
export abstract class MyBaseClass<S> {
protected constructor(protected readonly service: S) {}
// .. some code
}
Since this class is abstract it will never be injected anywhere, thus it should not be decorated with @Injectable()
. Removing it makes compiler happy again.
If you need @Injectable
then @Inject
needs to be also provided - the solution proposed by @tonysamperi.
I confirm that the bug is still present using Angular 7, and it' still saying:
This will become an error in Angular v6.x
I had this issue because I am using generics to reduce code duplication. Here is my original code that was causing the warning:
@Injectable() export abstract class MyBaseClass<S> { protected constructor(protected readonly service: S) {} // .. some code }Since this class is abstract it will never be injected anywhere, thus it should not be decorated with
@Injectable()
. Removing it makes compiler happy again.If you need
@Injectable
then@Inject
needs to be also provided - the solution proposed by @tonysamperi.
It works, when you remove injectable decorator, then your abstract/generic class compiles successfully. Thanks.
I'm submitting a...
I have 4 classes:
classes A, C and D are used as Services and correctly added to the
providers
list of my module. Class B is NOT used as a service.Current behavior
Everything works fine but I got this warning:
Expected behavior
Not sure if some action on my side is required or this warning should not be displayed.
Demo
Clone the repository, run
npm install
and thenng build --prod
. You'll see the warning.https://github.com/ShinDarth/angular-test/
FrancescoBorzi/angular-test@4101bc5
Environment