You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, JSON columns are typed as unknown in the generated Typescript types.
Ideally, they would have a more specific types. For example, kysely-codegen types them as JsonValue where JsonValue type is included in the generated typings file and defined like this (which is pretty much equivalent to the JsonValue type from type-fest library:
export type JsonArray = JsonValue[];
export type JsonObject = {
[K in string]?: JsonValue;
};
export type JsonPrimitive = boolean | number | string | null;
export type JsonValue = JsonArray | JsonObject | JsonPrimitive;
I noticed there were some options for type overrides in the library, unfortunately they only really allow you to override the string that is output for the field's type. There is no way to include extra type definitions (or import them). So while I could do
above the field, but that would leave JsonValue as an undefined type.
Ideally, either (1) the default typing for JSON columns would be the same as kysely-codegen, or (2) there would be a way to inject additional type definitions / arbitrary typescript into the generated file's preamble (similar to how it creates definitions for Timestamp and some others). Another option would be to do (1) but make it a configurable behavior with an additional configuration parameter.
I can potentially open a PR to do any of the above, but would be curious which of the above approaches would be acceptable / preferable. The simplest, of course, would just be to do (1).
The text was updated successfully, but these errors were encountered:
Hey there! I really need to add some documentation for this... but it's already possible to reference external types in prisma-kysely. For more info you can check out my comments on this issue:
Currently, JSON columns are typed as
unknown
in the generated Typescript types.Ideally, they would have a more specific types. For example,
kysely-codegen
types them asJsonValue
whereJsonValue
type is included in the generated typings file and defined like this (which is pretty much equivalent to theJsonValue
type fromtype-fest
library:I noticed there were some options for type overrides in the library, unfortunately they only really allow you to override the string that is output for the field's type. There is no way to include extra type definitions (or import them). So while I could do
or I could add
above the field, but that would leave
JsonValue
as an undefined type.Ideally, either (1) the default typing for JSON columns would be the same as
kysely-codegen
, or (2) there would be a way to inject additional type definitions / arbitrary typescript into the generated file's preamble (similar to how it creates definitions forTimestamp
and some others). Another option would be to do (1) but make it a configurable behavior with an additional configuration parameter.I can potentially open a PR to do any of the above, but would be curious which of the above approaches would be acceptable / preferable. The simplest, of course, would just be to do (1).
The text was updated successfully, but these errors were encountered: