@@ -636,7 +636,7 @@ export async function renderToHTML(
636
636
throw new Error ( invalidKeysMsg ( 'getStaticProps' , invalidKeys ) )
637
637
}
638
638
639
- if ( data . notFound ) {
639
+ if ( 'notFound' in data && data . notFound ) {
640
640
if ( pathname === '/404' ) {
641
641
throw new Error (
642
642
`The /404 page can not return notFound in "getStaticProps", please remove it to continue!`
@@ -649,6 +649,7 @@ export async function renderToHTML(
649
649
}
650
650
651
651
if (
652
+ 'unstable_redirect' in data &&
652
653
data . unstable_redirect &&
653
654
typeof data . unstable_redirect === 'object'
654
655
) {
@@ -662,7 +663,7 @@ export async function renderToHTML(
662
663
}
663
664
664
665
if ( isDataReq ) {
665
- data . props = {
666
+ ; ( data as any ) . props = {
666
667
__N_REDIRECT : data . unstable_redirect . destination ,
667
668
}
668
669
} else {
@@ -673,15 +674,15 @@ export async function renderToHTML(
673
674
674
675
if (
675
676
( dev || isBuildTimeSSG ) &&
676
- ! isSerializableProps ( pathname , 'getStaticProps' , data . props )
677
+ ! isSerializableProps ( pathname , 'getStaticProps' , ( data as any ) . props )
677
678
) {
678
679
// this fn should throw an error instead of ever returning `false`
679
680
throw new Error (
680
681
'invariant: getStaticProps did not return valid props. Please report this.'
681
682
)
682
683
}
683
684
684
- if ( typeof data . revalidate === 'number' ) {
685
+ if ( 'revalidate' in data && typeof data . revalidate === 'number' ) {
685
686
if ( ! Number . isInteger ( data . revalidate ) ) {
686
687
throw new Error (
687
688
`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(
702
703
`\nTo only run getStaticProps at build-time and not revalidate at runtime, you can set \`revalidate\` to \`false\`!`
703
704
)
704
705
}
705
- } else if ( data . revalidate === true ) {
706
+ } else if ( 'revalidate' in data && data . revalidate === true ) {
706
707
// When enabled, revalidate after 1 second. This value is optimal for
707
708
// the most up-to-date page possible, but without a 1-to-1
708
709
// request-refresh ratio.
709
710
data . revalidate = 1
710
711
} else {
711
712
// By default, we never revalidate.
712
- data . revalidate = false
713
+ ; ( data as any ) . revalidate = false
713
714
}
714
715
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
+ )
716
721
// pass up revalidate and props for export
717
722
// 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
719
725
; ( renderOpts as any ) . pageData = props
720
726
}
721
727
0 commit comments