-
Notifications
You must be signed in to change notification settings - Fork 449
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
.tsx
support
#601
Comments
For some general background on JSX-like grammars: #608 (comment) |
+1 |
1 similar comment
+1 |
+1 👍 |
This morning I started evaluating support for TypeScript in Pretty Diff's JS parser (jspretty.js). If I can correctly identify and parse TypeScript then TSX support is already available, as the parser won't know the difference between TSX and JSX. I am not a TypeScript user myself so I will have a lot of testing to do to ensure I get this right, but also negative impact test against JavaScript and ES6/React support. Once I get a bit further I will start posting beta test links for people to examine so that bugs can be identified. |
Here is something to test against: http://prettydiff.com/ignore/testlocation/index.xhtml?m=beautify Try out some TypeScript and tsx samples at the above tool. If you find any errors please let me know. In the mean time I will be looking for additional TypeScript code samples to test against and perform some regression tests. |
+1 |
It is a type parameter (or type parameter list) and only directly follows interface, class, and function declarations. I still need help as to whether the type parameter can have space between it and the reference it extends. |
Bah, https://github.com/Microsoft/TypeScript/wiki/JSX#the-as-operator
As a result could you guys please pass your TSX code samples through http://prettydiff.com/?m=beautify and let me know if they are beautified appropriately? |
Some issues with formatting after any dot notation. An example: return <button
onClick={this
.item
.bind(this)}>Click Here</button>; |
@ShMcK I have an option for that: |
That's great. But I prefer the chained methods in my logic code, and not so much in my template code. Is it possible to get the best of both worlds when using |
Not yet. I would have to create an option to supply a different setting when JavaScript is a J/TSX attribute. |
+1 |
@prettydiff I run my components through your site and was happy with the result with only a few problems:
render() {
let url = `https://placeholdit.imgix.net/~text?w=${this.props.width}&h=${this.props.height}`;
if (this.props.text != null) {
url += `&txt=${this.props.text.replace(/\s/, "+")}`;
url += `&txtsize=${this.props.textSize}`;
}
return <img src={url} />;
} ended up as render() {
let url = `https://placeholdit.imgix.net/~text?w=${this.props.width}&h=${this.props.height}`;
if (this.props.text != null) {
url += `&txt=${this
.props
.text
.replace(/\s/, "+")}`;
url += `&txtsize=${this.props.textSize}`;
}
return <img src={url}/>;
} Noteworthy might be that it formatted the first chained call while it left the second one alone (perhaps cause the first one was within an ES6 substitute string syntax or the second one didn't contain a method call but only attributes gettting accessed (just a blind guess))? return <footer className="footer">
<div className="container">
<p className="text text-muted">
Made with ♡ from around the world. <br />
© {date.getFullYear()} - All rights reserved.
</p>
</div>
</footer>; which ended up as: render() {
const date = new Date();
return <footer className="footer">
<div className="container">
<p className="text text-muted">
Made with ♡ from around the world.
<br/>
© {date.getFullYear()}
- All rights reserved.
</p>
</div>
</footer>;
} Also: this.props.index.forEach((countries, countryId) => {
countries.forEach((location, locationId) => {
locations.push(this.props.index.get(countryId).get(locationId));
});
}); ended up as this
.props
.index
.forEach((countries, countryId) => {
countries.forEach((location, locationId) => {
locations.push(this.props.index.get(countryId).get(locationId));
});
}); It would be nice (don't know about feasibility) to:
import * as React from "react";
import { Link } from "react-router";
class HeaderComponent extends React.Component<any, any> {
render() {
return <nav className="navbar navbar-inverse navbar-fixed-top">
<div className="container-fluid">
<div className="navbar-header">
<button type="button" className="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span className="sr-only">Toggle navigation</span>
<span className="icon-bar"></span>
<span className="icon-bar"></span>
<span className="icon-bar"></span>
</button>
<a className="navbar-brand" href="#">Project name</a>
</div>
<div id="navbar" className="collapse navbar-collapse">
<ul className="nav navbar-nav navbar-right">
<li className="active"><Link to="/">Locations</Link></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
</div>
</nav>;
}
}
export default HeaderComponent; I'm not sure why, cause those imports are used in other files as well, where they are properly handled, but perhaps it helps you to identify the underlying issue. That said, would it be possible to work together with @Glavin001 and add If that is combined with a link to some known issues list you hopefully wont get too many duplicates while getting more examples where things don't work as intended. WDYT? |
It is only breaking chained properties if one of the properties is a method. I could probably be more uniform about that so that I am always breaking property chains. There is an Atom Beautify to limit this behavior "Break chain methods". If TSX support is fine then somebody just needs to submit an Atom Beautify pull request to add support for the TSX grammar as it would get the same treatment as current JSX support. I am not a TSX user myself so I have just been needing validation and change recommendations. |
For those interested, see Please let me know if you have any questions. While I am unable to allocate time to implementing these new languages into Atom Beautify, I always want to try and encourage collaborators and will do my best to find time to respond with helpful answers. Thank you. |
+1 for |
+1 for tsx support |
TypeScript and TSX supported in the current version of Pretty Diff. An earlier comment mentioned a problem in the way Pretty Diff breaks methods onto lines. I plan to rewrite this logic soon: prettydiff/prettydiff#374 Before you can access the latest version of Pretty Diff in Atom Beautify I need to solve a distribution problem, which I am working at https://github.com/prettydiff/biddle and plan to move from Alpha to Beta version later today. |
+1 for |
Everyone please stop bumping this and instead add your 👍 on the Issue post at the top. I only see ":+1: 2" at the top however here at the bottom are 5+ more 👍 which would not be seen. I also want What we need to make this happen is someone from the community to submit a Pull Request implementing this functionality. It may be as simple as upgrading Pretty Diff and adding |
Keeping everybody informed I have fixed biddle. Check it out now - https://github.com/prettydiff/biddle I will republish Pretty Diff using biddle in production tomorrow. I am not ready to give it to Atom Beautify just yet though. I actually need users to play around with this thing for a bit so that I can get a sense of where the pain points are and just how bad it works for fails for other people. I wrote a getting started document at https://github.com/prettydiff/biddle/blob/master/documentation/gettingstarted.md The documentation might be easier to read from the command line though as I included a markdown to CLI parser in biddle. The number at the end defines the word wrap limit:
|
This needs prettydiff 2.1.X which will be provided with #881 |
What's the status on this issue @Glavin001 @prettydiff? Not much info since January... |
@wbhob Waiting on @prettydiff and #881 . Please subscribe to #881 for progress updates. |
Actually the
This feature request looks to be closed: vvakame/typescript-formatter#18 @wbhob (and others), if you want to get this support official then we need to verify is the Step 1. Create a If all goes well and the
Let me know if you have any questions. Looking forward to seeing a Pull Request! |
Closing tags act up a little bit in tsx... |
In that case please feel free to create an Issue over at https://github.com/vvakame/typescript-formatter and see if they can help support your use case. Once either |
+1 |
1 similar comment
+1 |
If anybody wants TSX support right now then help get this pull request to pass a build: #1750 |
Pretty Diff with TypeScript and TSX support are now in Atom Beautify and will be available once Atom Beautify is published to APM. |
@prettydiff There have been a few releases since then, but I still get a message that TSX is not supported. Any idea when this feature will actually be released? |
So its now been a few months. Does anyone know why TSX support isn't available yet? It isn't just that I need to change something in the settings, right? |
@traviswimer it's not quite that simple, but can be done, I'll see if I can get around to it soon. |
@szeck87 Based on what @prettydiff said when closing the issue, I thought the work was already done for this, and it was just a matter of waiting for a new release. Is that not the case? |
I don't see that it's supported in Atom Beautify. @prettydiff can you elaborate from your last comment? I don't see it anywhere here: https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/prettydiff.coffee#L46-L70 |
I added this to my pull request to update typescript-formatter. @Glavin001 can you please review? |
Merged #2021 |
Published to v0.32.0 |
I would like to suggest support for tsx files which are a jsx extention for typescript.
The text was updated successfully, but these errors were encountered: