Trending
#Developer Tools

colinhacks/reylo

Turns raw .sql files into typed TypeScript imports by asking your dev database for column and parameter types, no codegen.

1,213
8
Rust
MIT
4 days old

The problem

SQL in a TypeScript codebase usually drifts from its types. You either hand-write row types, keep a generated schema file in sync with a codegen step, or use a query builder that trades SQL's expressiveness for type safety. Every one of those puts the type in a second place, and stale types survive until a test or a production error finds them. Reylo lets a .sql file be imported directly, with the SQL text itself as the single source of truth.

What's different

The usual fix is codegen: a watcher or CLI reads the schema and writes .d.ts files, which you then trust to be fresh. Reylo instead plugs into the type checker through TypeScript's new content mappers, so tsc asks Reylo for a type at the moment it needs one. Reylo prepares the query against your dev database without executing it and reads back column and parameter types, then layers on nullability, cardinality (a unique-key match is Row | null, an aggregate is Row), enum unions and JSON shapes. Compared with query builders like Kysely or Prisma's SQL escape hatches, you keep any SQL, function or dialect, and the types follow the text. The trade-off is that typing now depends on a reachable database and an experimental compiler feature.

Who it's for

Teams already writing SQL by hand in Postgres, MySQL or SQLite who use plain drivers (pg, postgres.js, mysql2, better-sqlite3, D1) and want editor-level type checking without adopting an ORM. It also fits agent-driven workflows, since there is no derived file for a model to forget to regenerate. Look elsewhere if you are on an older TypeScript, cannot run a dev database during type checks, or want a stable, long-supported toolchain today.

Cost of adoption

The README is explicit: TypeScript 7.1 beta, Node 24+, a running dev database for DATABASE_URL, and tsc --runExternalCode. You also need a contentMappers entry in tsconfig.json, plus a runtime plugin (or --import reylo/register) so the imports resolve at execution. That is a lot of moving parts for a young project, and pinning to a beta compiler is a real risk. MIT licensed; the README is detailed on setup but thin on failure modes and long-term support.

Verdict

The HotRepo data shows a three-day-old repository, 1,207 stars and about 316 per day, with no Hacker News discussion and no trending-board history. That is a spike, not an established project. The idea is genuinely interesting and the author is well known in the TypeScript ecosystem, but the pitch leans on a beta compiler feature and a mandatory live database. Try it on a side project; do not put it on a critical path until TypeScript 7.1 ships and the project has a track record.

Written by AI from the project's README, updated October 24, 2026. The project's own docs are the source of truth.