简体   繁体   中英

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

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>

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM