Generate TypeScript Types from PostgreSQL

An utility module for Knex.js that generates TypeScript definitions (types) from a PostgreSQL database schema.

$ npm install knex
$ npm install knex-types --dev

Usage Example

const { knex } = require("knex");
const { updateTypes } = require("knex-types");

const db = knex(require("./knexfile"));

updateTypes(db, { output: "./types.ts" }).catch((err) => {

Find an example of generated types in ./main.test.ts.

Related Projects

  • GraphQL API Starter Kit — monorepo template, pre-configured with TypeScript, GraphQL.js, React, and Relay
  • Node.js API Starter Kit — Node.js project template (PostgreSQL, Knex, OAuth 2.0, emails, Cloud Functions)

How to Contribute

Please create a PR or send me a message on Discord.

Download Details:

Author: kriasoft

Official Github: 

License: MIT


Generate TypeScript Types from PostgreSQL
1.10 GEEK