1

I have this function, but when compiling the app.

public async test(options?: { engine?: Config }): Promise<any> {
        const hostel = new Service({
            list: this.servicesList,
            createService: list => this.dbService.buildService(list)
        });
     return hostel.load();
    }

I have this error:

26:27  error  Missing return type on function                             
@typescript-eslint/explicit-function-return-type.

on this line createService: list => this.dbService.buildService(list) text**

2
  • Basically you have one function which doesn't have return type on 26th row
    – hurricane
    Mar 31, 2020 at 21:11
  • The error described is that you have declared a return type of Promise<any> but are not returning anything from your test method. Mar 31, 2020 at 21:26

2 Answers 2

1

You only should add return in the function

public async test(options?: { engine?: Config }): Promise<any> {
   const hostel = new Service({
      list: this.servicesList,
      createService: list => this.dbService.buildService(list)
   });
   return hostel;// Missing line
}
1

As mentioned by Andrew in the comments, you are not returning anything from the function. If that's what you expect, just change Promise<any> to Promise<void>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.