arthurfiorette / prisma-json-types-generator

⚒️ Changes JsonValues to your custom typescript type.
https://npm.im/prisma-json-types-generator
MIT License
345 stars 18 forks source link

Json types inside type declarations won't work #303

Open thomasbouillon opened 3 months ago

thomasbouillon commented 3 months ago

Prerequisites

Versions

v3.0.4

A minimal reproducible example

https://github.com/thomasbouillon/reproduce-prisma-json-issue

Description

The README says Json types inside type declarations won't work but the linked issue has been resolved and merged since prisma 4.16.0.

Now it should work ?

(using mongodb if that changes anything)

Steps to Reproduce

schema.prisma

model A {
    nested B
}

type B {
   /// [CustomJson]
   myJsonValue Json
}
yarn prisma generate

Result:

... 
{
       /**
       * [CustomJson]
       */
      myJsonValue: Prisma.JsonValue
}

Expected Behavior

schema.prisma

model A {
    nested B
}

type B {
   /// [CustomJson]
   myJsonValue Json
}
yarn prisma generate

Result:

... {
       /**
       * [CustomJson]
       */
      myJsonValue: PrismaJson.CustomJson  //  <-----
}
arthurfiorette commented 3 months ago

Hey @thomasbouillon, thanks for this bug report. Since then I didn't implemented and/or testes support for json inside prisma types. Are you open to PR it? remember to add unit tests...