SQL-Typechecker is a CLI tool (v0.1.0) written in TypeScript that parses PostgreSQL DDL and SQL function files, performs type-checking beyond what PostgreSQL natively offers, and generates TypeScript type definitions including branded types. It aims to provide rigorous type-checking for SQL functions and supports nested JSON outputs, branded types (newtypes), and a subset of PostgreSQL syntax. The project is under active development but has been used in production for years. It differentiates from tools like pgtyped by not relying on PostgreSQL’s own type-checker and by generating branded types.
npm install sql-typecheckerNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows minimal usage: create a SQL schema file and a function file, run sql-typechecker, and view the generated TypeScript types.
Run 'npm install @js-joda/core' before using sql-typechecker.
Simplify SQL functions or check the list of supported syntax in the documentation. Avoid plpgsql functions as they are not supported.
Use the '--out' flag to specify a separate output directory to avoid conflicts.
Pin to a specific version in package.json (e.g., "sql-typechecker": "0.1.0").
Install the peer dependency: npm install @js-joda/core
Rewrite the function to use supported constructs (see documentation) or avoid using unsupported features like plpgsql blocks.
Ensure a SQL DDL file exists in the input directory, or use the '--dsn' flag to specify a connection string for dynamic schema extraction.