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

Consistently Type GS(S)P #10757

Merged
merged 1 commit into from Feb 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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