finds.dev← search

// the find

adelsz/pgtyped

★ 3,284 · TypeScript · MIT · updated Sep 2026

pgTyped - Typesafe SQL in TypeScript

pgTyped generates TypeScript types for raw SQL queries by asking a live Postgres instance to describe the query's parameters and result columns, so you write plain SQL (in .sql files or tagged TS) and get compile-time-checked params/results without hand-maintaining a schema or adopting a full ORM. It's aimed at teams who want type safety on raw SQL but don't want Prisma/Kysely-style query builders getting between them and the database.

Types come from the database itself via prepared-statement description, so there's no shadow schema to keep in sync — correctness tracks the real DB. Query parsing uses an actual ANTLR grammar (packages/parser) instead of regex scraping, which holds up on non-trivial SQL with joins and CTEs. Parameter substitution is handed off to the driver (query and params sent separately), so the tool itself doesn't introduce injection risk the way naive template-based generators can. It ships native ESM output with a CJS-compatible runtime package, which is a detail a lot of similar tools still get wrong.

Generating types requires a live, reachable Postgres instance with your schema already applied — CI pipelines and new developer onboarding need a real running DB just to build, which is more setup than schema-file-based codegen tools. Postgres only, no MySQL or SQLite, so it's a single-database bet. The README still says 'APIs might change' and this reads as effectively a single-maintainer project (adelsz) — worth checking issue/PR response times before leaning on it for anything critical. There's no migration story bundled in: it types whatever schema happens to be live, but you still need a separate tool to get that schema there and keep environments in sync.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →