I am using Kysely's code generation tool for a PostgreSQL database. The database contains an enum
type for statuses
, and I am trying to generate TypeScript types using the --singular
flag.
However, when I use the --singular
flag, the tool correctly generates table names in singular form (e.g., user
instead of users
). Unfortunately, it does not generate enum
or column
names in singular form. These remain in their plural form (e.g., statuses
instead of status
).
Actual sample ts
file:
export type Statuses = "ACTIVE" | "INACTIVE";
export interface User {
// ... other fields.
Statuses: Generated<Statuses>;
userId: Generated<string>;
}
CREATE TYPE statuses AS ENUM ('ACTIVE', 'INACTIVE');
CREATE TABLE IF NOT EXISTS users (
user_id bigserial PRIMARY KEY,
name text,
status statuses DEFAULT 'ACTIVE' NOT NULL
);
--singular
flag:npx kysely-codegen --singular --dialect=postgres --url="<DATABASE_URL>" --out-file="./types.ts"
enum
and column
names still remain in plural form.The --singular
flag should apply to all generated types, including enum
and column
names, ensuring consistency in the naming convention across the generated code.
Only the table names are converted to singular form, while enum
and column
names remain in plural form.
kysely: 0.27.4
kysely-codegen: 0.17.0
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too