sqltyper 1.3.2 generates typed TypeScript functions from raw PostgreSQL queries by analyzing schema from a running database. It connects to a PostgreSQL database, parses SQL files containing queries with parameter placeholders (${param} or :param), and outputs .ts files with correct TypeScript types for parameters and result rows. Unlike ORMs or query builders, it works directly with SQL while providing compile-time type safety. Compatible with node-postgres, postgres.js, and pg-promise runtime libraries. Released via npm, with active development on GitHub.
npm install sqltyperNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Complete setup and usage example: install, write SQL file, run sqltyper, and use generated typed function with pg client.
Use aliases (AS) in SQL to ensure unique column names.
Start your PostgreSQL database and provide correct connection string via --database.
Run sqltyper again after schema changes to update TypeScript types.
Install postgres@beta instead of postgres for TypeScript projects.
npm install --save pg (or postgres@beta, or pg-promise)
Ensure PostgreSQL is running and the --database argument points to a valid database.