-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Docs: getStaticProps & InferGetStaticPropsType | TypeScript #40607
Comments
Thanks for pointing this out, want to open a PR? Here is the file that needs to be edited: https://github.com/vercel/next.js/blob/canary/docs/api-reference/data-fetching/get-static-props.md |
Thank you for the answer and for specifying a documentation file, the link to the PR will be there tomorrow. |
Here is a PR: #40639 |
Added examples to `getStaticProps` & `getServerSideProps` explicit and implicit typings for TypeScript. Related issues: fixes #40607 Co-authored-by: Balázs Orbán <[email protected]>
…ercel#40639) Added examples to `getStaticProps` & `getServerSideProps` explicit and implicit typings for TypeScript. Related issues: fixes vercel#40607 Co-authored-by: Balázs Orbán <[email protected]>
…ercel#40639) Added examples to `getStaticProps` & `getServerSideProps` explicit and implicit typings for TypeScript. Related issues: fixes vercel#40607 Co-authored-by: Balázs Orbán <[email protected]>
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What is the improvement or update you wish to see?
In the documentation, it is advised to type getStaticProps first, and then in the example with InferGetStaticPropsType, getStaticProps is not typed. The documentation should specify this type behavior explicitly. All examples of type behavior are listed in the examples below.
The same with the other rendering methods
Is there any context that might help us understand?
Example 1. InferGetStaticPropsType is working as expected. Object
posts
in page Posts is typetypes.Post[]
.Example 2. The same as in the previous example, but the getStaticProps type is specified implicitly. This example is listed in the documentation.
Example 3. InferGetStaticPropsType is not working. Object
posts
in page Posts is typeany
.Does the docs page already exist? Please link to it.
https://nextjs.org/docs/api-reference/data-fetching/get-static-props#getstaticprops-with-typescript
The text was updated successfully, but these errors were encountered: