When the TypeScript file does not contain any JSX, _why did you guys use .TSX instead of .TS ?_
I know it does not really matter, but using .TSX signifies there is JSX inside.
Probably should keep .TS for plain TypeScript and .TSX when there is some JSX. Just my two cents for consistency.
It was just simpler to stick with TSX files across the board instead of involving users with this explanation. If you know the difference, that's great and you should feel free to use .ts when JSX isn't used, but in the end .ts files will always be able to interface with .tsx files anyway.
I'd be willing to hear out more feedback on this.
This seems an appropriate place to ask. Any reason we cant do what the JavaScript people do and just drop he x? And allow JSX in a ts file? Might be a TypeScript compiler question but just curious...
.ts files have an <AngleBracket> type assertion syntax which conflicts with the JSX grammar. In order to avoid breaking a ton of people, we use .tsx for JSX, and added the foo as Bar syntax which is allowed in both .ts and .tsx files.
My point was just for sake of clarity. You can see clearly that there is no JSX in a file its it's only a .TS, its if .TSX, you can (should) assume there's JSX inside.
In version 3.0, if you follow semver, it is acceptable to have some breaking changes.
If you are naming the next version as 3.0 instead of 2.10, why not to kill this <AngleBracket> type assertion syntax to allow JSX in both *.ts and *.tsx files, and maybe in 4.0 kill the *.tsx extension?
I like @lmcarreiro 's suggestion!
For me the argument of .tsx vs. .ts extensions would be the same as .jsx vs. .js and in that sense I think Dan Abramov killed that debate with this comment here 馃樃
In the meantime I'm more than happy to just use .tsx extensions everywhere.
Most helpful comment
.tsfiles have an<AngleBracket>type assertion syntax which conflicts with the JSX grammar. In order to avoid breaking a ton of people, we use.tsxfor JSX, and added thefoo as Barsyntax which is allowed in both.tsand.tsxfiles.