A TypeScript code generation library that parses raw SQL statements and generates TypeScript types for result rows and named parameters. Version 1.0.1 is the latest stable release. This library works isomorphic (Node.js and browser) and supports SELECT, UPDATE, DELETE, INSERT statements, alias columns, function calls, quoted identifiers, named parameters, and WITH clauses. It generates both row types and parameter types automatically at runtime or build time. Unlike SQL-to-TypeScript tools that require a database connection, gen-sql-type works purely from SQL strings without schema introspection.
npm install gen-sql-typeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates importing SqlTypeFile, wrapping a SQL statement to generate TypeScript types for result rows and parameters.
Manually override types using type assertions or post-process generated file
Ensure each wrapSql call has a distinct name argument, preferably using __filename or a constant
Use separate generated files or post-generation transformations
Use `import { SqlTypeFile } from 'gen-sql-type'` or `const { SqlTypeFile } = require('gen-sql-type')`Ensure tsconfig.json includes node_modules/@types or set `moduleResolution: node`. Reinstall package.
Use unique names for each SQL query, e.g., include table name or file path
No dependency data recorded yet.