Inheritance class: error TS2554: Expected 5 Arguments, but got 0

Asked

Viewed 177 times

1

I have two classes in Angular 4 that are related by inheritance, however in doing the build makes a mistake:

error TS2554: Expected 5 Arguments, but got 0.

Pai Class:

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

Classe Filho:

constructor(private localStorage: LocalStorageService, 
            protected jwtToken: JwtTokenService, 
            protected http: Http) {
    super();
    this.check = this.jwtToken.token ? true : false;
}

1 answer

2


In the daughter class is calling the super(). How many arguments are you passing on it? Zero!. In the mother class the constructor has 5 parameters. If it has these parameters, you need to pass all of them, passing zero is wrong. I can’t say what should go through at all, but something like that:

super(http, /* alguma coisa aqui */, jwtToken, /* alguma coisa aqui */, loadingService);

I put in the Github for future reference.

  • Thanks, but in the previous versions it was not necessary because no?

  • It was. It makes no sense not to be required, let alone change from nothing.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.