-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Closed
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.
Description
Bug report
Describe the bug
In this PR the type of GetServerSidePropsResult was updated which breaks it because the | chain is a collection of incompatible types.
This is the TS error:
Property 'props' does not exist on type 'GetServerSidePropsResult<ServerSidePropsResult>'.
Property 'props' does not exist on type '{ redirect: Redirect; }'.
When you do something like this:
const { ssrPayload } = (serverSidePropsResult).props;Even typecasting doesn't work:
const { ssrPayload } = (serverSidePropsResult as GetServerSidePropsResult<
ServerSidePropsResult
>).props;I'm not sure how this should be fixed, maybe we should add this GetServerSidePropsResult as generic, like so:
export type GetServerSideProps<
P extends { [key: string]: any } = { [key: string]: any },
ResultType = GetServerSidePropsResult<P>,
Q extends ParsedUrlQuery = ParsedUrlQuery
> = (
context: GetServerSidePropsContext<Q>
) => Promise<ResultType>... and then have different types for notFound and redirect.
Expected behavior
The types not to trigger an error.
Metadata
Metadata
Assignees
Labels
bugIssue was opened via the bug report template.Issue was opened via the bug report template.