General:
I'm writing a type declarations file for a Javascript package. The root export is a function that optionally accepts an instance of a third party module. The third party module is not a declared dependency in package.json because I want users to be able to use their preferred version of the third party dependency. I cannot figure out how to specify the type of the argument.
Specific:
Sqorn Postgres is a Javascript library that builds and executes SQL queries. The execution functionality only works if you pass the Node Postgres module as an argument. Node Postgres is NOT a declared dependency in Sqorn Postgres's package.json. Node Postgres has typings on Definitely Typed.
Sqorn Postgres is initialized as follows:
const sqorn = require('sqorn-pg')
const pg = require('pg')
const pool = new pg.Pool()
const sq = sqorn({ pg, pool })
Sqorn Postgres' current Type Declarations exports the following function.
declare function sqorn({ pg, pool }: { pg: any, pool: any }): sqorn.sq;
I'd like to use specific types for the pg
and pool
arguments, but cannot figure out how.