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 { ...@@ -72,14 +72,18 @@ export {
NextApiHandler, NextApiHandler,
} }
export type GetStaticProps< export type GetStaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery> = {
P extends { [key: string]: any } = { [key: string]: any },
Q extends ParsedUrlQuery = ParsedUrlQuery
> = (ctx: {
params?: Q params?: Q
preview?: boolean preview?: boolean
previewData?: any previewData?: any
}) => Promise<{ }
export type GetStaticProps<
P extends { [key: string]: any } = { [key: string]: any },
Q extends ParsedUrlQuery = ParsedUrlQuery
> = (
ctx: GetStaticPropsContext<Q>
) => Promise<{
props: P props: P
unstable_revalidate?: number | boolean unstable_revalidate?: number | boolean
}> }>
...@@ -91,16 +95,20 @@ export type GetStaticPaths< ...@@ -91,16 +95,20 @@ export type GetStaticPaths<
fallback: boolean fallback: boolean
}> }>
export type GetServerSideProps< export type GetServerSidePropsContext<
P extends { [key: string]: any } = { [key: string]: any },
Q extends ParsedUrlQuery = ParsedUrlQuery Q extends ParsedUrlQuery = ParsedUrlQuery
> = (context: { > = {
req: IncomingMessage req: IncomingMessage
res: ServerResponse res: ServerResponse
params?: Q params?: Q
query: ParsedUrlQuery query: ParsedUrlQuery
preview?: boolean preview?: boolean
previewData?: any 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 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