Skip to content

Commit

Permalink
Updated docs for getServerSideProps and getStaticProps return values (v…
Browse files Browse the repository at this point in the history
…ercel#33577)

This fixes the documentation for getServerSideProps and getStaticProps which mislead the defined type.

Current screenshot taken from [nextjs doc](https://nextjs.org/docs/api-reference/data-fetching/get-server-side-props)

![image](https://user-images.githubusercontent.com/5223310/150689799-5da3c1b6-61ae-4455-8970-8c96f025474a.png)

However, the declared type for these types are using union type which represents **any of the following** instead of **optional**.

Declared types;
[GetStaticPropsResult](https://github.com/vercel/next.js/blob/canary/packages/next/types/index.d.ts#L107)
![image](https://user-images.githubusercontent.com/5223310/150689919-5f3cf8f8-60d3-48e4-9412-993e2ead0634.png)

[GetServerSidePropsResult](https://github.com/vercel/next.js/blob/canary/packages/next/types/index.d.ts#L160)
![image](https://user-images.githubusercontent.com/5223310/150689931-16fe3bef-eb4e-41cd-b087-98c3282d599d.png)

---

### This PR updates the documentation for their return values;

**Before**: The `...` function should return an object with the following **optional** properties:
**After**: The `...` function should return object with **any one of the following** properties:

---



## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`


Co-authored-by: Vadi Taslim <70912283+vaditaslim@users.noreply.github.com>
  • Loading branch information
2 people authored and natew committed Feb 16, 2022
1 parent 175968c commit 8c3a76e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference/data-fetching/get-server-side-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The `context` parameter is an object containing the following keys:

## getServerSideProps return values

The `getServerSideProps` function should return an object with the following **optional** properties:
The `getServerSideProps` function should return an object with **any one of the following** properties:

### `props`

Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/data-fetching/get-static-props.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The `context` parameter is an object containing the following keys:

## getStaticProps return values

The `getStaticProps` function should return an object with the following **optional** properties:
The `getStaticProps` function should return an object containing either `props`, `redirect`, or `notFound` followed by an **optional** `revalidate` property.

### `props`

Expand Down

0 comments on commit 8c3a76e

Please sign in to comment.