Skip to content
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

new: Add JSX Pragma and Preact support #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JoaoVictorLouro
Copy link

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)

@milesj
Copy link
Owner

milesj commented Nov 7, 2020

@JoaoVictorLouro Sorry for the late response. Looking good but can you run the entire test suite against this preact pragma so that all the snapshots exist?

@henrikyt
Copy link

Hi guys.
This looks awesome, exactly the special sauce I would need.
Any plans on merging?

@milesj
Copy link
Owner

milesj commented Dec 17, 2020

@henrikyt Just waiting on @JoaoVictorLouro to add more tests. I currently don't have time myself to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants