DEV Community

Discussion on: Build a NestJS Module for Knex.js (or other resource-based libraries) in 5 Minutes

Collapse
 
mtaylor769 profile image
Mike Taylor • Edited

Great article. I'm using Typescript and it was giving me this error in the getKnex() function:

src/next-knex/nest-knex.service.ts:40:30 - error TS2350: Only a void function can be called with the 'new' keyword.

40       this._knexConnection = new Knex(this._NestKnexOptions);
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter fullscreen mode Exit fullscreen mode

did a bit of quick research and the fix is this:

      this._knexConnection = new (Knex as any)(this._NestKnexOptions);
Enter fullscreen mode Exit fullscreen mode

Keep up the great work!

Collapse
 
umasankarswain profile image
umasankar-swain