ts-sql-lang (v1.0.18) is a TypeScript SQL query builder that compiles check at compile time, preventing SQL syntax errors, wrong column names, missing tables, and duplicate aliases. It generates raw SQL strings and works with any MySQL/MariaDB driver (mysql, mysql2, etc.). Unlike runtime query builders, it relies heavily on TypeScript's type system for validation. Release cadence is low; no recent updates. Key differentiator: compile-time errors via TypeScript generics, not runtime checks.
npm install ts-sql-langNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic SELECT query with COUNT, WHERE, GROUP BY, ORDER BY, and LIMIT using typed SQL builder.
Call query.toSqlString() and pass the string to mysql/mysql2 or any other library.
Always include the table in the FROM/JOIN clause before referencing its columns.
Ensure all selected columns have unique names, or use .as() for duplicates.
Read the first line of the error carefully; it often points to the root cause. Simplify queries incrementally.
Call query.toSqlString() to convert to string.
Add the table using .selectFrom(tUser) or .join(tUser) before using its columns.
Rename one column using .as('uniqueAlias').No dependency data recorded yet.