diff --git a/__tests-tsd__/types.test-d.ts b/__tests-tsd__/types.test-d.ts index 2fdb1cd..d099937 100644 --- a/__tests-tsd__/types.test-d.ts +++ b/__tests-tsd__/types.test-d.ts @@ -1,5 +1,5 @@ import { knex } from 'knex'; -import { expectType } from 'tsd'; +import { expectType, expectAssignable } from 'tsd'; import '../types'; import { ILengthAwarePagination, IBasePagination, IWithPagination } from '../types'; @@ -12,8 +12,17 @@ interface User { } (async () => { - expectType>( - await db('users').select('*').paginate({ + expectAssignable>( + await db('users').column('*').paginate({ + perPage: 10, + currentPage: 1, + isFromStart: true, + isLengthAware: false, + }) + ); + + expectAssignable>( + await db('users').select('*').paginate({ perPage: 10, currentPage: 1, isFromStart: true, @@ -51,6 +60,26 @@ interface User { ).pagination ); + expectType( + ( + await db('users').select('*').paginate({ + perPage: 10, + currentPage: 1, + isLengthAware: true, + }) + ).pagination + ); + + expectType( + ( + await db('users').select('*').paginate({ + perPage: 10, + currentPage: 1, + isLengthAware: true, + }) + ).data + ); + expectType( ( await db('users').select('*').paginate({ diff --git a/types.d.ts b/types.d.ts index 08e15b1..dc2324b 100644 --- a/types.d.ts +++ b/types.d.ts @@ -33,10 +33,10 @@ interface ILengthAwarePagination extends IBasePagination { declare module 'knex' { namespace Knex { - interface QueryBuilder { - paginate( + interface QueryBuilder { + paginate( params: Readonly - ): Knex.QueryBuilder>; + ): Knex.QueryBuilder>; } } }