Error following Next.js open authoring guide

Guide is here: Initial Setup | TinaCMS Docs

yarn run v1.22.10
$ next build
info  - Loaded env from /home/joe/src/new-uniswap-docs/.env
info  - Using webpack 5. Reason: no custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5
Failed to compile.

./pages/index.tsx:87:6
Type error: Spread types may only be created from object types.

  85 |  if (preview) {
  86 |    return getGithubPreviewProps({
> 87 |      ...previewData,
     |      ^
  88 |      fileRelativePath: 'content/home.json',
  89 |      parse: parseJson,
  90 |    })
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

A stackoverflow post suggested changing it to …previewData as {}, but that threw a new error:

Type error: Class static side 'typeof MyDocument' incorrectly extends base class static side 'typeof Document'.
  The types returned by 'getInitialProps(...)' are incompatible between these types.
    Type 'Promise<{ styles: Element; }>' is not assignable to type 'Promise<DocumentInitialProps>'.
      Type '{ styles: JSX.Element; }' is not assignable to type 'DocumentInitialProps'.
        Property 'html' is missing in type '{ styles: JSX.Element; }' but required in type 'RenderPageResult'.

Couldn’t reproduce your issue.

initial-setup on  main [✘!?] is 📦 v0.1.0 via ⬢ v14.17.0 took 1m 28s 
➜ yarn build                                         
yarn run v1.22.10
$ next build
info  - Loaded env from /Users/frank/github/tina/initial-setup/.env
info  - Using webpack 5. Reason: no custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5
info  - Checking validity of types  
info  - Creating an optimized production build  
info  - Compiled successfully
info  - Collecting page data  
info  - Generating static pages (4/4)
info  - Finalizing page optimization  

Page                                 Size     First Load JS
┌ ○ /                                5.9 kB          382 kB
├   └ css/ea6f1f42cebc7b8cbe53.css   675 B
├   /_app                            0 B             376 kB
├ ○ /404                             3.1 kB          379 kB
├ λ /api/create-github-access-token  0 B             376 kB
├ λ /api/hello                       0 B             376 kB
├ λ /api/preview                     0 B             376 kB
├ λ /api/proxy-github                0 B             376 kB
├ λ /api/reset-preview               0 B             376 kB
└ ○ /github/authorizing              328 B           377 kB
+ First Load JS shared by all        376 kB
  ├ chunks/framework.44ddc8.js       42.4 kB
  ├ chunks/main.c9abfc.js            19.6 kB
  ├ chunks/pages/_app.93946f.js      313 kB
  ├ chunks/webpack.277c75.js         1.04 kB
  └ css/01db3197b29cb52779ce.css     203 B

λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
○  (Static)  automatically rendered as static HTML (uses no initial props)
●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
   (ISR)     incremental static regeneration (uses revalidate in getStaticProps)

✨  Done in 17.49s.

Can you send me your repo and I can compare?

I forked the original repository, updated tinacms packages and ran yarn build and had no error…

Rather than just copy-pasting the error, please explain what you did to get there.

I just followed the tutorial and ended up with this error.

Should I fork the repo instead?

If your goal is to quickly get started for a Next.js app and benefit from open authoring, yes.

@frmlbovcocrhufnijpxt Thanks for your question! If you wish do have a relatively easier experience and better content modelling while still saving your data to Github (no open authoring at the moment) you should checkout Tina Cloud. Although you will loose open authoring you will gain some benefits such is user management and a GraphQL API.

Getting started repo: GitHub - tinacms/tina-cloud-starter: Next.js starter for Git-backed editing with Tina Cloud - Fork this project to get started!
Guide: Overview | TinaCMS Docs
Docs: Tina Cloud | TinaCMS Docs

There is actually a pull request that solves that issue:

import previewData from next-tinacms-github and set it like this
...(previewData as PreviewData<any>)

I think all Documentation needs to be replaced like this, as it comes up fairly often.