Unverified Commit 11fce3a6 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Remove unstable_ prefix from unstable_notFound (#18283)

Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: 's avatarJoe Haddad <joe.haddad@zeit.co>
parent 7cb68f79
...@@ -625,7 +625,7 @@ export async function renderToHTML( ...@@ -625,7 +625,7 @@ export async function renderToHTML(
key !== 'revalidate' && key !== 'revalidate' &&
key !== 'props' && key !== 'props' &&
key !== 'redirect' && key !== 'redirect' &&
key !== 'unstable_notFound' key !== 'notFound'
) )
if (invalidKeys.includes('unstable_revalidate')) { if (invalidKeys.includes('unstable_revalidate')) {
...@@ -636,10 +636,10 @@ export async function renderToHTML( ...@@ -636,10 +636,10 @@ export async function renderToHTML(
throw new Error(invalidKeysMsg('getStaticProps', invalidKeys)) throw new Error(invalidKeysMsg('getStaticProps', invalidKeys))
} }
if ('unstable_notFound' in data && data.unstable_notFound) { if ('notFound' in data && data.notFound) {
if (pathname === '/404') { if (pathname === '/404') {
throw new Error( throw new Error(
`The /404 page can not return unstable_notFound in "getStaticProps", please remove it to continue!` `The /404 page can not return notFound in "getStaticProps", please remove it to continue!`
) )
} }
...@@ -759,10 +759,14 @@ export async function renderToHTML( ...@@ -759,10 +759,14 @@ export async function renderToHTML(
} }
const invalidKeys = Object.keys(data).filter( const invalidKeys = Object.keys(data).filter(
(key) => (key) => key !== 'props' && key !== 'redirect' && key !== 'notFound'
key !== 'props' && key !== 'redirect' && key !== 'unstable_notFound'
) )
if ((data as any).unstable_notFound) {
throw new Error(
`unstable_notFound has been renamed to notFound, please update the field to continue. Page: ${pathname}`
)
}
if ((data as any).unstable_redirect) { if ((data as any).unstable_redirect) {
throw new Error( throw new Error(
`unstable_redirect has been renamed to redirect, please update the field to continue. Page: ${pathname}` `unstable_redirect has been renamed to redirect, please update the field to continue. Page: ${pathname}`
...@@ -773,10 +777,10 @@ export async function renderToHTML( ...@@ -773,10 +777,10 @@ export async function renderToHTML(
throw new Error(invalidKeysMsg('getServerSideProps', invalidKeys)) throw new Error(invalidKeysMsg('getServerSideProps', invalidKeys))
} }
if ('unstable_notFound' in data) { if ('notFound' in data) {
if (pathname === '/404') { if (pathname === '/404') {
throw new Error( throw new Error(
`The /404 page can not return unstable_notFound in "getStaticProps", please remove it to continue!` `The /404 page can not return notFound in "getStaticProps", please remove it to continue!`
) )
} }
......
...@@ -88,7 +88,7 @@ export type GetStaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery> = { ...@@ -88,7 +88,7 @@ export type GetStaticPropsContext<Q extends ParsedUrlQuery = ParsedUrlQuery> = {
export type GetStaticPropsResult<P> = export type GetStaticPropsResult<P> =
| { props: P; revalidate?: number | boolean } | { props: P; revalidate?: number | boolean }
| { redirect: Redirect; revalidate?: number | boolean } | { redirect: Redirect; revalidate?: number | boolean }
| { unstable_notFound: true } | { notFound: true }
export type GetStaticProps< export type GetStaticProps<
P extends { [key: string]: any } = { [key: string]: any }, P extends { [key: string]: any } = { [key: string]: any },
...@@ -133,7 +133,7 @@ export type GetServerSidePropsContext< ...@@ -133,7 +133,7 @@ export type GetServerSidePropsContext<
export type GetServerSidePropsResult<P> = export type GetServerSidePropsResult<P> =
| { props: P } | { props: P }
| { redirect: Redirect } | { redirect: Redirect }
| { unstable_notFound: true } | { notFound: true }
export type GetServerSideProps< export type GetServerSideProps<
P extends { [key: string]: any } = { [key: string]: any }, P extends { [key: string]: any } = { [key: string]: any },
......
...@@ -22,7 +22,7 @@ export default function Page(props) { ...@@ -22,7 +22,7 @@ export default function Page(props) {
export const getServerSideProps = ({ query }) => { export const getServerSideProps = ({ query }) => {
if (query.hiding) { if (query.hiding) {
return { return {
unstable_notFound: true, notFound: true,
} }
} }
......
...@@ -22,7 +22,7 @@ export default function Page(props) { ...@@ -22,7 +22,7 @@ export default function Page(props) {
export const getServerSideProps = ({ query }) => { export const getServerSideProps = ({ query }) => {
if (query.hiding) { if (query.hiding) {
return { return {
unstable_notFound: true, notFound: true,
} }
} }
......
...@@ -26,7 +26,7 @@ export default function Page(props) { ...@@ -26,7 +26,7 @@ export default function Page(props) {
export const getStaticProps = ({ params, locale, locales }) => { export const getStaticProps = ({ params, locale, locales }) => {
if (locale === 'en' || locale === 'nl') { if (locale === 'en' || locale === 'nl') {
return { return {
unstable_notFound: true, notFound: true,
} }
} }
......
...@@ -24,7 +24,7 @@ export default function Page(props) { ...@@ -24,7 +24,7 @@ export default function Page(props) {
export const getStaticProps = ({ locale, locales }) => { export const getStaticProps = ({ locale, locales }) => {
if (locale === 'en' || locale === 'nl') { if (locale === 'en' || locale === 'nl') {
return { return {
unstable_notFound: true, notFound: true,
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment