prisma-json-types-generator icon indicating copy to clipboard operation
prisma-json-types-generator copied to clipboard

Support Prisma Client Extensions

Open rivatove opened this issue 1 year ago • 7 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the bug has not already been reported

Versions

3.1.1

A minimal reproducible example

I'll add a minimal reproduction if it proves necessary.

Description

Hi, I'm experiencing no type checking when using Prisma's create method. This is really baffling as the generated type seem alright:

  export type ordersCreateInput = {
    ...
    meta?: PrismaJson._OrderMeta | NullableJsonNullValueInput
    ...
  }

In the method call however, I can assign any value I want to the meta field with no error:

this.prisma.orders
      .create({
        data: {
          ...
          meta: 10,
          ...
      })

Doing it this way will raise an error though:

const test: Prisma.ordersCreateInput['meta'] = 10;

Do you know what could it be?

Steps to Reproduce

I'll add a minimal reproduction if it proves necessary.

Expected Behavior

No response

rivatove avatar Nov 17 '24 17:11 rivatove

I'll need a minimal reproduction repo to test it out :/

arthurfiorette avatar Nov 18 '24 13:11 arthurfiorette

I'll need a minimal reproduction repo to test it out :/

https://github.com/rivatove/prisma-json-types-generator-418/blob/master/prisma/seed.ts

Type-checking doesn't work with:

previewFeatures = ["strictUndefinedChecks"]

I don't think it's the only reason as removing that flag doesn't seem to fix that in my production app, but it's a good start and we can iterate further when you look into that.

rivatove avatar Nov 20 '24 11:11 rivatove

I fixed the strictUndefinedChecks problem with the latest release, would you mind testing it out again?

https://github.com/arthurfiorette/prisma-json-types-generator/releases/tag/v3.2.0

arthurfiorette avatar Nov 29 '24 22:11 arthurfiorette

I fixed the strictUndefinedChecks problem with the latest release, would you mind testing it out again?

https://github.com/arthurfiorette/prisma-json-types-generator/releases/tag/v3.2.0

It seems Prisma client extensions cause the issue. See updated reproduction: https://github.com/rivatove/prisma-json-types-generator-418/blob/master/prisma/seed.ts

rivatove avatar Dec 01 '24 12:12 rivatove

Thanks for the reproduction steps, sadly I do not have time to fix this right now but i'd love to review a PR fixing this.

arthurfiorette avatar Dec 06 '24 19:12 arthurfiorette

Understandable. I'm putting a $120 bounty for anyone that fixes this and has his PR merged and released. Valid until such functionality is not supported natively by Prisma.

2025-02-08 EDIT: I'm cancelling the bounty because I stopped using Prisma extensions.

rivatove avatar Dec 06 '24 20:12 rivatove

I'll work on this, let's me see if I can find a clever solution for this!

0hmX avatar Dec 07 '24 19:12 0hmX

I'm experiencing the same issue. When my Prisma client includes any extensions, all type checking of input data is gone. Any update on if/when this might be fixed?

EvanSmith93 avatar Dec 02 '25 01:12 EvanSmith93

lets see if copilot can fix this one too!

arthurfiorette avatar Dec 05 '25 23:12 arthurfiorette

Fixed in v4.0.1

arthurfiorette avatar Dec 08 '25 13:12 arthurfiorette