1

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?

0

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

So this worked wonderfully. However it seems when i runt he web app it is not able to know anything about the components which i converted (renamed) to TSX.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.