Skip to content

typed-sql documentation

typed-sql is a TypeScript SQL compiler. It analyzes static SQL templates against a generated snapshot of your database and carries the inferred row and parameter types through application code.

It is not an ORM or a query builder. SQL remains visible, database drivers remain application-owned, and generated files contain schema metadata rather than an application API.

Start here

  1. Install typed-sql for PostgreSQL or MySQL.
  2. Configure schema introspection.
  3. Write and check your first query.
  4. Execute queries with your selected driver.

Guides

Concepts and reference

Core guarantees

  • Static, supported SQL receives an exact row type and ordered parameter tuple.
  • Unsupported or ambiguous SQL produces a diagnostic or a conservative unknown, never any or a guessed type.
  • Query values remain driver parameters unless you explicitly opt into structural SQL.
  • Installing a grammar does not install a database driver.
  • Application code imports sql from its dialect package, never from generated output.

Released under the MIT License.