steven-ferguson/knex-cleaner

Issue using with Typescript

Opened this issue · 1 comments

I'm currently dealing with the same issue, attempting to use Knex-cleaner to truncate before each test:

node: 12.13.1
knex: ^0.21.13
knex-cleaner: ^1.3.1

import knexCleaner from "knex-cleaner";
import knex from ".././config/db-config";



beforeEach(() => {
      const options = {
            mode: "truncate", // Valid options 'truncate', 'delete'
            restartIdentity: true // Used to tell PostgresSQL to reset the ID counter
            // ignoreTables: ["Dont_Del_1", "Dont_Del_2"]
      };
      return knexCleaner.clean(knex, options).then(function () {
            console.log("the database is now clean");
      });
});

Getting the error :

Argument of type 'Knex<any, unknown[]>' is not assignable to parameter of type 'Knex'.
  Property 'clone' is missing in type 'Knex<any, unknown[]>' but required in type 'Knex'.ts(2345)
knex.d.ts(216, 5): 'clone' is declared here.

Hi - I'm having the same problem. @AbdelIdir, did you find a solution for this? Thank you. :)

package.json:    "@types/knex-cleaner": "^1.3.0",
package.json:    "knex-cleaner": "^1.3.1",
package.json:    "knex": "^0.21.17",