Jonathan
Jonathan
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Jonathan on 6/25/2023 in #questions
Linting errors when building on Vercel that I'm not getting on local machine
Hi all, My build on Vercel is failing because of linting errors. The weird thing is, I'm not getting these errors when building locally at all. This is an excerpt from the build error I'm getting on Vercel:
./src/server/api/trpc.ts
45:9 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
./src/server/db.ts
8:14 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
10:5 Error: Unsafe construction of an any type value. @typescript-eslint/no-unsafe-call
17:36 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
error Command failed with exit code 1.
./src/server/api/trpc.ts
45:9 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
./src/server/db.ts
8:14 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
10:5 Error: Unsafe construction of an any type value. @typescript-eslint/no-unsafe-call
17:36 Error: Unsafe assignment of an `any` value. @typescript-eslint/no-unsafe-assignment
info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
error Command failed with exit code 1.
The errors seem to indicate that I am unsafely assigning values with type "any" and that I am unsafely accessing properties of those values in other files. These errors happen in files that are related to or use Prisma, but when I check these files, there are no "any" types in the files at all. For reference, here's the server/db.ts file that is giving errors:
import { PrismaClient } from "@prisma/client";
import { env } from "@/env.mjs";

const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined;
};

export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
log:
env.NODE_ENV === "development"
? ["query", "error", "warn"]
: ["error"],
});

if (env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
import { PrismaClient } from "@prisma/client";
import { env } from "@/env.mjs";

const globalForPrisma = globalThis as unknown as {
prisma: PrismaClient | undefined;
};

export const prisma =
globalForPrisma.prisma ??
new PrismaClient({
log:
env.NODE_ENV === "development"
? ["query", "error", "warn"]
: ["error"],
});

if (env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;
When hovering over the variables in my editor (VS Code), everything seems to have a proper type. As mentioned before, the build does not fail on my local machine, but does on Vercel. I am asking this question here, because this project was generated using the create-t3-app cli. I hope someone can help me. Please let me know if this question is better to ask elsewhere.
2 replies