TypeScript folder is missing when launching app

Viewed 40

I have a problem when I want to test a website. When I launch my app in Visual Studio 2022, it compiles my Typescript files correctly but it's like my site waited for the TS files and didn't find it.

Problem in the browser

As you can see on the picture, the TSScripts folder seems to be in a bad state and it seems to be the problem.

I imagine it could be due to an error or a lack in my tsconfig.json. here is it's content :

{
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "ES6",
    "outDir": "wwwroot/js",
    "module": "ES6",
    "esModuleInterop": true
  },
  "include": [
    "TSScripts/**/*"
  ],
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

Can someone help me ?

Thank you.

Philippe

1 Answers

I don't know what framework you're using, but TS files are not valid files to run in the browser. You need to compile your TS files into .js files before your browser can understand it. tsc does this beautifully and the output folder can be set using the outDir option in tsconfig.json. You would then point your HTML to include that folder.

Related