Sandro Rey
Sandro Rey

Reputation: 2989

error Missing return type on function in nodejs

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**

Upvotes: 1

Views: 1870

Answers (2)

salah3x
salah3x

Reputation: 231

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>

Upvotes: 1

carboleda
carboleda

Reputation: 81

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
}

Upvotes: 1

Related Questions