|
1 |
| -import Knex from '../types'; |
| 1 | +import { knex, Knex } from '../types'; |
2 | 2 | import { clientConfig } from './common';
|
3 | 3 | import { expectType } from 'tsd';
|
4 | 4 |
|
5 |
| -const knex = Knex(clientConfig); |
| 5 | +const knexInstance = knex(clientConfig); |
6 | 6 |
|
7 | 7 | interface User {
|
8 | 8 | id: number;
|
@@ -57,39 +57,39 @@ declare module '../types/tables' {
|
57 | 57 | const main = async () => {
|
58 | 58 | // # Select:
|
59 | 59 |
|
60 |
| - expectType<any[]>(await knex('users')); |
| 60 | + expectType<any[]>(await knexInstance('users')); |
61 | 61 |
|
62 | 62 | // This test (others similar to it) may seem useless but they are needed
|
63 | 63 | // to test for left-to-right inference issues eg: #3260
|
64 |
| - expectType<User[]>(await knex('users')); |
65 |
| - expectType<User[]>(await knex<User>('users')); |
66 |
| - expectType<User[]>(await knex('users_inferred')); |
67 |
| - expectType<User[]>(await knex('users_composite')); |
| 64 | + expectType<User[]>(await knexInstance('users')); |
| 65 | + expectType<User[]>(await knexInstance<User>('users')); |
| 66 | + expectType<User[]>(await knexInstance('users_inferred')); |
| 67 | + expectType<User[]>(await knexInstance('users_composite')); |
68 | 68 |
|
69 |
| - expectType<any[]>(await knex('users').select('id')); |
70 |
| - expectType<Partial<User>[]>(await knex('users').select('id')); |
| 69 | + expectType<any[]>(await knexInstance('users').select('id')); |
| 70 | + expectType<Partial<User>[]>(await knexInstance('users').select('id')); |
71 | 71 |
|
72 |
| - expectType<Pick<User, 'id'>[]>(await knex('users_inferred').select('id')); |
73 |
| - expectType<Pick<User, 'id'>[]>(await knex('users_composite').select('id')); |
| 72 | + expectType<Pick<User, 'id'>[]>(await knexInstance('users_inferred').select('id')); |
| 73 | + expectType<Pick<User, 'id'>[]>(await knexInstance('users_composite').select('id')); |
74 | 74 | expectType<Pick<User, 'id' | 'age'>[]>(
|
75 |
| - await knex('users_inferred').select('id').select('age') |
| 75 | + await knexInstance('users_inferred').select('id').select('age') |
76 | 76 | );
|
77 | 77 |
|
78 | 78 | expectType<Pick<User, 'id' | 'age'>[]>(
|
79 |
| - await knex('users_composite').select('id').select('age') |
| 79 | + await knexInstance('users_composite').select('id').select('age') |
80 | 80 | );
|
81 | 81 |
|
82 | 82 | expectType<Pick<User, 'id' | 'age'>[]>(
|
83 |
| - await knex('users_inferred').select('id', 'age') |
| 83 | + await knexInstance('users_inferred').select('id', 'age') |
84 | 84 | );
|
85 | 85 | expectType<Pick<User, 'id' | 'age'>[]>(
|
86 |
| - await knex('users_composite').select('id', 'age') |
| 86 | + await knexInstance('users_composite').select('id', 'age') |
87 | 87 | );
|
88 | 88 |
|
89 | 89 | expectType<Pick<User, 'id'> | undefined>(
|
90 |
| - await knex.first('id').from('users_inferred') |
| 90 | + await knexInstance.first('id').from('users_inferred') |
91 | 91 | );
|
92 | 92 | expectType<Pick<User, 'id'> | undefined>(
|
93 |
| - await knex.first('id').from('users_composite') |
| 93 | + await knexInstance.first('id').from('users_composite') |
94 | 94 | );
|
95 | 95 | };
|
0 commit comments