Make VSCode apply syntax highlighting to .tsx files
Asked Answered
I

6

9

Trying to start a gatsby+react+typescript project and VSCode will only apply syntax highlighting to the HTML in my .tsx files. The typescript code remains a single color. How do I fix this?

Note: I have no plugins installed at the moment and the highlighting works if the file type is set to .jsx

related image

Iconostasis answered 1/10, 2019 at 3:17 Comment(4)
vscode.readthedocs.io/en/latest/languages/typescriptDemetra
What language mode is shown in the lower right corner of the status bar? The file icon suggest that it's not set to typescriptApocryphal
looks like it thinks the file is XML.Iconostasis
Does it work properly if you set it to typescript react? Have you configured files.associations so that tsx files would be treated as xml?Apocryphal
I
11

Clicking on the language button in the lower right corner and selecting typescript react fixed the problem.

Iconostasis answered 8/10, 2019 at 15:24 Comment(0)
D
1

I solved this issue just reloading vscode as required by JavaScript and TypeScript Nightly extension, once it was reload I just double checked that Typescript react was selected and the problem was resolved.

Seems like the real problem was that the library JavaScript and TypeScript Nightly was not fully reloaded.

Dray answered 30/12, 2022 at 5:38 Comment(0)
E
0

I faced same problem, even "Typescript React" was selected as the language. I had to click and select the language pack version before getting syntax highlighting working.

vscode select language pack version

Euphonize answered 2/5, 2020 at 10:43 Comment(0)
M
0

In my case "JavaScript and TypeScript Nightly" extension was causing the problem. I had the same problem even when "Typescript React" was selected. I disabled all the extensions and problem solved. Then I enabled each extension individually and I've found out "JavaScript and TypeScript Nightly" was causing the problem. I hope this will help someone.

Mongolism answered 17/11, 2022 at 13:55 Comment(0)
M
0

Reload the JavaScript and TypeScript Nightly extension solved it (Settings on Auto-Detect)

Meridithmeriel answered 1/5, 2023 at 9:44 Comment(0)
S
0

Here is how I got mine to work:

  1. Click settings for the installed extension
  2. Click 'Extension Settings' from the drop down should see '@ext:kamikillerto.vscode-colorize' in the search bar up top.
  3. Select the option Colorize: Include -> 'Edit in settings.json enter image description here
  4. add "**/*.tsx" to the colorize.include array. enter image description here
Shalloon answered 20/11, 2023 at 13:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.