You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Furthermore I'd re-export the types in index.tsx as follows:
export { FooComponent, IFooComponentProps } from "./FooComponent";
Unfortunately CRA does not allow me to disable isolatedModules in the tsconfig.json and the compiler is complaining about re-exporting IFooComponentProps. In my use case I have an IFooComponentProps[] in another file that I am using to dynamically create FooComponents. It seems I have to move my props interface into separate files (especially when I use stateful components) which is just unnecessarily increasing the amount of files.
I'd like to know why CRA is enforcing isolatedModules (even automatically writing it to the config if I remove it manually) and how I may fix my design.
The text was updated successfully, but these errors were encountered:
Babel is used to compile typescript, but requires isolatedModules to be true. Typescript won't let you re-export types when isolatedModules is true because of this. There's your explanation at least.
I came across a workaround that is really weird to me. Writing export * from "./FooComponent"; allows me to re-export and use the classes and interfaces once again. It seems arbitrary that this works but it serves its purposes in my case.
I'll add that you can kinda do the same thing by manually exporting an alias to the type. Kinda annoying, and maybe there's a better way, but it's what I'm doing when I need it.
Is this a bug report?
No
Description
Previously I used the following file structure for components:
In my
FooComponent.tsx
I'd basically define the following:Furthermore I'd re-export the types in
index.tsx
as follows:Unfortunately CRA does not allow me to disable
isolatedModules
in thetsconfig.json
and the compiler is complaining about re-exportingIFooComponentProps
. In my use case I have anIFooComponentProps[]
in another file that I am using to dynamically createFooComponents
. It seems I have to move my props interface into separate files (especially when I use stateful components) which is just unnecessarily increasing the amount of files.I'd like to know why CRA is enforcing
isolatedModules
(even automatically writing it to the config if I remove it manually) and how I may fix my design.The text was updated successfully, but these errors were encountered: