Make types documentation more explicit

This commit is contained in:
Igor Savin 2021-03-05 14:23:47 +02:00
parent aa7121fa98
commit 8c2a25213b

View File

@ -3,7 +3,7 @@
### Upgrading to version 0.95.0+
* TypeScript type exports changed significantly. While `import Knex from 'knex';` used to import the knex instantiation function, the namespace and the interface for the knex instantiation function/object, there is now a clear distinction between them:
```
```typescript
import { knex } from 'knex' // this is a function that you call to instantiate knex
import { Knex } from 'knex' // this is a namespace, and a type of a knex object
import KnexTimeoutError = Knex.KnexTimeoutError; // this is a class from the Knex namespace
@ -12,6 +12,22 @@ const config: Knex.Config = {} // this is a type from the Knex namespace
const knexInstance: Knex = knex(config)
```
If your code looked like this:
```typescript
import knex from 'knex'
const config: knex.Config = {} // this is a type from the Knex namespace
const knexInstance = knex(config)
```
Change it to
```typescript
import { knex, Knex } from 'knex'
const config: Knex.Config = {} // this is a type from the Knex namespace
const knexInstance = knex(config)
```
* TypeScript version 4.1+ is needed when using knex types now.
* MSSQL driver was completely reworked in order to address the multitude of connection pool, error handling and performance issues. Since the new implementation uses `tedious` library directly instead of `mssql`, please replace `mssql` with `tedious` in your dependencies if you are using a MSSQL database.