frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Show HN: Typegres – I made every Postgres function type-safe in TypeScript

https://typegres.com/
1•ryanrasti•9h ago

Comments

ryanrasti•9h ago
Hi HN, I'm Ryan, the creator of Typegres.

For years, I've felt stuck between two unsatisfying options for talking to my database: use a traditional ORM that forces you to learn its quirks instead of Postgres itself, or write raw SQL strings and sacrifice type safety and composability.

ORMs discourage you from using the database's powerful native features, forcing you to pull data into the backend to transform it. Raw SQL is powerful but error-prone, and dynamic queries quickly become a tangled mess of string concatenation.

That frustration led me to build Typegres, my take on a new kind of query builder with a simple philosophy: minimal abstraction, maximum surface area.

Instead of hiding SQL, Typegres embraces it. It code-generates a type-safe TypeScript method for every one of Postgres's 3000+ built-in functions and operators. This approach has a huge benefit for iterating faster: since everything is a method, you get full discoverability via autocomplete. The ultimate vision is that Typegres not only helps you write safe queries, but actually helps you learn Postgres as you type.

Some of the things I'm most excited about:

* Full(er) Postgres Coverage: If you can do it in Postgres, you can do it in Typegres, with type-safety. This includes first-class support for advanced features like set-returning functions (e.g., `jsonb_each`).

* Composable & Type-Safe: Build complex queries from smaller, reusable parts—including subqueries—while maintaining complete type safety from start to finish.

* Ergonomic Operator Syntax: SQL operators like `+`, `=`, or `>` are just methods, allowing for natural chaining with auto-complete: (e.g., `.where(u => u.age['>='](21))`)

* Compile-Time Safety: The type system understands SQL rules. For example, it will show a TypeScript error if you try to select a non-aggregated column in a `groupBy` clause.

The coolest part is the in-browser playground, which is powered by Sam Willis's incredible PGlite project. You can try out the full library with zero setup.

A quick note on its status: this is an early developer preview. My main goal today is to see if this philosophy resonates with other developers. The core type-safety is robust, but there's many edge cases to still cover and it's not yet ready for production use. Following the project on GitHub is the best way to stay updated on the journey to 1.0.

Starting with this level of fidelity to Postgres opens the door to some pretty exciting future features— the tl;dr is that I'm optimistic this route can make significant headway into tackling the object-relational impedance mismatch (see the github README for more). Because Typegres understands the database so deeply, it can create healthier, more powerful abstractions.

I'd love to hear all your feedback in the comments. Thank you!

Playground: https://typegres.com/play

GitHub: https://github.com/ryanrasti/typegres

Integrity-Policy Header

https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Integrity-Policy
1•todsacerdoti•1m ago•0 comments

My Digital Minimalism Journey

https://sym.bearblog.dev/digital-minimalism/
1•sym5731•5m ago•0 comments

Libinput 1.29 Improving Scroll Wheel Responsiveness for Most Devices

https://www.phoronix.com/news/libinput-1.29-RC
1•Bender•7m ago•0 comments

Updating an old Ubuntu to a supported version

https://anonymoushash.vmbrasseur.com/2025/07/old-ubuntu-upgrade.html
1•vmbrasseur•7m ago•0 comments

Windows 11 clean install guide: remove bloatware and optimize performance

https://sym.bearblog.dev/win11-install/
1•sym5731•8m ago•0 comments

New Burning Coal Seams Revealed Across Wyoming's Northern Border

https://cowboystatedaily.com/2025/07/10/dozens-of-new-burning-coal-seams-revealed-across-wyomings-northern-border/
2•Bender•8m ago•0 comments

Barksdale Airmen Help Secure New Drone Restrictions Across Louisiana

https://www.afgsc.af.mil/News/Article-Display/Article/4238511/barksdale-airmen-help-secure-new-drone-restrictions-across-louisiana/
1•Bender•10m ago•0 comments

Grok 4 answers controversial questions by searching what Musk has to say

https://twitter.com/jeremyphoward/status/1943436621556466171
3•ks2048•13m ago•1 comments

Binding Application in Idris

https://andrevidela.com/blog/2025/binding-application/
1•matt_d•14m ago•0 comments

Retro-gaming YouTuber PatmanQC has died, aged 53

https://www.vanhoe.com/obituary/Patrick-Davis
1•shdon•14m ago•0 comments

Readeck

https://readeck.org/en/
3•billybuckwheat•16m ago•0 comments

The Return of the "Elderly" Pop Star

https://www.cantgetmuchhigher.com/p/why-are-pop-stars-getting-older
1•jnord•17m ago•0 comments

The simplest GenAI setup I've used actually worked

https://Lyzr.ai
1•kuoki•18m ago•0 comments

Don't Eat Honey

https://benthams.substack.com/p/dont-eat-honey
1•bookofjoe•20m ago•1 comments

Show HN: Context Compass – Track Claude chat token usage before hitting limit

https://chromewebstore.google.com/detail/context-compass-for-claud/fmbipbgbfoganenegfmkmlidljbfnkhf
1•raydawg88•22m ago•0 comments

San Francisco firm fined $215M for illegally using Russian oligarch funds

https://sfstandard.com/2025/06/13/russia-ukraine-sanctions-putin-venture-capital-peskin/
6•2OEH8eoCRo0•23m ago•0 comments

Musk Says Grok Chatbot Coming to Tesla Vehicles by Next Week

https://www.bloomberg.com/news/articles/2025-07-10/musk-says-grok-chatbot-is-coming-to-tesla-vehicles-by-next-week
2•JumpCrisscross•24m ago•3 comments

Light at the end of the tunnels: classic rail routes through the Alps reopen

https://www.theguardian.com/travel/2025/jul/10/classic-rail-routes-through-alps-reopen-austria-switzerland-italy
1•divbzero•25m ago•0 comments

First 74,369-gate circuit validated on IBM back end

https://twitter.com/CTibedo/status/1943409135090892865
1•GeometryKernel•28m ago•0 comments

Ask HN: Why isn't mobile phone service restricted to emergency numbers only?

1•amichail•31m ago•4 comments

Using Large Language Models to Infer Problematic Instagram Use

https://www.mdpi.com/2079-9292/14/13/2548
1•PaulHoule•33m ago•0 comments

Robinhood's Crypto Trading Promotions Probed by Florida AG

https://www.bloomberg.com/news/articles/2025-07-10/robinhood-s-crypto-trading-promotions-probed-by-florida-ag
2•Bluestein•36m ago•0 comments

Italy's Mosaic School

https://www.bbc.com/travel/article/20250707-inside-italys-secret-mosaic-school
1•andsoitis•40m ago•0 comments

A Doctor Said Israel's War Is Fueling Health Crises in Gaza. UCSF Fired Her

https://theintercept.com/2025/06/05/gaza-israel-san-francisco-ucsf-doctor-professor/
14•heavyset_go•42m ago•0 comments

Claude now connects with Canvas, Panopto, and Wiley for educational access

https://the-decoder.com/claude-now-connects-with-canvas-panopto-and-wiley-for-educational-access/
2•alwillis•42m ago•0 comments

Open Source Tools to Detect CVE-2024-54085

https://eclypsium.com/blog/eclypsium-releases-tools-for-detecting-ami-megarac-bmc-vulnerabilities/
2•cws•42m ago•0 comments

Show HN: Highlight Text to Send Directly into ChatGPT

https://chromewebstore.google.com/detail/chatgpt-search-use-on-any/ekamciedckbbigpojmkhbaoddfbdkphi
1•bluelegacy•45m ago•0 comments

Color Block Jam Level Guide

https://www.colorblockjamlevel.app/
1•cnych•49m ago•0 comments

Extending Self-Discharge Time of Dicke Quantum Batteries with Molecular Triplets

https://journals.aps.org/prxenergy/abstract/10.1103/bhyh-53np
1•gnabgib•49m ago•0 comments

Advice, like youth, probably just wasted on the young (1997)

https://www.chicagotribune.com/news/columnists/chi-schmich-sunscreen-column,0,4054576.column
1•GeoAtreides•50m ago•0 comments