TypeSQL: write plain SQL strings, get exact TypeScript types (no codegen)
I created this new library that parses Postgres SQL inside TypeScript’s type system. You write a SQL string and the compiler infers the row and parameter types. It needs no codegen and no database connection.
const q = sql(`SELECT u.id, u.email, p.title
FROM users u LEFT JOIN posts p ON p.author_id = u.id
WHERE u.id = ${sql.param(7)}`);
// { id: number; email: string; title: string | null }
sql("SELECT nme FROM users");
// error: column "nme" does not exist
- Handles joins, CTEs, subqueries, window functions, INSERT/UPDATE/DELETE … RETURNING
- Runs on pg or postgres.js, and can reuse your existing Kysely, Drizzle or Prisma schema
- Requires TypeScript 7
https://github.com/ismailkarsli/typesql
Feedback welcome, especially queries that don’t type-check but should.
6 replies
(Insert LLM) creates this new library...
Brother you want feedback for an entirely llm-coded project? The first commit is 25k LoC.
It passes full PostgreSQL test suite. I'm trying to put it on a solid foundation.
To be honest, I didn't have much faith in vibe-coded projects either, but my belief has grown stronger as I've seen more potential projects.
Also, don't assume I'm completely unfamiliar with the code. I've done the planning, chosen the project structure, and reviewed a significant portion (though perhaps superficially) of what I considered important.
See, this is the problem with vibe-coded projects and LLMs in general. They are fundamentally atomizing.
I can only speak for myself, though anecdotally I would guess this is not an uncommon position, when I say that this isn't fun. To build a community around a project you need people to be excited about the project and to be willing put free time into it because of that.
Vibecoding an app removes all the parts that made building a project fun and leaves behind only the shitty ones; the ones you specifically highlighted, the project management ones.
Maybe you got into software because you really love Agile and Gantt charts but, for a lot of people, the appeal was the craft. Open source was awesome because they can build things with like-minded people in a way that is tactile and interactive. Not unlike woodworking or metalworking hobbyists. LLMs take that part and light it on fire.
Sure, the bot can churn out fully functioning code for me. But I'm not excited about it, and I'm certainly not excited about someone else's.
Literally why. Just do what the diesel rust crate does with their macros.
It’s just so they can get dependencies out in the wild and then they add malicious code. This is why we should all learn to code… simply so we can stop being lazy and write our own
is_evenfunctions.This is TypeScript, diesel is Rust.