-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
What version of Next.js are you using?
12.0.5-canary.12
What version of Node.js are you using?
12.20.37
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
npm run build
Describe the Bug
After bumping TypeScript version to latest and enforcing strict mode I am presented with a type error for getStaticProps: GetStaticProps when implementing error catching and validation.
Expected Behavior
I would love for Next.js to have a built in type that accounts for TypeScript latest when run strict (as this is the same configuration found when running npx create-next-app@latest --typescript).
In the interim, I'd love any guidance to solve the issue as it stands. I am very new to Next.js and TypeScript and just can't figure out exactly what the type error wants me to do. I'd love to be able to build this application without changing strict to false or decrementing the TypeScript version used.
To Reproduce
If you install the Next.js with TypeScript example found here using npx create-next-app --example with-typescript with-typescript-app but bump the TypeScript version to the latest stable (4.5.2) and update the strict option to true in the tsconfig file you'll get the following error in ./pages/users/[id].tsx:
Which is caused by this TypeScript rule released in v4.4 and true if strict===true. Solving for this issue triggers a type issue for GetStaticProps:
I have a repo here with a handful of commits that demonstrate this process.

