Skip to content

Commit

Permalink
Consistently Type GS(S)P
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Feb 29, 2020
1 parent e608c86 commit 1b3bc5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions packages/next/next-server/server/render.tsx
Expand Up @@ -471,11 +471,7 @@ export async function renderToHTML(
// invoke, where we'd have to consider server & serverless.
const previewData = tryGetPreviewData(req, res, previewProps)
const data = await getStaticProps!({
...(pageIsDynamic
? {
params: query as ParsedUrlQuery,
}
: { params: undefined }),
...(pageIsDynamic ? { params: query as ParsedUrlQuery } : undefined),
...(previewData !== false
? { preview: true, previewData: previewData }
: undefined),
Expand Down Expand Up @@ -534,10 +530,10 @@ export async function renderToHTML(

if (getServerSideProps && !isFallback) {
const data = await getServerSideProps({
params,
query,
req,
res,
...(pageIsDynamic ? { params: params as ParsedUrlQuery } : undefined),
query,
})

const invalidKeys = Object.keys(data).filter(key => key !== 'props')
Expand Down
4 changes: 2 additions & 2 deletions packages/next/types/index.d.ts
Expand Up @@ -65,7 +65,7 @@ export {
}

export type GetStaticProps = (ctx: {
params: ParsedUrlQuery | undefined
params?: ParsedUrlQuery
preview?: boolean
previewData?: any
}) => Promise<{
Expand All @@ -79,9 +79,9 @@ export type GetStaticPaths = () => Promise<{
}>

export type GetServerSideProps = (context: {
params: ParsedUrlQuery | undefined
req: IncomingMessage
res: ServerResponse
params?: ParsedUrlQuery
query: ParsedUrlQuery
}) => Promise<{ [key: string]: any }>

Expand Down

0 comments on commit 1b3bc5c

Please sign in to comment.