2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

index.d.tsで起きたPrismaPromiseの「Type error: Type expected.」で、vercelにデプロイできない時に確認すべきこと

Posted at

先日、TypeScript+Next.jsのアプリをvercelにデプロイしようとしていたのですが、GitHubリポジトリとvercelを連携して、deployボタンを押したところ以下のエラーが起きて失敗しました。

17:15:42.281  	Failed to compile.
17:15:42.284  	./node_modules/.prisma/client/index.d.ts:10:33
17:15:42.284  	Type error: Type expected.
17:15:42.285  	   8 | export type PrismaPromise<A> = Promise<A> & {[prisma]: true}
17:15:42.285  	   9 | type UnwrapTuple<Tuple extends readonly unknown[]> = {
17:15:42.285  	> 10 |   [K in keyof Tuple]: K extends `${number}` ? Tuple[K] extends PrismaPromise<infer X> ? X : never : never
17:15:42.285  	     |                                 ^
17:15:42.285  	  11 | };

どうやらPrismaPromiseの型定義が間違えているっぽい(?)けど、index.d.tsは一回もいじってないし、と思いつつググっていると、以下のgithub issueを発見。

Bug: Prisma 2.17.0: Type errors in generated client for UnwrapTuple #5726

ここに全てが書いてありました。

どうやら、prismaのバージョンが2.14以降だと、TypeScript 4.1以上が必要らしいです。

自分の使っていたTypeScriptとprismaのバージョンをみてみると、prisma2.17.0TypeScript 3.9.4。これが原因っぽいです。

そこで、以下を実行します。

$ npm update -g typescript

これで、TypeScriptのバージョンは4.2.2になりました。
これで、エディタをみてみると、型のエラーが消えました!

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?