pg-typesafe generates TypeScript types for PostgreSQL queries.
pg-typesafe does so with no runtime dependencies, and zero additional verbosity.
Here is a query with pg-typesafe :
const { rows } = client . query ( "select id, name, last_modified from tbl where id = $1" , [ 42 ] , ) ;
This query looks the same as a normal query with pg , but is fully typed:
The parameter is required, and must be a number
rows has the type { id:number; name:string; last_modified: Date }[]
Getting Started
Install pg-typesafe:
npm i -D pg-typesafe
... continue reading