How do I fix this ts-toolbelt TypeScript TypeError on Vercel deployment for a Next.js app?

This is the error I'm getting

In my portfolio app, I'm trying to merge a PR into the main branch, which contains code to implement React Query. The app works fine on development but when I try to deploy it, Vercel gives me the error above that apparently occurs when they try to build my app.

I tried installing ts-toolbelt as a dependency but it doesn't seem to work.

Here's the project's repo and precisely to the failing PR (You wont' get access to the vercel deployment details as it's my account, but every error that appears is shown in the picture above)

Upvotes: 0

Views: 363

Answers (1)

Pedro Brás
Pedro Brás

Reputation: 11

Same thing happened to me and after some research looks like the ts-toolbar version that comes in the React-Query package is not compatible with the Typescript version my React app is using.

To fix it I added a resolutions field on the package.json to force the ts-toolbelt dependency to a compatible version, like so:

"resolutions": {
   "ts-toolbelt": "6.15.5"
}

6.15.5 being the ts-toolbelt version compatible with my Typescript version (3.8.3)

Then running yarn install solved the issue for me.

Upvotes: 1

Related Questions