Inherited class: error TS2554: Expected 5 arguments, but got 0

1

I have two classes in Angular 4 that are related by inheritance, however doing build gives an error:

  

error TS2554: Expected 5 arguments, but got 0.

Parent class:

constructor(protected http: Http,
            private router: Router,
            protected jwtToken: JwtTokenService,
            private loadingService: LoadingService,
            protected requestOptions: DefaultRequestOptionsService) {}

Son Class:

constructor(private localStorage: LocalStorageService, 
            protected jwtToken: JwtTokenService, 
            protected http: Http) {
    super();
    this.check = this.jwtToken.token ? true : false;
}
    
asked by anonymous 26.07.2018 / 16:18

1 answer

2

In the child class you are calling super() . How many arguments are going on in him? Zero!. In the parent class the constructor has 5 parameters. If it has these parameters, you need to pass them all, passing zero is wrong. I can not state what should happen at all, but something like this:

super(http, /* alguma coisa aqui */, jwtToken, /* alguma coisa aqui */, loadingService);
    
26.07.2018 / 19:21