Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added promisable and better types #5222

Merged
merged 5 commits into from Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions test-tsd/querybuilder.test-d.ts
Expand Up @@ -11,17 +11,17 @@ const knexInstance = knex(clientConfig);
declare module '../types' {
namespace Knex {
interface QueryBuilder {
customSelect<TRecord, TResult>(
customSelect<TRecord extends {}, TResult> (
value: number
): Knex.QueryBuilder<TRecord, TResult>;
): Promise<Knex.QueryBuilder<TRecord, TResult>>;
}
}
}

knex.QueryBuilder.extend('customSelect', function (value: number) {
return this.select(this.client.raw(`${value} as value`));
return new Promise((r) => r(this.select(this.client.raw(`${value} as value`))));
});

const main = async () => {
expectType<number[]>(await knexInstance('users').customSelect<any, number[]>(42));
expectType<number[]>(await (await knexInstance('users').customSelect<any, number[]>(42)));
};