angular-cli: Can't resolve all dependencies

🐞 bug report

Affected Package

The issue is caused by package @angular/cli

Probably by @angular-devkit/build-angular

Is this a regression?

Yes, the previous version in which this bug was not present was: ....

It was fine when I was working on @angular/cli: 8.3.6 and @angular-devkit/build-angular: 0.802.2

Description

A clear and concise description of the problem...

The problem arises when Class A extends Class B which has a constructor and Class A doesn’t specify this constructor.

Before the update it was working and after I updated my dependencies it stopped. It started alerting that “cannot resolve all dependencies”.

After I specified a constructor with super call explicitly the error vanished.

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-issue-repro2-tncgci

🔥 Exception or Error




Can't resolve all parameters for AppComponent: (?).

🌍 Your Environment

Angular Version:





     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 8.3.9
Node: 12.11.1
OS: linux x64
Angular: 8.2.10
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.803.9
@angular-devkit/build-angular      0.803.9
@angular-devkit/build-ng-packagr   0.803.9
@angular-devkit/build-optimizer    0.803.9
@angular-devkit/build-webpack      0.803.9
@angular-devkit/core               8.3.9
@angular-devkit/schematics         8.3.9
@angular/cdk                       8.2.3
@angular/cli                       8.3.9
@angular/material                  8.2.3
@angular/material-moment-adapter   8.2.3
@ngtools/webpack                   8.3.9
@schematics/angular                8.3.9
@schematics/update                 0.803.9
ng-packagr                         5.6.1
rxjs                               6.5.3
typescript                         3.4.5
webpack                            4.39.2


Anything else relevant?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 17

Most upvoted comments

No problem. I will chime in by saying that even though the workaround is fairly straight-forward it doesn’t really make sense. Why would I have to make an abstract class @Injectable(), for example? It’s never going to be injected anywhere.

I also suspect, given the low complexity of my apps and that both encountered this issue, that this is going to break many, many apps once they upgrade. I had to do so due to a security vulnerability reported by npm audit.

Edit: Even better, angular-tslint-rules flags the workaround with the following linting error: Decorator out of context for "@Injectable()"

By decorating the base class with @Injectable(), it works: https://stackblitz.com/edit/angular-issue-repro2-9kqik4

The issue that I am running into is a little different, I have a class which gets deps via constructor, and is injected only via provider. By decorating this class with @Injectable() I was able to get around the error. The weird thing is that it was working fine in prod mode.