reyesoft / ngx-jsonapi

JSON API client library for Angular 5+ 👌 :: Production Ready 🚀
https://ngx-jsonapi.reyesoft.com/
MIT License
101 stars 52 forks source link

Error when extending service that uses @Autoregister decorator #144

Closed maxi7587 closed 5 years ago

maxi7587 commented 5 years ago

When extending a service that uses the @Autoregister decorator, the decorator overrides the constructor of the new service (that extends the original service), so new methods are erased from the new class.

Example:

@Autoregister
@Injectable
export class SomeService {
   public someMethod() { return; }
}

@Autoregister
@Injectable
export class SomeNewService extends SomeService {
    public newMethod() { return; }
}

In this case, the method newMethod can't be accessed in the service instance.

maxi7587 commented 5 years ago

Extended services should not use @Autoregister... they should use register method instead