Support for "jsx": "preserve" config
See original GitHub issueAfter issue #58 I’ve realized that we have no support for this options in config which leads to errors that user can’t understand. Possible solutions:
- Find a way to activate
babel-jest
transformer from jest config afterts-jest
applied. - Inform user that this option is not allowed and use
"jsx": "react"
instead. - Include
babel-jest
transformer in our package and run it if"jsx": "preserve"
is used.
As for me third solution seems to be the worst. First of all we have to create tests for this case.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:18
Top Results From Across the Web
Documentation - JSX - TypeScript
The preserve mode will keep the JSX as part of the output to be further consumed by another transform step (e.g. Babel). Additionally...
Read more >what is the use of 'jsx' property in tsconfig.json - Stack Overflow
The preserve mode will keep the JSX as part of the output to be further consumed by another transform step (e.g. Babel).
Read more >Introducing the New JSX Transform – React Blog
Flow supports the new JSX transform in v0.126.0 and up, by adding react.runtime=automatic to your Flow configuration options. Removing Unused ...
Read more >babel/plugin-transform-react-jsx
Though the JSX spec allows this, it is disabled by default since React's JSX does not currently have support for it. You can...
Read more >JSX: The benefits of using it with Vue JS you should explore
If you are using an older version of Vue-cli that doesn't support Vue JSX, ... Setting the jsx option to “preserve” means that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can’t seem to get a react element test to work with ts-jest, and tsconfig: preserve. I reproduced the test using https://github.com/wmonk/create-react-app-typescript, so I know my test is ok.
I tried setting it to
react
in jsx, still same message.my transforms:
any ideas what that message means?
non react tests work like a charm thus far.
BTW, I think this issue is bigger than just JSX. There are a lot of other things that Babel can do beyond just JSX (for instance, the actual implementation side of “allowSyntheticDefaultImports”). I tend to use TypeScript for type-checking and Babel for transpilation for this reason.
Additionally, while I was able to easily chain TypeScript and Babel using a custom preprocessor, I can’t quite get code coverage working. So in the case of 1 or 3, some additional work might be needed to make sure code coverage still works. And if anyone has any tips on making that work manually that’d be awesome.