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
Make GetStaticProps and GetServerSideProps types use generic props #11033
Comments
Try out |
Fixed by #10856 |
What about types in context params? in
I get this error
|
You got to check first if context.params is not undefined before destructuring this value |
For anyone looking for a getStaticProps driven approach instead:
Then you can have your component read
|
I can't figure it out as well. I've opened up a discussion → #16522 |
|
Under what circumstances |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Feature request
The
GetStaticProps
andGetServerSideProps
typescript types allow us to use the new data fetching methods with typescript, but there is no type check for props content.Is your feature request related to a problem? Please describe.
The current implementation is as follows:
Describe the solution you'd like
This way, when defining a Props interface in our page, we can have type safety:
Something very similar would be implemented for
GetServerSideProps
.Describe alternatives you've considered
As the new methods are not static properties of pages anymore, we cannot infer them via the page, so the user may need to add the generic
Props
type parameter in many places.Perhaps the types could have more parameters to allow typing
previewData
?The text was updated successfully, but these errors were encountered: