Include `jsx` in filetype when extension is `tsx`
Following the convention that the filetype for .jsx files is javascript.jsx, .tsx files should also include the jsx filetype.
This enables syntax highlighting for the JSX portion in .tsx files.
@leafgarland, any thoughts on this?
Hi @chaucerbao do you use a tsx syntax like ianks/vim-tsx? I'd like to know how this affects using, not using that.
I do not use ianks/vim-tsx. I use mxw/vim-jsx which only handles the JSX fragments.
Here's a tiny example of the typescript setup (left), versus a typescript.jsx setup (right).

On the left, there is minimal/basic highlighting of the JSX portion of the code, but on the right, the JSX tags and attributes are accounted for, and there is no interference with the non-JSX portions.
I notice that ianks/vim-tsx sets the filetype to typescript.tsx
autocmd BufNewFile,BufRead *.tsx set filetype=typescript.tsx
However, I don't think tsx should be in the filetype, tsx is more like a file extension that represents "Typescript with JSX".
@leafgarland, it looks like you've already accounted for ianks/vim-tsx with this code. I've run your plugin alone (with the JSX update), as well as both your and ianks/vim-tsx plugins together, and ianks/vim-tsx seems to take precedence when both are loaded (filetype becomes typescript.tsx).
Is that your experience as well? If so, then this update should be pretty safe.
Nice work, thanks. I'll double check on my setup and merge if no issues.
@leafgarland, have you run into any issues with this?
ping @leafgarland @chaucerbao
@bttf Not much for me to do here. Just waiting to see if the PR works for @leafgarland
I tried this out with mxw/vim-jsx and some syntax highlighting broke. It looked like once it got inside a jsxRegion it never came out and the rest of the file had broken syntax highlighting.
It still works ok with ianks/vim-tsx and without either.
Oh interesting. I've been running vim-jsx through vim-polyglot without issues for a long time. However, I just noticed that vim-polyglot has recently started using a fork since mxw/vim-jsx "appears to have been abandoned".
I imagine others would have run into the issue you're seeing, but I haven't come across any mentions of it yet, in this (current) thread, or this one
Just cleaning up