brianc / node-pg-types

Type parsing for node-postgres
268 stars 55 forks source link

Add typescript declaration file #83

Closed MohamedLamineAllal closed 5 years ago

MohamedLamineAllal commented 5 years ago

pg.types.builtins is missing from @types/pg Even though the type imports is set to be automaticly resolved from pgTypes import pgTypes = require("pg-types"); export const types: typeof pgTypes;

Having a declarative typing directly set in pg-types. Will give better flexibility and better update time.

Here a PR that propose a fix.

If there is anything that is not ok. Let me know.

Context: (latest versions) Screenshot from 2019-07-26 11-55-34

(builtins are missing) Screenshot from 2019-07-26 11-54-07

(after fix) Screenshot from 2019-07-26 12-05-32

MohamedLamineAllal commented 5 years ago

Thank you sir. I will add tests and then commit again.

MohamedLamineAllal commented 5 years ago

I just added tests and a minimal change to types declaration. (added TypeFormat type, and the overloading of the setTypeParser Function). Let me know if there is anything to add.

bendrucker commented 5 years ago

Thanks for working on this. Made a couple small changes:

Just need to follow up when I’m at my laptop and update the lockfile since I made the edits via the web interface. Should be good to merge and cut a new minor release in an hour or so.

What should we do about the types in DefinitelyTyped now that there is official support? I assume we shouldn’t remove them and break existing users, but I’m hoping there’s somewhere we can put a deprecation notice.

MohamedLamineAllal commented 5 years ago

Hi sir. I'm late. i looked at the changes. Thank you for the details.

For types in DefinitelyTyped. Yea, it should be exactly as you said (most logical thing, as otherwise i will think to update @types/pg-types, which is useless). And for the notice, i think it would be nice to just add it to this repo package Readme. I will fill a PR suggesting a deprecation notice. I will add a section Typescript. Where i will explain the typescript support. And also put the deprecation notice.

Thank you again sir.