Skip to content

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

@P4

Description

@P4

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) {
  }
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions