← All ideas
Developer toolsOct 26, 2026~14 days to build

Type-safe SQL imports for TypeScript without codegen

A small tool that lets TypeScript developers import .sql files and get full type inference, with no codegen step and no ORM lock-in.

Who & Problem

Who it's for: TypeScript backend developers and small teams who write raw SQL and want type safety without adopting an ORM or running a codegen step.

TypeScript developers who write raw SQL lose type safety. Their query results are typed as any, so column names and types are only checked at runtime. The usual fixes are codegen tools like sqlc or full ORMs like Prisma, both of which add a build step or lock you into a framework.

Evidence you can check

1 source · open any link

Why now

TypeScript type-level programming has matured enough to infer SQL schemas without a codegen step, so a small tool can now do what used to need a build pipeline.

Market gap & main competitors

Existing options force a trade-off: sqlc needs a codegen step, Prisma needs ORM lock-in. A zero-codegen, no-lock-in import path for plain .sql files is still thin, especially for small teams that want to keep raw SQL.

CompetitorPriceWeakness
sqlcFree, open sourceRequires a codegen step and a config file before you get types.
PrismaFree core, paid cloud plansFull ORM lock-in; you write in its schema language, not plain SQL.

MVP features

  1. Import a .sql file in TypeScript and get inferred types for the query result
  2. Support SELECT queries against a declared schema with column name and type checking
  3. Clear error messages when a query does not match the schema

First 100 users

  1. Post in TypeScript and Node.js communities on Reddit and Discord
  2. Share a short demo on X and Hacker News Show HN
  3. Write one blog post comparing the zero-codegen approach to sqlc and Prisma

Starter pack

Spec, stack, and prompt-by-prompt build steps. Copy anything.

TypeScriptNode.jsVitesttsx

Overview

A TypeScript library that lets developers import .sql files and get typed query results with no codegen step and no ORM.

Tech stack

  • TypeScript
  • Node.js
  • A test runner such as Vitest
  • A small demo app

Features

  1. Import a .sql file and infer the result type.
  2. Check SELECT queries against a declared schema.
  3. Show clear errors when a query does not match the schema.

Don'ts

  • Do not add a codegen or build step.
  • Do not require an ORM or a schema language.
  • Do not support writes or migrations in the first version.

Done when

  • A demo app imports a .sql file and gets correct types.
  • Wrong column names fail at compile time.
  • Tests cover at least three query shapes.

Step 1

Set up the project

Create a new TypeScript Node.js project with strict mode on. Add Vitest for tests and tsx for running scripts. Add a src folder and a tests folder. Show me the package.json and tsconfig.json.

Step 2

Define the schema type

In src/schema.ts, define a TypeScript type that describes a database schema as a map of table names to column names and column types. Keep it simple: string, number, boolean, and null.

Step 3

Parse a .sql file

Write a function that reads a .sql file as a string and extracts the SELECT column list and the FROM table name. Return a plain object with those fields. Add tests for a simple SELECT and a SELECT with aliases.

Step 4

Infer result types

Using the parsed query and the schema type, write a TypeScript type that maps the selected columns to their types from the schema. Add a test file that checks the inferred type with type-level assertions.

Step 5

Add compile-time errors

Make the inferred type fail to compile when a selected column does not exist in the schema. Show a short example of the error message a developer would see.

Step 6

Build a demo app

Create a small demo app that imports a users.sql file, runs the query against an in-memory array, and prints typed results. Show the full demo code.

Step 7

Write the README

Write a README with a short intro, a quick start example, and a section comparing this to sqlc and Prisma in plain words. No hype.

Before you ship

  • Strict TypeScript is on
  • A .sql file can be imported
  • Result types are inferred from the schema
  • Wrong column names fail at compile time
  • Demo app runs
  • Tests pass
  • README has a quick start
  • Repo is public with a runnable example

Today's radar found 113 opportunities

Sign in to see the top 10.

Sign in for 10 rows

One idea with evidence, every morning.