-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code sharing between multiple React projects causing TS2403 #17111
Comments
I had the same issue. I found this workaround:
And then in the projects:
This solved the issue for me ... and seems alright as long as you are using the same version of the type definitions everywhere. The only caveat I can think of is that you have to consciously remember to update the version in package.json everywhere whenever you want to use a newer version of the package. |
You can always use Path Mapping (i.e. |
This issue has been marked as 'Question' and has seen no recent activity. It has been automatically closed for house-keeping purposes. If you're still waiting on a response, questions are usually better suited to stackoverflow. |
TypeScript Version: 2.4.1
Code
Expected behavior:
I'm able to import a React component from one React project to another.
Actual behavior:
Hundreds of errors like these ones:
I think what's happening is that both A and B depend on React, but somehow TypeScript gets confused since they are in different projects. If B is in the same project, no issue at all. But when it's in another project, the build ends up with two React typings files, and it sees them as a redefinition. Any workarounds to this problem?
The text was updated successfully, but these errors were encountered: