Next 13: Missing Types for generateStaticParams
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 Binaries: Node: 16.18.0 npm: 8.19.2 Yarn: 1.22.19 pnpm: 7.13.4 Relevant packages: next: 13.0.0 eslint-config-next: 13.0.0 react: 18.2.0 react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
No response
Describe the Bug
A next 13 app with typescript and generateStaticParams
can not be build. The following code works in dev mode, but fails on build:
import { use } from "react";
import { fetchPeople, fetchPeoples } from "../../../lib/people";
type Params = {
id: string;
};
type Props = {
params: Params;
};
const People = ({ params }: Props) => {
const people = use(fetchPeople(params.id));
return (
<>
<h1>{people.name}</h1>
</>
);
};
export const generateStaticParams = async (): Promise<Params[]> => {
const peoples = await fetchPeoples();
const result = peoples.map((people) => ({
id: people.id,
}));
return result;
}
export default People;
The build fails with the following error:
Type error: Page "app/people/[id]/page.tsx" does not match the required types of a Next.js Page.
Invalid configuration:
The exported page component isn't correctly typed.
Expected "Props", got "PageProps".
Invalid configuration:
Expected "Params", got "PageParams | undefined".
Expected "Params", got "undefined".
Sadly i was not able to find the mentioned types of the error.
Have a look at the following discussions for more informations:
- https://github.com/vercel/next.js/discussions/41826#discussioncomment-3966869
- https://github.com/vercel/next.js/discussions/41745#discussioncomment-3971314
Expected Behavior
The example above can be build or the required types are exported.
Link to reproduction
https://github.com/sdorra/next-13-missing-types
To Reproduce
Run pnpm build
in the example repository
Issue Analytics
- State:
- Created a year ago
- Reactions:14
- Comments:17 (1 by maintainers)
I’m currently running
"next": "^13.0.3"
and i still facing same issue when executingnpm run build
. this line of code cause the build to fail:This is the error when executing
npm run build
:I didn’t face any problem during dev(
npm run dev
), I’m not sure whether it’s my fault or the feature got some bugs during build time.NextJS 13 is dope 🚀 , but there is something can be polish. thank you Nextjs Dev member have a nice day 😄. I really hope this can be sort out soon…
I’m facing the same problem during build: