kysely icon indicating copy to clipboard operation
kysely copied to clipboard

Add a native way to mark columns as read-only.

Open igalklebanov opened this issue 8 months ago • 0 comments

Hey 👋

Proposal:

Similar to the proposal @ #1404, we could also use Readonly<T> to represent the equivalent of ColumnType<T, never, never> for column types, but in a TypeScript-native way that's much more readable and concise. Some tools and people use GeneratedAlways<T> as a shorthand for this use case, but it's semantically wrong.

Readonly<T> requires using primitive type constructors, e.g. String instead of string.

It supports nullable:

nullable: Readonly<String | null>
//  ^?  Readonly<String> | null

Cons:

Forcing usage of constructor types for primitives. It's niche, and there's already a way to achieve the same thing.

igalklebanov avatar Mar 29 '25 22:03 igalklebanov