t3-oss / create-t3-app

The best way to start a full-stack, typesafe Next.js app
https://create.t3.gg
MIT License
24.88k stars 1.15k forks source link

bug: "Error: Unsafe assignment of an `any` value" when trying to run "npm run build" on a new scaffolded app #1751

Closed tomagrab closed 7 months ago

tomagrab commented 7 months ago

Provide environment information

System: OS: Windows 10 10.0.19045 CPU: (6) x64 Intel(R) Xeon(R) Gold 6154 CPU @ 3.00GHz Memory: 2.73 GB / 10.00 GB Binaries: Node: 21.1.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD npm: 9.6.6 - C:\Program Files\nodejs\npm.CMD

"ct3aMetadata": {
"initVersion": "7.26.0"

},

Describe the bug

After scaffolding a new T3 app, I ran "npm run build" and received the following errors:

./src/app/page.tsx 54:9 Error: Unsafe assignment of an any value. @typescript-eslint/no-unsafe-assignment 59:68 Error: Unsafe member access .name on an any value. @typescript-eslint/no-unsafe-member-access

This error also happens in production when attempting to deploy to Vercel.

Reproduction repo

https://github.com/tomagrab/chirp

To reproduce

npm create t3-app@latest Need to install the following packages: create-t3-app@7.26.0 Ok to proceed? (y) │ ◇ What will your project be called? │ chirp │ ◇ Will you be using TypeScript or JavaScript? │ TypeScript │ ◇ Will you be using Tailwind CSS for styling? │ Yes │ ◇ Would you like to use tRPC? │ Yes │ ◇ What authentication provider would you like to use? │ None │ ◇ What database ORM would you like to use? │ Prisma │ ◇ EXPERIMENTAL Would you like to use Next.js App Router? │ Yes │ ◇ What database provider would you like to use? │ PostgreSQL │ ◇ Should we initialize a Git repository and stage the changes? │ Yes │ ◇ Should we run 'npm install' for you? │ Yes │ ◇ What import alias would you like to use? │ @/

Using: npm

✔ chirp scaffolded successfully!

Adding boilerplate... ✔ Successfully setup boilerplate for prisma ✔ Successfully setup boilerplate for tailwind ✔ Successfully setup boilerplate for trpc ✔ Successfully setup boilerplate for dbContainer ✔ Successfully setup boilerplate for envVariables

Installing dependencies... ✔ Successfully installed dependencies!

Initializing Git... ✔ Successfully initialized and staged git

Next steps: cd chirp ./start-database.sh npm run db:push npm run dev git commit -m "initial commit"

Thank you for trying out the App Router option. If you encounter any issues, please open an issue!

cd chirp
npm run build

chirp@0.1.0 build next build

▲ Next.js 14.1.0

Failed to compile.

./src/app/page.tsx 54:9 Error: Unsafe assignment of an any value. @typescript-eslint/no-unsafe-assignment 59:68 Error: Unsafe member access .name on an any value. @typescript-eslint/no-unsafe-member-access

info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules Linting and checking validity of types

Additional information

No response

rayhankinan commented 7 months ago

I have this exact same issue when using Prisma. It seems that the generated type is not linked to the "db" object.

Screenshot 2024-02-01 at 22 34 26
opmaominc commented 7 months ago

i have the same issue @tomagrab did you end up figuring out a solution?

tomagrab commented 7 months ago

opmaominc

No solution yet ☹️

iamtheozzy commented 7 months ago

upgrading prisma and @prisma/client to latest and then i also restarted the eslint server and that seemed to fix it

tomagrab commented 7 months ago

@iamtheozzy @opmaominc

I simply ran:

npm i

Then I was able to successfully build the project 😄

I'm not sure if something changed because this was not working beforehand. Did not need to restart the eslint server.