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
- Install typed-sql for PostgreSQL or MySQL.
- Configure schema introspection.
- Write and check your first query.
- Execute queries with your selected driver.
Guides
- Compose conditional SQL without creating a parallel query-builder API.
- Generate snapshots and detect drift.
- Configure Zed, VS Code, or another LSP client.
- Review the PostgreSQL and MySQL grammar boundaries.
Concepts and reference
- Architecture
- Inference and safety
- Performance
- Query API
- Compatibility
- Database type mappings
- Diagnostics
- Authoring a custom grammar
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, neveranyor 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
sqlfrom its dialect package, never from generated output.