diff --git a/src/client.ts b/src/client.ts index 042ff71..4b65082 100644 --- a/src/client.ts +++ b/src/client.ts @@ -12,7 +12,7 @@ import { } from 'node:tls'; import { EventEmitter } from 'node:events'; -import { Defaults, Environment } from './defaults.js'; +import { Defaults } from './defaults.js'; import * as logger from './logging.js'; import { postgresqlErrorCodes } from './errors.js'; @@ -147,7 +147,7 @@ interface PreFlightQueue { bind: Bind | null; } -const DEFAULTS = new Defaults(env as unknown as Environment); +const DEFAULTS = new Defaults(env as Record); export type EventMap< T = { diff --git a/src/defaults.ts b/src/defaults.ts index c03053d..8616c1b 100644 --- a/src/defaults.ts +++ b/src/defaults.ts @@ -4,7 +4,7 @@ import { userInfo } from 'node:os'; * * See {@link https://www.postgresql.org/docs/current/libpq-envars.html} for a detailed description. */ -export interface Environment { +export type Environment = keyof { PGCLIENTENCODING: string; PGCONNECT_TIMEOUT: string; PGDATABASE: string; @@ -23,7 +23,7 @@ function secToMsec(value?: number) { export class Defaults { constructor( - env: Environment, + env: Partial>, readonly host = env.PGHOST || 'localhost', readonly port = parseInt(env.PGPORT as string, 10) || 5432, readonly user = env.PGUSER || userInfo().username,