Nicheloom

Market intelligence for builders — see what's gaining traction before it's crowded.

Pg-typesafe

Strongly typed queries for PostgreSQL and TypeScript

Details

External ID
47050872
Source
HN
Company
—
Product
pi-typesafe
Website domain
github.com
Launched
Feb. 17, 2026
Cohort
—
Upvotes
69
Upvotes percentile
0.8578167115902965
Tags
—
Fetched at
Sept. 7, 2026, 9:25 p.m.
Updated at
Sept. 7, 2026, 9:25 p.m.

Description

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.

Enrichment

Theme
database infrastructure and developer tools
Vertical
Horizontal
Function
Dev tools
Audience
Developer
AI stance
Not AI
Project type
Hobby / open-source project
Normalized one-liner
typed postgresql queries for typescript
Manually corrected
False

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 — 187 launches clear the similarity bar, closest 8 shown.

Attention rank: #34 of 188 (itself plus its competitors, highest first — normalized so YC and Product Hunt are compared fairly).

Launched 110 days after the earliest competitor.

Other launches for this product

Same idea, different domain

Nobody's really built a dev tools tool for Sales yet.