new: Add JSX Pragma and Preact support #42
+155
−40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
babel-plugin-typescript-to-proptypes
does not support preact.Solution
Allow the plugin to be configured to use different "pragmas", so it can switch between React, Preact, or Inferno.
--
First of all, thanks for the awesome library, I have been using it in many projects, even professional ones, it helps to debug and speeds up development nicely.
One downside of this plugin is, however, that it does not support other JSX powered libraries, it is locked into React.
I have been using Preact for some of my projects and would love for this plugin to support it as well!
For that, I have forked your repository and made some changes, to allow the plugin to switch contexts between react and preact.
To use preact, a user can simply set up a "jsxPragma" config option to "preact". The plugin will then use preact references instead of React ones.
I had to do some small code refactoring for this to work. That is, extract constants and use some helper methods.
Please let me know what you think :)
(The code is still under development, and I am looking for feedback)