-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Factory-resolved JSX namespaces #18131
Comments
//cc @RyanCavanaugh |
This isn't just a problem for React. It is a problem for any multi package project where you have cross dependencies and you are trying to work with TypeScript. Projects that have different versions of |
I really like this idea. |
Current issues
Two recent issues we've observed relatively frequently with our JSX implementation includes the following:
@types/react
can have differing declarations of JSX. This is problematic because the JSX namespace is global and these conflicts are surfaced to users rather than library authors. This makes for a bad experience. (Code sharing between multiple React projects causing TS2403 #17111)Mitigations
For each of the above issues respectively:
"react"
or some such libraryIdea
@mhegazy and I have discussed this, and believe it is worth exploring the idea of resolving JSX namespaces from the same module as the factory function itself. In other words, if the JSX factory is
React.createElement
, TypeScript should attempt to resolve theJSX
namespace from the location of the factory function itself.Code could temporarily be defined that works in both older and newer versions of TypeScript:
Duplicate JSX declaration errors would still be a problem (and potentially exacerbated), but after several versions we could remove the global augmentations.
Open questions:
The text was updated successfully, but these errors were encountered: