@@ -636,7 +636,7 @@ export async function renderToHTML(
636636 throw new Error ( invalidKeysMsg ( 'getStaticProps' , invalidKeys ) )
637637 }
638638
639- if ( data . unstable_notFound ) {
639+ if ( 'unstable_notFound' in data && data . unstable_notFound ) {
640640 if ( pathname === '/404' ) {
641641 throw new Error (
642642 `The /404 page can not return unstable_notFound in "getStaticProps", please remove it to continue!`
@@ -649,6 +649,7 @@ export async function renderToHTML(
649649 }
650650
651651 if (
652+ 'unstable_redirect' in data &&
652653 data . unstable_redirect &&
653654 typeof data . unstable_redirect === 'object'
654655 ) {
@@ -662,7 +663,7 @@ export async function renderToHTML(
662663 }
663664
664665 if ( isDataReq ) {
665- data . props = {
666+ ; ( data as any ) . props = {
666667 __N_REDIRECT : data . unstable_redirect . destination ,
667668 }
668669 } else {
@@ -673,15 +674,15 @@ export async function renderToHTML(
673674
674675 if (
675676 ( dev || isBuildTimeSSG ) &&
676- ! isSerializableProps ( pathname , 'getStaticProps' , data . props )
677+ ! isSerializableProps ( pathname , 'getStaticProps' , ( data as any ) . props )
677678 ) {
678679 // this fn should throw an error instead of ever returning `false`
679680 throw new Error (
680681 'invariant: getStaticProps did not return valid props. Please report this.'
681682 )
682683 }
683684
684- if ( typeof data . revalidate === 'number' ) {
685+ if ( 'revalidate' in data && typeof data . revalidate === 'number' ) {
685686 if ( ! Number . isInteger ( data . revalidate ) ) {
686687 throw new Error (
687688 `A page's revalidate option must be seconds expressed as a natural number. Mixed numbers, such as '${ data . revalidate } ', cannot be used.` +
@@ -702,20 +703,25 @@ export async function renderToHTML(
702703 `\nTo only run getStaticProps at build-time and not revalidate at runtime, you can set \`revalidate\` to \`false\`!`
703704 )
704705 }
705- } else if ( data . revalidate === true ) {
706+ } else if ( 'revalidate' in data && data . revalidate === true ) {
706707 // When enabled, revalidate after 1 second. This value is optimal for
707708 // the most up-to-date page possible, but without a 1-to-1
708709 // request-refresh ratio.
709710 data . revalidate = 1
710711 } else {
711712 // By default, we never revalidate.
712- data . revalidate = false
713+ ; ( data as any ) . revalidate = false
713714 }
714715
715- props . pageProps = Object . assign ( { } , props . pageProps , data . props )
716+ props . pageProps = Object . assign (
717+ { } ,
718+ props . pageProps ,
719+ 'props' in data ? data . props : undefined
720+ )
716721 // pass up revalidate and props for export
717722 // TODO: change this to a different passing mechanism
718- ; ( renderOpts as any ) . revalidate = data . revalidate
723+ ; ( renderOpts as any ) . revalidate =
724+ 'revalidate' in data ? data . revalidate : undefined
719725 ; ( renderOpts as any ) . pageData = props
720726 }
721727
0 commit comments