Buuntu / fastapi-react

🚀 Cookiecutter Template for FastAPI + React Projects. Using PostgreSQL, SQLAlchemy, and Docker
MIT License
2.19k stars 349 forks source link

Typescript errors on default install/up #187

Open mkbt opened 2 years ago

mkbt commented 2 years ago

Hi there,

I'm getting a bunch of Typescript errors in the browser console when bringing the docker-compose file up from defaults.

VM111:2 Uncaught ReferenceError: process is not defined
    at Object.4043 (<anonymous>:2:13168)
    at r (<anonymous>:2:306599)
    at Object.8048 (<anonymous>:2:9496)
    at r (<anonymous>:2:306599)
    at Object.8641 (<anonymous>:2:1379)
    at r (<anonymous>:2:306599)
    at <anonymous>:2:315627
    at <anonymous>:2:324225
    at <anonymous>:2:324229
    at HTMLIFrameElement.e.onload (index.js:1:1)
TypeScript error in /app/src/index.tsx(8,4):
'Router' cannot be used as a JSX component.
  Its instance type 'BrowserRouter' is not a valid JSX element.
    The types returned by 'render()' are incompatible between these types.
      Type 'React.ReactNode' is not assignable to type 'import("/node_modules/@types/react-transition-group/node_modules/@types/react/index").ReactNode'.  TS2786

     6 | 
     7 | ReactDOM.render(
  >  8 |   <Router>
       |    ^
     9 |     <App />
    10 |   </Router>,
    11 |   document.getElementById('root')

Is there a dependancy I'm missing?

I tried building from the latest commits via a fork mentioned at https://github.com/Buuntu/fastapi-react/issues/177 but still ran into further issues.

gegnew commented 2 years ago

Any update on this? Also curious

hung96ad commented 2 years ago

i same you :(

aeciorc commented 2 years ago

Update typescript to 4.1.0, then add this to your package.json at the root level:

 "resolutions": {
    "@types/react": "^17.0.38"
  },

You're still going to run into a ton of other issues though, from dependency mismatches to missing libraries. Fixing the MUI issues will be a pain. I honestly think it's not worth using the frontend portion of this app at all.