DEDUPED Hot AI repos, turned into use cases Get the Monday 5

How to import .sql files into TypeScript with real types with Reylo

Write queries in .sql files, import them, and get row and parameter types from your database.

Short answer: Install: npm install reylo, then npm install -D @reylosql/postgres (or mysql or sqlite) and npm install -D typescript@beta; then add a contentMappers entry for Reylo to tsconfig.json covering .sql, .reylo.yaml and .reylo.yml; set DATABASE_URL in your environment or .env; its scheme tells Reylo which database you use. All steps.

Who it is forA TypeScript developer tired of hand-writing row types that drift out of sync with their raw SQL.

The problemRaw SQL means hand-written types that go stale; an ORM means giving up some of the power of SQL.

The outcomeTyped query imports, like a row or null for a unique-key match, with no generated files and no watcher.

What you need first

  • TypeScript 7.1 (currently in beta), the first release with content mappers
  • Node 24 or later
  • A running dev database: Postgres, MySQL 8.0.22 or later, or a SQLite file
  • A supported driver such as pg, postgres.js, mysql2, better-sqlite3, Bun.sql or Cloudflare D1

Steps

  1. Install: npm install reylo, then npm install -D @reylosql/postgres (or mysql or sqlite) and npm install -D typescript@beta
  2. Add a contentMappers entry for Reylo to tsconfig.json covering .sql, .reylo.yaml and .reylo.yml
  3. Set DATABASE_URL in your environment or .env; its scheme tells Reylo which database you use
  4. Write a query in a .sql file with named parameters such as :id::int, import it and call .run(db, { id: 1 }) with your driver's client
  5. Load Reylo at run time on Node with node --env-file=.env --import reylo/register main.ts, or add the plugin for Bun, Vite, Next.js or your setup

Prompt for your agent

Add colinhacks/reylo to <project> using <database> and <driver>. Move the query in <file> into a .sql file, import it, and show me the inferred return type. Use TypeScript 7.1 beta and keep the existing behavior identical.

Caveat. It depends on TypeScript 7.1, which is still in beta, and needs a live dev database for type checks.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for colinhacks/reylo and "Import .sql files into TypeScript with real types"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer