← All projects
Project record1 mention
Originally shared on Hacker News

TypeSQL

TypeSQL parses Postgres SQL string literals inside TypeScript's type system to produce exact row and parameter types at compile time with no codegen and no database connection. It handles joins with correct nullability, CTEs, subqueries, window functions, INSERT/UPDATE/DELETE with RETURNING, and DDL; at runtime it is a 3.8 KB wrapper for pg or postgres.js and can take a schema from Kysely, Drizzle, or Prisma. It requires TypeScript 7 and supports only Postgres.

Last shared
01 / Source history

Shared over time

Each entry reflects what was shared on that date. Details may have changed since then.

  1. TypeSQL

    TypeSQL parses Postgres SQL string literals inside TypeScript's type system to produce exact row and parameter types at compile time with no codegen and no database connection. It handles joins with correct nullability, CTEs, subqueries, window functions, INSERT/UPDATE/DELETE with RETURNING, and DDL; at runtime it is a 3.8 KB wrapper for pg or postgres.js and can take a schema from Kysely, Drizzle, or Prisma. It requires TypeScript 7 and supports only Postgres.

    Posted by @ismailkarsli · Original source ↗

    Story title · @ismailkarsli · · Source ↗

    Show HN: TypeSQL – Postgres SQL parsed in TypeScript's type system, no codegen

    Submitted URL · @ismailkarsli · · Source ↗

    https://github.com/ismailkarsli/typesql

    Source text · @ismailkarsli · · Source ↗

    TypeSQL parses Postgres SQL string literals inside TypeScript's type system, so you get the exact row and parameter types with no codegen and no database connection. A misspelled column is a compile error.

    Source text · @ismailkarsli · · Source ↗

    It handles joins with correct nullability, CTEs, subqueries, window functions, INSERT/UPDATE/DELETE with RETURNING, and DDL. At runtime it's a 3.8 KB wrapper for pg or postgres.js, and it can take your schema from Kysely, Drizzle or Prisma.

    Source text · @ismailkarsli · · Source ↗

    It needs TypeScript 7 and only supports Postgres. Each extra query adds about 6 ms of compile time (numbers in the README).