Prisma1: makePrismaClientClass has incorrect TS signature

Created on 14 Nov 2018  路  20Comments  路  Source: prisma/prisma1

Describe the bug
The function argument signature for prisma-client-lib/makePrismaClientClass appears to be incorrect. The module declaration is as follows:

import { Model } from './types';
export declare function makePrismaClientClass<T>({ typeDefs, endpoint, secret, models, }: {
    typeDefs: string;
    endpoint: string;
    secret?: string;
    models: Model[];
}): T;

The relevant portion of my generated prisma-client/index.ts is:

/**
 * Type Defs
 */

export const Prisma = makePrismaClientClass<ClientConstructor<Prisma>>({
  typeDefs,
  endpoint: `http://localhost:4466/prisma/dev`
});
export const prisma = new Prisma();

The generated error from tsc is:

src/prisma-client/index.ts:1359:72 - error TS2345: Argument of type '{ typeDefs: string; endpoint: string; }' is not assignable to parameter of type '{ typeDefs: string; endpoint: string; secret?: string; models: Model[]; }'.
  Property 'models' is missing in type '{ typeDefs: string; endpoint: string; }'.

Unless I'm missing something, it appears that models should also be marked as optional - eg

models?: Model[]

To Reproduce
Steps to reproduce the behavior:

  1. Create a new local Prisma deployment using the instructions listed here for the TypeScript default config.
  2. docker-compose up -d
  3. prisma deploy
  4. prisma generate

Expected behavior
No errors are thrown by tsc.

Versions (please complete the following information):

  • OS: Ubuntu 18.10
  • prisma CLI: prisma/1.20.1 (linux-x64) node-v11.0.0
  • Prisma Server: prismagraphql/prisma:1.20
bu2-confirmed areclients

Most helpful comment

Thanks for reporting @superhawk610 ! We just released 1.20.5 bringing the client and the cli back in sync!
When you're now generating the client with [email protected] and use [email protected] it should work as expected.

If that is not the case, please let us know and we reopen this issue!

All 20 comments

Additional context
I'm using prisma-client inside a custom Express deployment of Next.js. Here's my tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "lib": ["es2017", "esnext.asynciterable"],
    "outDir": "ts-built",
    "rootDir": "src",
    "jsx": "react",
    "inlineSourceMap": true,
    "noImplicitAny": true,
    "removeComments": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "skipLibCheck": true
  },
  "include": ["**/*"],
  "exclude": ["node_modules", "ts-built"]
}

@superhawk610 I'm also getting this typescript compilation error too, and many others too. Let's hope somebody takes a look into all these typescript errors because it's important.

@chanlito What other errors are you seeing? I had 20 or so upon first compile, I had to install @types/ws and modify my tsconfig.json like so:

{
  "compilerOptions": {
    "skipLibCheck": true
  }
}

As a temporary fix, you can add the following file at @types/prisma-client-lib/makePrismaClientClass.d.ts to your project:

import { Model } from 'prisma-client-lib/types';

declare module 'prisma-client-lib' {
  export declare function makePrismaClientClass<T>({
    typeDefs,
    endpoint,
    secret,
    models,
  }: {
    typeDefs: string;
    endpoint: string;
    secret?: string;
    models?: Model[];
  }): T;
}

I had to add models: [] to the generated file to fix this issue.

I experience the same error. I wonder why this was not caught in a test?

It's a regression around prisma-client-lib, I think.

I had not the error before upgrading it from [email protected] to [email protected].

Can you guys (@superhawk610 @JensMadsen @chanlito) confirm your prisma-client-lib version is superior to 1.20.1 ?

Alright, it's indeed a regression.

yarn remove prisma-client-lib && yarn add [email protected] fixes the issue.

@kevinmarrec I'm using [email protected] and I'm pretty sure it's a regression bug.

@kevinmarrec i was on 1.20.3 doing yarn remove prisma-client-lib && yarn add [email protected] as you suggested fixed the issue for me. Thanks :-)

@tadejstanic Yes it's sure
@JensMadsen No problem, Prisma team is working on a patch :)

Thanks for reporting @superhawk610 ! We just released 1.20.5 bringing the client and the cli back in sync!
When you're now generating the client with [email protected] and use [email protected] it should work as expected.

If that is not the case, please let us know and we reopen this issue!

I seem to be having this issue with newer versions:

[email protected] and [email protected]

@forgo I was facing the same issue., fixed by install latest version of prisma via npm (previously installed via homebrew)

I think it's on [email protected] as well

I was also getting this error on [email protected]. I downgraded it to version 1.20.1 for now.

Had the same problem on my machine but downgrading both versions to 1.20.5 worked for me. The second time the last 2 weeks I had to spend time fixing stuff that should not break in the first place...

So I'm currently facing an issue that has been fixed in 1.20.7 but I'm unsure whether I can safely update to the newest version yet. Any updates?

The issue I'm talking about is #3520

Keep the prisma and prisma-client-lib in the same version.

npm install --save prisma-client-lib
npm install -g prisma

Generate new files with correct lib version

prisma generate
Was this page helpful?
0 / 5 - 0 ratings

Related issues

marktani picture marktani  路  3Comments

AlessandroAnnini picture AlessandroAnnini  路  3Comments

nikolasburk picture nikolasburk  路  3Comments

akoenig picture akoenig  路  3Comments

jannone picture jannone  路  3Comments