kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
10.71k stars 271 forks source link

Missing stream typing in MysqlDialect #73

Closed kokororin closed 2 years ago

kokororin commented 2 years ago

MysqlDialect missing stream option typings. But it works with @ts-ignore

Example usage:

import { Client } from 'ssh2';
import mysql2 from 'mysql2';

const client = new Client();
const ssh = client.connect({
  host: config.server_tunnel.dstHost,
  port: 22,
  username: config.server_tunnel.username,
  privateKey: config.server_tunnel.privateKey
});

ssh.forwardOut('127.0.0.1', 12345, 'remote.host.com', 3306, (err, stream) => {
   mysql2.createConnection({
    user: config.database.username,
    password: config.database.password,
    database: config.database.database,
    stream: stream,
    host: 'remote.host.com'
  });

  const db = new Kysely<any>({
   // Works with ts-ignore
    dialect: new MysqlDialect({
      stream,
      database: config.database.database
    })
  });

});
koskimas commented 2 years ago

The stream property doesn't exist in the mysql2 connection options either https://github.com/sidorares/node-mysql2/blob/master/typings/mysql/lib/Connection.d.ts#L12

kokororin commented 2 years ago

VSCode bring me to this file: https://github.com/sidorares/node-mysql2/blob/master/index.d.ts#L174

koskimas commented 2 years ago

Oh, ok. I'll change Kysely to use that interface instead.

koskimas commented 2 years ago

@kokororin 0.17.3 now has the stream property