-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Why can't Pool
be inherited?
#1887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
And the definition of @types/pg-pool is wrong: /// <reference types="pg" />
export {Pool, PoolConfig } from "pg"; |
See #1541. |
I see. Would it be a solution to copy the prototype? var pool = new Pool(config)
var prototype = Object.assign(Reflect.getPrototypeOf(this), Reflect.getPrototypeOf(pool))
Reflect.setPrototypeOf(pool, prototype)
return pool |
I don’t think it should be done with const Pool = require('pg-pool')
const {Client} = require('pg')
class MyPool extends Pool {
constructor(options) {
super({Client, ...options})
}
f() {
console.log('...')
}
} |
pg-pool should be ok. But the ts definition for pg-pool is wrong. See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/pg-pool/index.d.ts That incorrectly refer to pg definition. Therefore, cannot use pg-pool like:
|
pg’s bound pool (the |
I got a
TypeError
:The text was updated successfully, but these errors were encountered: