How can I make Visual Studio 2019 treat .js files as .jsx?

Viewed 634

How can I make Visual Studio 2019 treat .js files as .jsx? Currently my projects use only .js files even though they contain JSX for React. Currently I use WebStorm which handles this with no problem, but Visual Studio 2019 shows errors until I change the file extension to .jsx. It's not really feasible for me to change everything to .jsx extension currently, so I'm wondering if there is anyway for me to force Visual Studio to treat .js files as .jsx. Is this possible?

1 Answers

Navigate to Tools > Options > Text Editor > File Extension and add an entry to map file extension js to Editor TypeScript Editor. This may require you to close and re-open any .js editor windows.

Note that even though .jsx isn't a typescript file, Visual Studio still uses the TypeScript Editor.

.js -> TypeScript Editor Mapping

Related