Vercel: "Linting and checking validity of types" fails on deploy but passes locally

Viewed 718

When running locally, I can run "next build" without problems. The command "vercel build" also works without problems. But as soon as I deploy to vercel, the "Linting and checking validity of types" fails when it's being built on vercel. Typescript is set to strict mode, but it is as if it's even stricter in when running in vercel even though it's the same codebase.

The app is based on the create-t3 app. It stops building on vercel as soon as I add a "select" statement in a prisma findUnique query. Such as in the "check-credentials" file.

In the console in vercel, it would output the following error:

info  - Linting and checking validity of types...
Failed to compile.
./src/pages/api/user/check-credentials.ts:33:7
Type error: Type '{ id: true; name: true; email: true; image: true; password: true; }' is not assignable to type 'UserSelect'.
  Object literal may only specify known properties, and 'password' does not exist in type 'UserSelect'.
  31 |       email: true,
  32 |       image: true,
> 33 |       password: true,
     |       ^
  34 |     },
  35 |   });
  36 |   if (user && user.password == hashPassword(req.body.password)) {

I have created a clone of the repository, as my best guess is that there might be a problem with ts validation and linting being ignored locally, but not on deploys: https://github.com/Andreaswt/t3-app

1 Answers

Looks like an error where your Prisma schema in CI compiles to a different output than whatever your local Prisma schema is compiling to. I'm unfamiliar with t3, but it seems that you're changing the Prisma schema without also recompiling the underlying Prisma client. You probably need to run db-generate-client to keep backend functionality in sync with your schema.

Related