Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic form of GetStaticProps and GetServerSideProps #10856

Merged
merged 8 commits into from Mar 12, 2020
12 changes: 8 additions & 4 deletions packages/next/types/index.d.ts
Expand Up @@ -64,12 +64,14 @@ export {
NextApiHandler,
}

export type GetStaticProps = (ctx: {
export type GetStaticProps<
P extends { [key: string]: any } = { [key: string]: any }
> = (ctx: {
params?: ParsedUrlQuery
preview?: boolean
previewData?: any
}) => Promise<{
props: { [key: string]: any }
props: P
revalidate?: number | boolean
}>

Expand All @@ -78,13 +80,15 @@ export type GetStaticPaths = () => Promise<{
fallback: boolean
}>

export type GetServerSideProps = (context: {
export type GetServerSideProps<
P extends { [key: string]: any } = { [key: string]: any }
> = (context: {
req: IncomingMessage
res: ServerResponse
params?: ParsedUrlQuery
query: ParsedUrlQuery
preview?: boolean
previewData?: any
}) => Promise<{ [key: string]: any }>
}) => Promise<P>
Timer marked this conversation as resolved.
Show resolved Hide resolved

export default next