-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Types not being generated if no react import present #64
Comments
Ok so I found a way but only for working for version v1.4.x Base on this info https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#:~:text=import%20%7Bjsx%20as%20_jsx%7D%20from%20%27react/jsx%2Druntime%27%3B If we add this to the line mentioned above it works. The question is... why it works for this version but not for v2?
|
I think the best solution is to decouple from With that being said, I don't really use or maintain this plugin anymore. |
I don't understand really what's on your mind? You can't decouple from react if the main purpose of usage of prop-types is... react, right? I mean, are you refeering to JSX? So detecting if a document is using JSX and if so applying type extraction rather than relying on react for it? |
@carlesnunez Yeah, we would need to detect JSX or React components directly instead, since the react import is no longer required. |
Hello, with latest typescript compiler versions is not needed to import react. I detected that when not adding the import the plugin does not generate the types. It makes sense as checking the code we ultimatelly rely on react being imported to move on. If not we just stop execution:
https://github.com/milesj/babel-plugin-typescript-to-proptypes/blob/master/src/index.ts#L133
I'm more than open to open a PR but I'm curious about what would be the prefered approach? I'm thinking on adding a config option like "usesReactLessFiles" and in that case we rely on other thing to perform the transpilation?
The text was updated successfully, but these errors were encountered: