I have a typescript IntelliSense problem.
I want to add a new method to knex in typescript as written in the docs (search "Extending Query Builder").
So I create knex.d.ts in @types folder with this content:
// knex.d.ts
import { Knex as KnexOriginal } from 'knex';
declare module 'knex' {
namespace Knex {
interface QueryBuilder {
customSelect<TRecord, TResult>(value: number): KnexOriginal.QueryBuilder<TRecord, TResult>;
}
}
}
And add this code to my tsconfig.base.json:
// tsconfig.json
{
"compilerOptions": {
"typeRoots": [ "node_modules/@types", "@types" ],
}
}
But I got an error in typescript:
Property 'customSelect' does not exist on type 'Knex<any, unknown[]>'.
The error is point to the foo-lib
at authDb.customSelect(); and authDb.select().customSelect();.
What I am doing wrong??
I create a repo to reproduce the problem: https://github.com/wizardnet972/nx-knex