You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 25, 2023. It is now read-only.
Currently when using definePage, either for the pages/ or app directory, if you add any argument to the handler, like to get the params from getStaticPaths or accessing the req for getServerSideProps, then the inferred props for Component break.
To break down what I have worked out so far:
The order you add additional properties to the options parameter can affect whether the type inference works (See example).
My guess is some kind of loop hierarchy bug where because getServerSideProps is before Component it knows to check for inferred props first, but when getServerSideProps is defined after Component it doesn't know getServerSideProps exists to fails over to the default of Record<string, any>?
Only happens when adding a parameter to a handler function, like { params } to getStaticProps.
What's the issue?
Currently when using
definePage
, either for thepages/
or app directory, if you add any argument to the handler, like to get theparams
fromgetStaticPaths
or accessing thereq
forgetServerSideProps
, then the inferred props forComponent
break.To break down what I have worked out so far:
options
parameter can affect whether the type inference works (See example).getServerSideProps
is beforeComponent
it knows to check for inferred props first, but whengetServerSideProps
is defined afterComponent
it doesn't knowgetServerSideProps
exists to fails over to the default ofRecord<string, any>
?{ params }
togetStaticProps
.TS Playground example
I also tried creating a discriminated union type to work around the issue but somehow it broke even more.

Example
✅ This one works perfectly fine
❌ This one does not & sets
props
toRecord<string, any>
The text was updated successfully, but these errors were encountered: