question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Port missing in 'ConnectionConfig' TypeScript definition?

See original GitHub issue

Environment

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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kibertoadcommented, Oct 29, 2019

Released in 0.20.1

1reaction
timorthicommented, Jul 26, 2019

@kibertoad Just submitted a PR for a separate PgConnectionConfig interface – I’m still unsure about what driver ConnectionConfig is meant for…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found