Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build: Cannot use JSX unless the '--jsx' flag is provided

I am using VS 2013 and tsx files with react. I can build my project manually just fine. (Right click and build solution)

But when I try to publish on Azure, VS tries to build again but at that time I am getting all bunch of errors stated as:

Error   2   Build: Cannot use JSX unless the '--jsx' flag is provided. 

and points to my tsx files.

Seems like Azure Publish using different kind of build steps than VS 2013 does.

How can I fix this issue?

Azure publish error

VS 2013 errors

like image 924
Teoman shipahi Avatar asked Feb 03 '16 06:02

Teoman shipahi


2 Answers

I added "jsx": "react" to my tsconfig.json to resolve this error:

{
    "compileOnSave": true,
    "compilerOptions": {
        "target": "es6",
        "outFile": "Content/app.js",
        "sourceMap": true,
        "jsx": "react"
    }
}
like image 164
Andy Edinborough Avatar answered Oct 03 '22 01:10

Andy Edinborough


Adding this to the csproj worked for me in VS2015:

<PropertyGroup>
  <TypeScriptJSXEmit>react</TypeScriptJSXEmit>
</PropertyGroup>

From: Working around "Cannot use JSX unless the '--jsx' flag is provided." using the TypeScript 1.6 beta

like image 30
theycallmemorty Avatar answered Oct 03 '22 01:10

theycallmemorty