jakajancar / pgc4d

A full-featured PostgreSQL Client for Deno
MIT License
21 stars 3 forks source link

URL is not assignable to string #6

Closed nakleiderer closed 4 years ago

nakleiderer commented 4 years ago

I'm receiving the following type error while trying to use this library. This error occurs before any of my code is executed.

Error

error: TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname
                 ~~~
    at https://deno.land/std@0.53.0/path/win32.ts:911:18

TS2345 [ERROR]: Argument of type 'string | URL' is not assignable to parameter of type 'string'.
  Type 'URL' is not assignable to type 'string'.
  return new URL(url).pathname;
                 ~~~
    at https://deno.land/std@0.53.0/path/posix.ts:433:18

Found 2 errors.

Reproduction Steps

Create a repro.ts file with the following contents and execute deno run --allow-all --unstable repro.ts

// repro.ts
import { connectPg } from 'https://deno.land/x/pgc4d@v1.2.0/src/mod.ts'

const config = {
    hostname:"localhost",
    username: "root",
    password: "PASSWORD",
    database: "dev",
    port: 5432
};

const client = await connectPg(config)

try {
    const result = await client.query("SELECT * from users LIMIT 1;");
    console.dir(result.rows);
} finally {
    client.close();
}

Environment

jakajancar commented 4 years ago

@nakleiderer This seems to have been a regression in Deno, which broke older std (v0.53.0) that pgc4d was depending on.

I have upgrade std to v0.63.0 and Deno (in CI) to v1.2.2. Please upgrade to pgc4d 1.3.0 and it should work for you.

Thanks for the report!