Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error parsing dependencies if a service has an inherited constructor. #140

Open
P4 opened this issue Jul 26, 2021 · 0 comments
Open

error parsing dependencies if a service has an inherited constructor. #140

P4 opened this issue Jul 26, 2021 · 0 comments

Comments

@P4
Copy link

P4 commented Jul 26, 2021

I was trying to use the tool on my project, sadly it errors out on a random service with a rather unhelpful error message:
image

More useful info from the terminal:

Error while responding to a message AssertionError [ERR_ASSERTION]: Invalid depenancies in "TestService".
    at new AssertionError (internal/assert/assertion_error.js:433:11)
    at assertDeps (/tmp/.mount_ngrev-5UpDxv/resources/app/node_modules/ngast/ngast.bundle.js:147:19)
    at InjectableSymbol.getDependencies (/tmp/.mount_ngrev-5UpDxv/resources/app/node_modules/ngast/ngast.bundle.js:2404:13)
    at ProviderState.getData (/tmp/.mount_ngrev-5UpDxv/resources/app/src/electron/states/provider.state.js:63:24)
    at /tmp/.mount_ngrev-5UpDxv/resources/app/src/electron/states/app.state.js:73:31
    at Array.forEach (<anonymous>)
    at AppState.getData (/tmp/.mount_ngrev-5UpDxv/resources/app/src/electron/states/app.state.js:72:21)
    at /tmp/.mount_ngrev-5UpDxv/resources/app/src/electron/parser.js:159:40
    at EventEmitter.<anonymous> (/tmp/.mount_ngrev-5UpDxv/resources/app/src/electron/helpers/process.js:21:17)

The service that fails in the real project does not have its own constructor, instead it uses the constructor from its base class, which is also marked with Injectable (AFAIK that's legal when using Ivy, the app works).

Here's a minimal example that causes the same error when added to a "Hello world" app generated with angular CLI:
generate a service using ng g service test, then replace contents of test.service.ts with the following:

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable()
export class BaseTestService {
  constructor(http: HttpClient) { }
}

@Injectable({
  providedIn: 'root'
})
export class TestService extends BaseTestService {
}

Lastly, add the service as a dependency to AppComponent:

export class AppComponent {
  constructor(private testService: TestService) {
  }
} 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant