I've been grappling with this code snippet for a while now. It was originally written in JavaScript a few months back, but recently I decided to delve into TypeScript. However, I'm struggling to understand how data types are properly defined in TypeScript. Does anyone have any tips or resources that could help me resolve this issue?
Here's the specific error message:
src/utils/pool.ts:5:5 - error TS2322: Type '"" | { rejectUnauthorized: false; } | undefined' is not assignable to type 'boolean | ConnectionOptions | undefined'. Type '""' is not assignable to type 'boolean | ConnectionOptions | undefined'.
5 ssl: process.env.PGSSLMODE && { rejectUnauthorized: false },
Thank you in advance!
import { Pool, PoolConfig } from 'pg';
export const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: process.env.PGSSLMODE && { rejectUnauthorized: false },
})
pool.on('connect', ()=> console.log('Postgres connected'))