添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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 bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. topic: client types Types in Prisma Client

Bug description

Any version of Prisma greater than 4.12.0 that I tried (4.13.0 and 5.5.2 for sure) produce the following error:

prisma-client/prisma/dist/runtime/library.d.ts:1298:35 - error TS1005: '?' expected.
1298     select: infer S extends object;

I reproduced the issue with TS 4.7.4, 5.0.0, and 5.2.2, so it is not a matter of using an old TS version as reported in related issues (see below).

Related issues:

  • Prisma errors in index.d.ts when building the project #5732
  • Migrating to release: 4.16.2 throws typescript error: "TS1005: '?' expected". #20024
  • How to reproduce

    Generate the client and build the application. The source files are sensitive and I did not yet have the opportunity to invest time shrinking to produce a minimal example that exposes the bug.

    Expected behavior

    Compile without errors.

    Prisma information

    datasource db {
      provider = "postgresql"
      url      = env("POSTGRES_URI")
    generator client {
      provider        = "prisma-client-js"
      output          = "./dist"
      previewFeatures = ["tracing"]
    // [...] sensitive and I did not yet have the opportunity to invest time shrinking to produce a minimal example that exposes the bug
    // [...] sensitive and I did not yet have the opportunity to invest time shrinking to produce a minimal example that exposes the bug

    Environment & setup

  • OS: Ubuntu 22.04.3 LTS 64 bits (Linux <hostname> 6.2.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 6 10:23:26 UTC 2 x86_64 x86_64 x86_64 GNU/Linux)
  • Database: PostgreSQL 15.3
  • Node.js version: Node.js v18.18.0
  • Prisma Version

    The bug is present in 4.13.0 and 5.5.2. I have not tested all versions in between, but I believe all are affected. The bug is absent from version 4.12.0.

    Are you sure you are using a recent version of Typescript?

    Yes, as explicitly stated in the issue description:

    I reproduced the issue with TS 4.7.4, 5.0.0, and 5.2.2, so it is not a matter of using an old TS version as reported in related issues (see below).

    bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Oct 31, 2023

    @mitre-tm without more information to be able to reproduce, we won't be able to help here.

    Please give steps to reproduce (the exact command and tooling versions) along with your tsconfig.json file for example.

    I just tried the following with 5.5.2 and everything works as expected.

    datasource db {
      provider = "postgresql"
      url      = "postgresql://prisma:prisma@localhost:5432/21665"
    generator client {
      provider        = "prisma-client-js"
      output          = "./dist"
      previewFeatures = ["tracing"]
    model Post {
      id        Int      @id @default(autoincrement())
      createdAt DateTime @default(now())
      title     String
      content   String?
      published Boolean  @default(false)
      author    User     @relation(fields: [authorId], references: [id])
      authorId  Int
    model Profile {
      id     Int     @id @default(autoincrement())
      bio    String?
      user   User    @relation(fields: [userId], references: [id])
      userId Int     @unique
    model User {
      id      Int      @id @default(autoincrement())
      email   String   @unique
      name    String?
      posts   Post[]
      profile Profile?
    

    tsconfig

    "compilerOptions": { "target": "es2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, "strict": true /* Enable all strict type-checking options. */, "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */

    main.ts

    import { PrismaClient } from '@prisma/client'
    async function main() {
      const prisma = new PrismaClient()
      const data = await prisma.user.findMany()
      console.log(data)
      prisma.$disconnect()
    main()

    I solved the issue by deleting the lockfiles (package-lock.json) and recreating them with npm install. In this process, some dependencies were auto-updated, which I believe solved the issue. In the build (CI), we use npm clean-install, for reproducibility and security.

    By the way, our tsconfig.json was already consistent with the one provided in the example, with the difference that target was set to ES2022, as recommended for Node 18.

    node_modules/@prisma/client/runtime/library.d.ts:1299:1 - error TS1005: '?' expected.
    1299 } & Record<string, unknown> | {
    node_modules/@prisma/client/runtime/library.d.ts:1301:1 - error TS1005: '?' expected.
    1301 } & Record<string, unknown> ? {
    Error! You can try adding the -V parameter for more information output.
    Error: TS Error: '?' expected.(node_modules/@prisma/client/runtime/library.d.ts)
        "jsx": "preserve",
        "esModuleInterop": true,
        "typeRoots": [ "./typings", "./node_modules/@types"],
        "outDir": "dist",
        "paths": {
          "~/*": ["./*"],
          "@/*": ["./web/*"],
          "~src/*": ["./src/*"] 
      "exclude": [
        "dist",
        "node_modules",
        "test",
        "web"
              

    @brooke1220 Please open a new issue and fill up the template, we'll need more information to be able to help you.
    Make sure to check your typescript package version installed.

    I solved the issue by deleting the lockfiles (package-lock.json) and recreating them with npm install. In this process, some dependencies were auto-updated, which I believe solved the issue. In the build (CI), we use npm clean-install, for reproducibility and security.

    By the way, our tsconfig.json was already consistent with the one provided in the example, with the difference that target was set to ES2022, as recommended for Node 18.

    thank you bro, you solved my problem, i love you

    bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. domain/client Issue in the "Client" domain: Prisma Client, Prisma Studio etc. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. topic: client types Types in Prisma Client