Fix type checking for generateStaticParams (#45788

Address the problem reported in
https://github.com/vercel/next.js/discussions/41745#discussioncomment-4936492.

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
This commit is contained in:
Shu Ding 2023-02-10 20:16:38 +01:00 committed by GitHub
parent 946ccb00fc
commit 98d6e47234
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View file

@ -29,7 +29,7 @@ type TEntry = typeof entry
check<IEntry, TEntry>(entry)
type PageParams = Record<string, string>
type PageParams = any
interface PageProps {
params: any
searchParams?: any
@ -54,7 +54,7 @@ interface IEntry {
: `default: PageComponent`
}
config?: {}
generateStaticParams?: (params?: PageParams) => any[] | Promise<any[]>
generateStaticParams?: (args: { params: PageParams }) => any[] | Promise<any[]>
revalidate?: RevalidateRange<TEntry> | false
dynamic?: 'auto' | 'force-dynamic' | 'error' | 'force-static'
dynamicParams?: boolean

View file

@ -0,0 +1,12 @@
export default function page() {
return 'typing'
}
export async function generateStaticParams({
params,
}: {
params: { slug: 'a' | 'b' }
}) {
console.log(params)
return []
}