-
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
Enable JSX syntax in .ts files #26489
Comments
Increased compiler complexity and yet another compiler flag for questionable gain. Why not just use |
There are parsing conflicts with |
Could we deprecate the |
I'd like to see an option to completely disable the edit: I didn't see the above when posting this. I guess we are stuck for now. 😕 🤷♂️
|
Continued in #30503. |
Since #30503 was closed, but has received a lot of feedback from users, here are the reactions from that issue (140 upvotes, 27 downvotes, 22 hearts): ...or #30503 could just become the open, canonical issue and this one closed @RyanCavanaugh? |
I don't see value in prioritizing drive-by votes via Twitter over organic traffic, nor particularly care to encourage people to log new issues because they didn't like the resolution of prior ones. |
Got it, no problem. I do think that Twitter, the work of developer advocates and other publicity can be an effective tools to highlight issues that developers aren't aware are possible to change (or aren't aware where to go to demonstrate about them). Organic traffic is unfortunately a very bad way of getting real developer feedback:
However, I do agree that votes can be biased in this regard. And I also agree that reopening closed issues is untenable. On this particular issue though, guy feeling says that the vote represents how the community feels about it:
|
It's meaningful to distinguish two kinds of votes:
The latter is often a 10x or 100x multiplier on the former. We've seen this before where Influencers will link an issue on Twitter and suddenly that issue gets dozens of upvotes out of nowhere, and I don't want popular Twitter personalities to be the sole deciders of feature priority. Reddit has I am personally quite skeptical that all 140 people who upvoted the duplicate issue had just failed to find the issue with the most obvious title possible for this feature back the first time they realized they wanted it. |
It's simple. People are lazy. Most were probably not even looking for it in the first place, but they were willing to give their opinion when the issue was served on a platter. I think you're underestimating how large percentage of the TS community are also using JSX and bothered by the current behavior. The React community is huge. Since you're not convinced by the votes, I would instead encourage reaching out to known individuals in the TS that use JSX and ask them for feedback. Quality feedback is always better than faceless votes. |
I'm going to repost a part of constructive debate from the other topic. @weswigham pointed out a major obstacle to allowing the syntax as-is in My reply was to suggest an alternative:
Note that I did not research whether this is doable, or if it's still an issue for the parser. |
What about |
JSX is already allowed in JS files |
Let me clarify, I am using Typescript in |
On reason I wish Also, the extra file extensions are just one more piddly detail to configure for tools/package script usage of Having used JSX in |
I felt the same way when I switched to ts from js. |
This may or may not be related, but I would like for jsx parsing to be enabled as a default feature (or at least a command line option) so that the ts-node REPL will be able to use JSX for quick experiments in interactive sessions. |
How about adding annotation/pragma in ts files to parse jsx @RyanCavanaugh
|
Sometimes we cannot use tsx, because in games tsx is the extension of tiled map files. |
As snarky and silly as it may seem, I just don't want to. It's a very subjective thing, but I consider it "dirty" to have two different file extensions for such a slight difference in syntax, merely because the compiler is unable to tell the difference between generics and JSX otherwise. Sure, I can just use ts and tsx, and whenever the compiler complains about using the wrong syntax for the current file extension, it's pretty easy to just rename it, but all these things add up to a death by a thousand cuts where all the different syntax, flags, all the rules, and all the exceptions to those rules just create more and more stuff that I have to remember, on top of trying to understand what the code is doing, understanding the domain problem I'm trying to solve with code, and a dozen other things. The same issue exists in JS ecosystem tooling where everything is a plugin, with flags, and config files, but that's a different rant for another day, I suppose... 😖. |
Well...we already have a '.mjs' extension for ecma modules...but in my experience it actually creates more problems than it solves. Also, it was my understanding that even the original React creators of the JSX syntax no longer recommend using the .jsx extension, citing issues related to those described in the thread above. If that would have happened sooner, do you think TypeScript would still expect a separate extension? Also, maybe I'm just imagining this, but didn't we have a separate extension for files that depended on Babel? (Sorry, I don't use that much Babel anymore.) The bottom line is, unless the syntax is just COMPLETELY different (as in part of a wholly different spec) then the idea using a different file extension doesn't make any sense to me. We're talking about a single syntactical construct here. |
Vendor lock-in, the |
Search Terms
JSX, extension, React
Suggestion
How about adding new compiler option to enable JSX syntax in .ts files?
Currently, JSX syntax is available in only .tsx files, but I want to use same extension, .ts, regardless of whether JSX syntax is used.
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: