create-react-app
                                
                                 create-react-app copied to clipboard
                                
                                    create-react-app copied to clipboard
                            
                            
                            
                        export * from, and module has no exports
Hey 👋
I'm having some kind of issue while importing/exporting modules when using index files.
I'm having my repo this way:
- /src
- /services
- index.ts
- /serviceA
- index.ts
- serviceA.ts
 
- /serviceB
- index.ts
- serviceB.ts
 
 
 
- /services
My index.ts files in each service do
export * from "./serviceX";
And the index file in the folder /services does:
export * from "./serviceA";
export * from "./serviceB";
In another file i do:
import { serviceA } from "services";
At first, it works and it imports the module finely. But I've noticed that when I switch of git branch, and then come back to the previous branch: those kind of import don't work anymore (when it was working originally).
I've been working on a couple of branches, then after some merges, when checking out the main branch, all the previous work is bugged due to this issue.
However, for now I've been able to find another way to do those export, which is this way:
export { serviceA } from "./serviceA";
Then the imports work fine, but I still find it more comfortable to use * instead of naming each module.
the project use:
- react-scripts: 5.0.1
- yarn: 3.2.1
Thanks everyone, have a nice day 🖖
doesn't seem like create-react-app issue
just add these properties to tsconfig.json { "compilerOptions": { "baseUrl": "./src", }, "include":["src"] }
or import like "./services" instead of "services"
Hey @sunil-sharma-999 👋 I've been using those properties for a couple of days to see how it goes, but I still have the problem with typescript from time to time. I suspect some kind of problem with some sort of caching of the dev server.
@Vincent-Alexandrine Probably caching issue i guess. I don't use typescript much but whenever i use it the typescript linting lags a bit.
Hey :wave:
Thanks you, the solution seems to write ./src instead of src for both baseUrl and include.
I hit the same problem in my project. But using ./src in baseUrl and include did not help.
UPDATE: It actually worked. weird.