piotrwitek / react-redux-typescript-realworld-app

RealWorld App implementation based on "react-redux-typescript-guide"
https://react-redux-typescript-realworld-app.netlify.com/
250 stars 75 forks source link

Question about namespace declarations #7

Open batusai513 opened 5 years ago

batusai513 commented 5 years ago

Hi, I'am checking this repo for resources on how to estructure a TS project and I saw something interesting, https://github.com/piotrwitek/react-redux-typescript-realworld-app/blob/master/src/services/types.d.ts you are declaring all your types inside a namespace, I was trying to replicate this on my app created with create-react-app but I'm getting a module not found error, so I wanted to ask how do you make those namespace declarations import works in here.

Thanks

michalpopek commented 5 years ago

That's a good question, I'm facing the same issue when trying to replicate this setup using the latest CRA (react-scripts@3.1.1). Any hints on how to fix that?

piotrwitek commented 5 years ago

You must be doing something differently, please check and use the same exact syntax.
Please do not try to change the structure or file extensions, keep everything the same. Only when you have it working you can experiment and change things one by one to find out where is the problem.

senpl commented 4 years ago

I think the tricky part is that types are declared and exported in many places, not only in /services, but also in /store. So if they will be only in one place it will not work. It has to be in both. This might be related: https://stackoverflow.com/questions/59864992/local-project-module-not-found/59867006#59867006 .