Port missing in 'ConnectionConfig' TypeScript definition?
See original GitHub issueEnvironment
Knex version: 0.18.4 Database + version: Postgres 9.5 OS: macOS 10.14
If issue is about TypeScript definitions, tag @lorefnon.
Bug
(I’m opening this issue under the assumption that I’m supposed to use ‘ConnectionConfig’ to type my PG connection config object. If my assumption is wrong, then there seems to be a missing type definition for Postgres connection config?)
The pg
library accepts a port
key, and passing the port
key to knex indeed works:
import Knex from 'knex';
// TS compiler complaining about 'port' not being in the type definition
const pgConnectionConfig: Knex.ConnectionConfig = {
port: 1234,
host: 'myhost'
user: 'myuser'
password: 'mypw'
database: 'mydb'
};
// Attempts to connect to 'myhost' on port 1234
const k = Knex({
client: 'pg',
connection: pgConnectionConfig,
...
});
but this key is missing in the ConnectionConfig
interface.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Port missing in 'ConnectionConfig' TypeScript definition? #3367
(I'm opening this issue under the assumption that I'm supposed to use 'ConnectionConfig' to type my PG connection config object. If my ...
Read more >Argument of type '{ host: string | undefined; user - Stack Overflow
Here for each K in "host" | "username" | "port" typescript calculates ConfigUndefined[K] indexed access type and with the help of Exclude ...
Read more >@types/knex | Yarn - Package Manager
This is a stub types definition for knex (https://github.com/tgriesser/knex). knex provides its own type definitions, so you don't need @types/knex installed!
Read more >node-mssql | Microsoft SQL Server client for Node.js
Providing a different connection config to the connect() function will not ... const host = server.address().address const port = server.address().port ...
Read more >Installation | Knex.js
Installation #. Knex can be used as an SQL query builder in both Node.JS and the browser, limited to WebSQL's constraints (like the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Released in 0.20.1
@kibertoad Just submitted a PR for a separate
PgConnectionConfig
interface – I’m still unsure about what driverConnectionConfig
is meant for…