-
Notifications
You must be signed in to change notification settings - Fork 286
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
Expose the PostgresError type for TypeScript #99
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can get rid of the Impl
suffix, which differs from the actual implementation by the way 😉
types/index.d.ts
Outdated
@@ -63,7 +63,7 @@ interface JSToPostgresTypeMap { | |||
[name: string]: unknown; | |||
} | |||
|
|||
declare class PostgresError extends Error { | |||
declare class PostgresErrorImpl extends Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
declare class PostgresErrorImpl extends Error { | |
declare class PostgresError extends Error { |
types/index.d.ts
Outdated
@@ -94,6 +94,7 @@ type UnwrapPromiseArray<T> = T extends any[] ? { | |||
} : T; | |||
|
|||
declare namespace postgres { | |||
type PostgresError = PostgresErrorImpl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type PostgresError = PostgresErrorImpl | |
type PostgresError = typeof PostgresError |
types/index.d.ts
Outdated
@@ -312,7 +313,7 @@ declare namespace postgres { | |||
<T extends HelperSerializable, U extends (keyof (T extends any[] ? T[number] : T))[]>(objOrArray: T, ...keys: U): Helper<T, U>; | |||
|
|||
END: {}; // FIXME unique symbol ? | |||
PostgresError: typeof PostgresError; | |||
PostgresError: typeof PostgresErrorImpl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PostgresError: typeof PostgresErrorImpl; | |
PostgresError: PostgresError; |
I don't think this is right. I need the type of |
I think the easiest way would be to move |
Indeed, sorry 😆. Maybe a
Yes, because in this case it becomes possible to access the class constructor from the package exports, which is wrong: it is only accessible on the |
dbd0135
to
cae6ebf
Compare
Fixed like this ^ |
I guess this is good to merge - right @Minigugus ? |
With current
index.d.ts
it seems to be impossible to get hold of thePostgresError
type. It would be useful for e.g. signatures of error handling functions.Fix by exposing the type but not the class.