I created an asp.net core Reactjs project via Visual Studio 2022. Unfortunately everything is in javascript (not typescript).
How can i enable typescript for this project?
You can compile TypeScript code with NuGet.
First, Add TypeScript support with NuGet: Microsoft.TypeScript.MSBuild
.
Then, Add the tsconfig.json
file to the project root. You can use this file to configure options for the TypeScript compiler.Like this:
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5",
"outDir": "wwwroot/js"
},
"include": [
"scripts/**/*"
]
}
Lastly, Add TypeScript (.ts) or TypeScript JSX (.tsx) files to your project, and then add TypeScript code.
For more details, you can refer to this document and this link .
Hope this can help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.