import { knex } from '../types'; import { expectType } from 'tsd'; import { clientConfig } from './common'; const knexInstance = knex(clientConfig); // Use: // import { Knex } from 'knex' // This would be `declare module 'knex'` in runtime code declare module '../types' { namespace Knex { interface QueryBuilder { customSelect( value: number ): Promise>; } } } knex.QueryBuilder.extend('customSelect', function (value: number) { return new Promise((r) => r(this.select(this.client.raw(`${value} as value`))) ); }); const main = async () => { expectType( await await knexInstance('users').customSelect(42) ); };