-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add option to output .js files while preserving jsx #13636
Add option to output .js files while preserving jsx #13636
Conversation
This commit adds the ability to preserve jsx in source code, but also to output .js files rather than .jsx files. This is useful for react-native which does not support .jsx files.
Hi @ds300, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
Thanks! We were thinking the option name should just be |
A much better name :) I'll make the change later tonight. |
You also need to enable notification for es5 transformation for new option. Refer: https://github.com/Microsoft/TypeScript/blob/master/src/compiler/transformers/es5.ts#L17 |
Also please add tests in tests\cases\compiler for easy baseline verification of this scenario. Thank you |
@sheetalkamat I think I made the appropriate change in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave a comment
@@ -0,0 +1,22 @@ | |||
/// <reference path="fourslash.ts" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be a fourslash test (they are much slower than compiler baselines). See other tests in tests/cases/compiler
for how to write a multi-file baseline test (search "@filename
")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other compiler testcases I made after this also test the PR's behaviour, so I suppose I can just delete this fourslash one.
@@ -1798,9 +1798,10 @@ declare namespace ts.server.protocol { | |||
namespace JsxEmit { | |||
type None = "None"; | |||
type Preserve = "Preserve"; | |||
type ReactNative = "ReactNative"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you revert the changes to this file, the file is generated as part of the build. you have edited the correct file under src/server/protocol.ts
This PR adds the ability to preserve jsx in source code, but also to output
.js
files rather than.jsx
files. This is useful for react-native which does not support.jsx
files.This is a replacement PR for #9864 which seems to have stalled. It also solves #11158.