Pg-typesafe
Strongly typed queries for PostgreSQL and TypeScript
Get picks like this daily. Today's launch numbers, the top launches, AI and tech news, and a daily opportunity pick, straight to your inbox.
Want to reach these readers? Sponsor an issue.
Throughout my career, I tried many tools to query PostgreSQL, and in the end, concluded that for what I do, the simplest is almost always the best: raw SQL queries.Until now, I typed the results manually and relied on tests to catch problems. While this is OK in e.g., GoLang, it is quite annoying in TypeScript. First, because of the more powerful type system (it's easier to guess that updated_at is a date than it is to guess whether it's nullable or not), second, because of idiosyncrasies (INT4s are deserialised as JS numbers, but INT8s are deserialised as strings).So I wrote pg-typesafe, with the goal of it being the less burdensome: you call queries exactly the same way as you would call node-pg, and they are fully typed.It's very new, but I'm already using it in a large-ish project, where it found several bugs and footguns, and also allowed me to remove many manual type definitions.
HN · launched Feb 17, 2026 · 69 upvotes (top 14%) · 0 views
Niche: data and schema validation tools · 56 launches, 2 in the last 7 days ▼ -75% · Explore this niche →
Category and tags
- Horizontal
- Dev tools
- Developer
- Not AI
- Hobby / open-source project
Visit website ↗ Source listing ↗
More like this: all 56 launches in data and schema validation tools →
Could you build this?
Partial Generating TypeScript types from raw SQL queries requires either running an embedded PostgreSQL parser (like libpg_query) in WebAssembly/Node or introspecting live schema catalogs and parsing query ASTs.
What it would actually take: The architecture involves embedding PostgreSQL's native parser (typically via `libpg_query` compiled to C/Wasm) to extract ASTs from arbitrary SQL queries, coupled with a connection to a development database to resolve schema metadata, table structures, and type inferences. The hard part is full SQL dialect compliance, correctly typing complex joins, subqueries, and JSON operations, and maintaining synchronization with TypeScript's type checker. This requires expertise in compiler construction, AST traversal, and database catalog internals.
Discussion
20 comments analyzed.
Competitors mentioned: Slonik, Clorinde, Kanel, Knex, pg-promise
Concerns raised: Lack of composability for building dynamic queries, Debugging difficulty with auto-numbered placeholders ($1, $2) vs named parameters, Schema drift between DB and TypeScript interfaces, Limited support for dynamic/ad-hoc SQL queries
Feature requests: Support for named parameters (like :id instead of $1), Better pattern for composing/building dynamic queries, Composable query builders
Competitors
Other products that read as similar to this one : 320 launches clear the similarity bar, closest 8 shown.
Attention rank: #54 of 321 (itself plus its competitors, highest first, normalized so YC and Product Hunt are compared fairly).
Launched 110 days after the earliest competitor.
- pg-jev · github · 2026-09-17 · 274 upvotes · similarity 0.60
- pg-query-validate · github · 2026-09-27 · 27 upvotes · similarity 0.55
- uplpgsql · hn · 2026-07-16 · 10 upvotes · similarity 0.53
- GEDB · hn · 2026-02-16 · 9 upvotes · similarity 0.52
- Pgxio · hn · 2026-11-09 · 10 upvotes · similarity 0.51
- Pgrust, Postgres in Rust (passing 100% of Postgres regression tests) · hn · 2026-06-25 · 6 upvotes · similarity 0.50
- LinkedQL · hn · 2025-12-08 · 31 upvotes · similarity 0.50
- Dbctx · hn · 2026-08-11 · 5 upvotes · similarity 0.50
The niche, labels, vibe code rating and competitor comparison on this page are analysis by Nicheloom. If you use them, please credit nicheloom.com. How you may use our data.