RobinBlomberg / kysely-codegen

Generate Kysely type definitions from your database.
MIT License
690 stars 62 forks source link

0.13 breaking changes #135

Closed michael-land closed 4 months ago

michael-land commented 4 months ago

Upgrading from version 0.11 to 0.13 results in an error related to the PostgreSQL array type. Generated array type changed from T[] to ArrayType<T>

code

export type ArrayType<T> = T extends ColumnType<infer S, infer I, infer U> ? ColumnType<S[], I[], U[]> : T[];

type X = 'A' | 'B';
type Xs = X[];

type Table = {
  xs: ArrayType<X>;
};

const input: Insertable<Table> = {
  xs: ['A', 'B'],
};

screenshots CleanShot 2024-03-07 at 23 49 59@2x CleanShot 2024-03-07 at 23 50 08@2x

Upvote & Fund

Fund with Polar

RobinBlomberg commented 4 months ago

Thanks for reporting! I'll jump on this immediately.

RobinBlomberg commented 4 months ago

This feels like a TypeScript limitation, because I'm not sure why these behave differently...

image

Anyway, I'll find a solution. Be back soon.

Edit: Found a 3-day-old TypeScript issue about this: https://github.com/microsoft/TypeScript/issues/57650

RobinBlomberg commented 4 months ago

Not the most beautiful thing, but it works! Expect a new version within ~15 minutes (I hope, if I don't have to extend the TypeScript generator).

Arrayz

RobinBlomberg commented 4 months ago

Released in 0.13.1!