Fixing the Visual Studio 2017 error "Cannot use JSX unless the '-jsx' flag is provided" when with React and TypeScript views (TSX files)

Posted: (EET/GMT+2)

 

If you are using Visual Studio 2017 to develop React applications with TypeScript, you might run into the following error message, either in the Error List view, or directly in the code editor with that red "squiggle" underline:

Cannot use JSX unless the '-jsx' flag is provided.

To solve this problem, go to your project's properties in Visual Studio, and then select the TypeScript Build tab. On that page, make sure the "JSX compilation in TSX files" option is set to "React", and not "None", which is the default.

This should solve the problem!