Unverified Commit 547bf460 authored by Justin's avatar Justin Committed by GitHub

Context types for getStaticProps and getServerSideProps (#12606)

parent 8d024554
......@@ -72,14 +72,18 @@ export {
NextApiHandler,
}
export type GetStaticProps<
P extends { [key: string]: any } = { [key: string]: any },
Q extends ParsedUrlQuery = ParsedUrlQuery
> = (ctx: {
export type GetStaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery> = {
params?: Q
preview?: boolean
previewData?: any
}) => Promise<{
}
export type GetStaticProps<
P extends { [key: string]: any } = { [key: string]: any },
Q extends ParsedUrlQuery = ParsedUrlQuery
> = (
ctx: GetStaticPropsContext<Q>
) => Promise<{
props: P
unstable_revalidate?: number | boolean
}>
......@@ -91,16 +95,20 @@ export type GetStaticPaths<
fallback: boolean
}>
export type GetServerSideProps<
P extends { [key: string]: any } = { [key: string]: any },
export type GetServerSidePropsContext<
Q extends ParsedUrlQuery = ParsedUrlQuery
> = (context: {
> = {
req: IncomingMessage
res: ServerResponse
params?: Q
query: ParsedUrlQuery
preview?: boolean
previewData?: any
}) => Promise<{ props: P }>
}
export type GetServerSideProps<
P extends { [key: string]: any } = { [key: string]: any },
Q extends ParsedUrlQuery = ParsedUrlQuery
> = (context: GetServerSidePropsContext<Q>) => Promise<{ props: P }>
export default next
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment