kysely-codegen
Configuration for kysely-codegen, a TypeScript type generator for Kysely.
| Type | object |
|---|---|
| File match |
.kysely-codegenrc.json
**/.kysely-codegenrc.json
|
| Schema URL | https://catalog.lintel.tools/schemas/kysely/kysely-codegen/latest.json |
Validate with Lintel
npx @lintel/lintel check
Configuration file for kysely-codegen, a TypeScript type generator for Kysely.
kysely-codegen introspects your database and generates TypeScript type definitions so that Kysely queries are fully typed. Configuration is read from .kysely-codegenrc.json in the project root. CLI arguments take precedence over config file values.
See the kysely-codegen README for full documentation.
Properties
Use the Kysely CamelCasePlugin for generated table column names. When enabled, column names like created_at become createdAt in the generated types.
Specifies which parser to use for PostgreSQL date/time values.
timestamp— Dates are typed asDate(default)string— Dates are typed asstring
Sets the default schema(s) for the database connection. Tables in these schemas are generated without a schema prefix.
Defaults to ["public"] for PostgreSQL and [] for other dialects.
Sets the SQL dialect. If not provided, it is inferred from the connection string URL.
postgres— PostgreSQLmysql— MySQL / MariaDBmssql— Microsoft SQL Serversqlite— SQLite (via better-sqlite3)bun-sqlite— SQLite via Bun's built-in SQLitekysely-bun-sqlite— SQLite via kysely-bun-sqliteworker-bun-sqlite— SQLite via Bun workerlibsql— libSQL (Turso)
Controls whether to generate types for PostgreSQL domains. Only relevant when using the postgres dialect.
Path to an environment file (e.g. .env) to load before reading the connection string. Useful when DATABASE_URL is defined in an env file.
A glob pattern to exclude tables from code generation. Tables matching this pattern are skipped.
A glob pattern to include only matching tables in code generation. Tables not matching this pattern are skipped.
Sets the terminal log level.
debug— All messagesinfo— Informational and abovewarn— Warnings and errors (default)error— Errors onlysilent— No output
Specifies which parser to use for PostgreSQL numeric / decimal values.
string— Typed asstring(default, preserves precision)number— Typed asnumber(may lose precision for large values)number-or-string— Typed asnumber | string
Sets the output file path for the generated type definitions. When set to null, uses the default path inside node_modules.
Specifies type overrides for specific table columns. Allows you to manually set the TypeScript type for columns where the inferred type is not ideal.
1 nested properties
A map of "table.column" (or "schema.table.column") to a TypeScript type expression string.
Includes PostgreSQL table partitions in the generated code. Only relevant when using the postgres dialect.
Prints the generated output to the terminal (stdout) instead of writing to a file. Useful for previewing output or piping to other tools.
Generates TypeScript enum declarations for PostgreSQL enum types instead of union types. Only relevant when using the postgres dialect.
false— Generate union types like"a" | "b"(default)true— Generate runtime enums with default naming"pascal-case"— Generate enums with PascalCase member names"screaming-snake-case"— Generate enums with SCREAMING_SNAKE_CASE member names
Singularizes generated type aliases (e.g. Users becomes User).
false— No singularization (default)true— Use built-in singularization rules{...}— A record of regex pattern to replacement string for custom singularization rules
Skips adding the // This file was generated by kysely-codegen comment at the top of the generated file.
Uses TypeScript's import type syntax in the generated code (e.g. import type { ColumnType } from 'kysely' instead of import { ColumnType } from 'kysely').
The database connection string URL. If not provided, reads from the DATABASE_URL environment variable.
Examples for each dialect:
- PostgreSQL:
postgres://user:pass@localhost:5432/mydb - MySQL:
mysql://user:pass@localhost:3306/mydb - SQLite:
C:/path/to/db.sqliteor:memory: - libSQL:
libsql://your-db.turso.io - MSSQL:
Server=localhost;Database=mydb;User Id=sa;Password=pass;
Verifies that the generated types are up-to-date without writing any files. Exits with a non-zero code if the output file would change. Useful in CI pipelines.