Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find name '$PrismaModel' due to feature extendedWhereUnique with preview feature fieldReference #16997

Closed
Tracked by #19379 ...
haimprecise opened this issue Dec 23, 2022 · 8 comments · Fixed by prisma/prisma-engines#3989
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: extendedWhereUnique Preview Feature topic: fieldReference topic: postgresql topic: previewFeatures Issue touches on an preview feature flag topic: prisma-client
Milestone

Comments

@haimprecise
Copy link

haimprecise commented Dec 23, 2022

Bug description

Using the following ref:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["fieldReference", "extendedWhereUnique"]
}

With Prisma versions 4.5+ yields:
node_modules/.prisma/client/index.d.ts:20937:43 - error TS2304: Cannot find name '$PrismaModel'.
across the entire index.d.ts file

However, when either fieldReference or extendedWhereUnique are removed, the file compiles properly.

We cannot use both fieldReference and extendedWhereUnique but our code heavily relies on them.

How to reproduce

Expected behavior

Should properly compile

Prisma information

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["fieldReference", "extendedWhereUnique"]
}

Environment & setup

  • OS: macOS, Azure DevOps Pipeline
  • Database: PostgreSQL
  • Node.js version: 18.3.1
  • Typescript 4.7+

Prisma Version

4.5+

Tested all versions

@haimprecise haimprecise added the kind/bug A reported bug. label Dec 23, 2022
@VasiliyIsaichkin
Copy link

same problem

@jkomyno jkomyno added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. labels Dec 27, 2022
@haimprecise
Copy link
Author

I have narrowed it down.

It works when I remove extendedWhereUnique. Somehow they are colliding.

@haimprecise haimprecise changed the title Using preview feature fieldReference with a > 4.6.1 version result in a typescript error CRITICAL Degradation due to feature extendedWhereUnique with preview feature fieldReference Jan 1, 2023
@Jolg42
Copy link
Member

Jolg42 commented Jan 2, 2023

@haimprecise @VasiliyIsaichkin Could you provide an example schema to reproduce this?
Does it error when running tsc --noEmit?

@Jolg42 Jolg42 added the tech/typescript Issue for tech TypeScript. label Jan 2, 2023
@haimprecise
Copy link
Author

This an example:

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["extendedWhereUnique", "fieldReference"]
}

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  name  String?
}

typescript: 4.7.4
prisma: 4.6.1
@client/prisma: 4.6.1

Happens for tsc --noEmit

@janpio janpio changed the title CRITICAL Degradation due to feature extendedWhereUnique with preview feature fieldReference Cannot find name '$PrismaModel' due to feature extendedWhereUnique with preview feature fieldReference Jan 6, 2023
@haimprecise
Copy link
Author

Is this issue being reviewed by some team member?

In summary, fieldReference collides with extendedWhereUnique. Both features are gold for us!

@devcodeash
Copy link

Same issue with
typescript: 4.9.5
prisma: 4.10.1

@haimprecise
Copy link
Author

As a feedback for Preview features, fieldReference and extendedWhereUnique aren't working together.

typescript: 4.9.5
prisma: 4.13.0

@aqrln aqrln added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels May 25, 2023
@aqrln
Copy link
Member

aqrln commented May 25, 2023

I can reproduce with latest Prisma, some types are missing the $PrismaModel generic type parameter on the type declaration although they use it in their fields, e.g:

  /**
   * User base type for findUnique actions
   */
  export type UserFindUniqueArgsBase = {
    /**
     * Select specific fields to fetch from the User
     */
    select?: UserSelect | null
    /**
     * Filter, which User to fetch.
     */
    where: UserWhereUniqueInput<$PrismaModel>
  }

Note that you need skipLibCheck: false in your tsconfig to see the compiler error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: extendedWhereUnique Preview Feature topic: fieldReference topic: postgresql topic: previewFeatures Issue touches on an preview feature flag topic: prisma-client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants